summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-12-04 16:45:29 -0800
committerMark Wells <mark@freeside.biz>2015-12-04 16:45:29 -0800
commit52d332b9d4ce7a9aa27ba1da57fefb03275ba9ae (patch)
treebb22b730e1aabd211f85473a019b36be5a470b9f
parent6d0ece61c680a00af35bbf9db6337e32b899257a (diff)
correctly handle percentage discounts with duration less than package billing cycle, #39165, from #19173
-rw-r--r--FS/FS/part_pkg/discount_Mixin.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm
index e411c84e8..5b3f10094 100644
--- a/FS/FS/part_pkg/discount_Mixin.pm
+++ b/FS/FS/part_pkg/discount_Mixin.pm
@@ -134,11 +134,12 @@ sub calc_discount {
} else {
# we are calculating a recurring fee discount. estimate the recurring
- # fee:
- # XXX it would be more accurate for calc_recur to just _tell us_ what
- # it's going to charge
+ # fee. Note we use $months here rather than $chg_months so that if the
+ # remaining discount amount is for less time than the package period,
+ # the "estimated recurring fee" is only for as long as the discount
+ # lasts.
- my $recur_charge = $br * $chg_months / $self->freq;
+ my $recur_charge = $br * $months / $self->freq;
# round this, because the real recur charge is rounded
$recur_charge = sprintf('%.2f', $recur_charge);
@@ -218,7 +219,7 @@ sub calc_discount {
'pkgdiscountnum' => $cust_pkg_discount->pkgdiscountnum,
'amount' => $amount,
'months' => $months,
- # XXX should have a 'setuprecur'
+ # XXX should have a 'setuprecur' (and on 4.x, it does)
};
push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;
$tot_discount += $amount;