diff options
author | ivan <ivan> | 2005-12-25 00:52:27 +0000 |
---|---|---|
committer | ivan <ivan> | 2005-12-25 00:52:27 +0000 |
commit | 3213e7c1e281dbdba8baa980028482df3b9c1873 (patch) | |
tree | 7096d01bf15dafbdfdc707d28ee6d2d88761acad /FS | |
parent | 9cc2ba7cbf26eefbd1d01a2f98b47a24a8766428 (diff) |
add invoice event to suspend only when greater than N amount
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_bill.pm | 20 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 13 | ||||
-rw-r--r-- | FS/FS/part_bill_event.pm | 2 |
3 files changed, 30 insertions, 5 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 44b50ae74..6e3b2b2f8 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -236,6 +236,25 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } +=item cust_suspend_if_balance_over AMOUNT + +Suspends the customer associated with this invoice if the total amount owed on +this invoice and all older invoices is greater than the specified amount. + +Returns a list: an empty list on success or a list of errors. + +=cut + +sub cust_suspend_if_balance_over { + my( $self, $amount ) = ( shift, shift ); + my $cust_main = $self->cust_main; + if ( $cust_main->total_owed_date($self->_date) < $amount ) { + return (); + } else { + $cust_main->suspend; + } +} + =item cust_credit Depreciated. See the cust_credited method. @@ -2389,6 +2408,7 @@ sub _items_payments { } + =back =head1 SUBROUTINES diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 7866369d7..a265e4177 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1460,7 +1460,8 @@ sub unsuspend { =item suspend Suspends all unsuspended packages (see L<FS::cust_pkg>) for this customer. -Always returns a list: an empty list on success or a list of errors. + +Returns a list: an empty list on success or a list of errors. =cut @@ -1472,8 +1473,9 @@ sub suspend { =item suspend_if_pkgpart PKGPART [ , PKGPART ... ] Suspends all unsuspended packages (see L<FS::cust_pkg>) matching the listed -PKGPARTs (see L<FS::part_pkg>). Always returns a list: an empty list on -success or a list of errors. +PKGPARTs (see L<FS::part_pkg>). + +Returns a list: an empty list on success or a list of errors. =cut @@ -1488,8 +1490,9 @@ sub suspend_if_pkgpart { =item suspend_unless_pkgpart PKGPART [ , PKGPART ... ] Suspends all unsuspended packages (see L<FS::cust_pkg>) unless they match the -listed PKGPARTs (see L<FS::part_pkg>). Always returns a list: an empty list -on success or a list of errors. +listed PKGPARTs (see L<FS::part_pkg>). + +Returns a list: an empty list on success or a list of errors. =cut diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm index 573b21b59..8143e3473 100644 --- a/FS/FS/part_bill_event.pm +++ b/FS/FS/part_bill_event.pm @@ -134,6 +134,8 @@ sub check { or $c =~ /^\s*\$cust_main\->suspend_(if|unless)_pkgpart\([\d\,\s]*\);\s*$/ + or $c =~ /^\s*\$cust_bill\->cust_suspend_if_balance_over\([\d\.\s]*\);\s*$/ + or do { #log return "illegal eventcode: $c"; |