From 3213e7c1e281dbdba8baa980028482df3b9c1873 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Dec 2005 00:52:27 +0000 Subject: add invoice event to suspend only when greater than N amount --- FS/FS/cust_bill.pm | 20 ++++++++++++++++++++ FS/FS/cust_main.pm | 13 ++++++++----- FS/FS/part_bill_event.pm | 2 ++ 3 files changed, 30 insertions(+), 5 deletions(-) (limited to 'FS') 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) 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) matching the listed -PKGPARTs (see L). Always returns a list: an empty list on -success or a list of errors. +PKGPARTs (see L). + +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) unless they match the -listed PKGPARTs (see L). Always returns a list: an empty list -on success or a list of errors. +listed PKGPARTs (see L). + +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"; -- cgit v1.2.1