[freeside-commits] branch FREESIDE_3_BRANCH updated. be4379d3f8238376f913337b6402dd8b6167913a
Jonathan Prykop
jonathan at 420.am
Tue Apr 12 04:01:21 PDT 2016
The branch, FREESIDE_3_BRANCH has been updated
via be4379d3f8238376f913337b6402dd8b6167913a (commit)
from 6aecb23afe1e96c2eb4438a9be0ee76dd70250dd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit be4379d3f8238376f913337b6402dd8b6167913a
Author: Jonathan Prykop <jonathan at freeside.biz>
Date: Tue Apr 12 05:36:58 2016 -0500
RT#28648: Unsuspend when past due balance is paid [new option, Charges not past due]
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index e370fb8..5ea992c 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2106,7 +2106,7 @@ and customer address. Include units.',
'description' => 'Enables the automatic unsuspension of suspended packages when a customer\'s balance due is at or below the specified amount after a payment or credit',
'type' => 'select',
'select_enum' => [
- '', 'Zero', 'Latest invoice charges'
+ '', 'Zero', 'Latest invoice charges', 'Charges not past due'
],
},
diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm
index 645971c..96e520d 100644
--- a/FS/FS/cust_main_Mixin.pm
+++ b/FS/FS/cust_main_Mixin.pm
@@ -660,11 +660,25 @@ sub unsuspend_balance {
my $maxbalance;
if ($setting eq 'Zero') {
$maxbalance = 0;
+
+ # kind of a pain to load/check all cust_bill instead of just open ones,
+ # but if for some reason payment gets applied to later bills before
+ # earlier ones, we still want to consider the later ones as allowable balance
} elsif ($setting eq 'Latest invoice charges') {
my @cust_bill = $cust_main->cust_bill();
my $cust_bill = $cust_bill[-1]; #always want the most recent one
- return unless $cust_bill;
- $maxbalance = $cust_bill->charged || 0;
+ if ($cust_bill) {
+ $maxbalance = $cust_bill->charged || 0;
+ } else {
+ $maxbalance = 0;
+ }
+ } elsif ($setting eq 'Charges not past due') {
+ my $now = time;
+ $maxbalance = 0;
+ foreach my $cust_bill ($cust_main->cust_bill()) {
+ next unless $now <= ($cust_bill->due_date || $cust_bill->_date);
+ $maxbalance += $cust_bill->charged || 0;
+ }
} elsif (length($setting)) {
warn "Unrecognized unsuspend_balance setting $setting";
return;
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Conf.pm | 2 +-
FS/FS/cust_main_Mixin.pm | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
More information about the freeside-commits
mailing list