[freeside-commits] branch FREESIDE_4_BRANCH updated. 35a97be88782585537119195cd52eef3d62a9880
Mark Wells
mark at 420.am
Mon Feb 1 16:06:17 PST 2016
The branch, FREESIDE_4_BRANCH has been updated
via 35a97be88782585537119195cd52eef3d62a9880 (commit)
from d024699a657dcafdef6b9161350ae4dc1ccc5d6e (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 35a97be88782585537119195cd52eef3d62a9880
Author: Mark Wells <mark at freeside.biz>
Date: Mon Feb 1 15:52:39 2016 -0800
fix calculation of unused time credit + advance billing, #36726
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index b82303c..8844991 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -247,7 +247,6 @@ sub calc_remain {
foreach my $cust_bill_pkg (
qsearch('cust_bill_pkg', {
pkgnum => $cust_pkg->pkgnum,
- sdate => {op => '<' , value => $time},
edate => {op => '>=', value => $time},
recur => {op => '>' , value => 0},
})
@@ -259,8 +258,17 @@ sub calc_remain {
$edate = $self->add_freq($cust_bill_pkg->sdate);
}
- my $amount = ($cust_bill_pkg->recur - $cust_bill_pkg->usage) *
- ($edate - $time) / ($edate - $cust_bill_pkg->sdate);
+ # this will also get any package charges that are _entirely_ after the
+ # cancellation date (can happen with advance billing). in that case,
+ # use the entire recurring charge:
+ my $amount = $cust_bill_pkg->recur - $cust_bill_pkg->usage;
+
+ # but if the cancellation happens during the interval, prorate it:
+ # (XXX obey prorate_round_day here?)
+ if ( $cust_bill_pkg->sdate < $time ) {
+ $amount = $amount * ($edate - $time) / ($edate - $cust_bill_pkg->sdate);
+ }
+
$credit += $amount;
push @{ $options{'cust_credit_source_bill_pkg'} },
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_pkg/flat.pm | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
More information about the freeside-commits
mailing list