projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3859395
)
fix final month application of percentage discounts to bundled packages, RT#17045
author
Ivan Kohler
<ivan@freeside.biz>
Sat, 24 Mar 2012 18:31:53 +0000
(11:31 -0700)
committer
Ivan Kohler
<ivan@freeside.biz>
Sat, 24 Mar 2012 18:31:53 +0000
(11:31 -0700)
FS/FS/part_pkg/discount_Mixin.pm
patch
|
blob
|
history
diff --git
a/FS/FS/part_pkg/discount_Mixin.pm
b/FS/FS/part_pkg/discount_Mixin.pm
index
1305942
..
335ff6d
100644
(file)
--- a/
FS/FS/part_pkg/discount_Mixin.pm
+++ b/
FS/FS/part_pkg/discount_Mixin.pm
@@
-82,7
+82,7
@@
sub calc_discount {
#UI enforces one or the other (for now? probably for good)
my $amount = 0;
$amount += $discount->amount
#UI enforces one or the other (for now? probably for good)
my $amount = 0;
$amount += $discount->amount
- if
defined $param->{'real_pkgpart'} &&
$cust_pkg->pkgpart == $param->{'real_pkgpart'};
+ if $cust_pkg->pkgpart == $param->{'real_pkgpart'};
$amount += sprintf('%.2f', $discount->percent * $br / 100 );
my $chg_months = $param->{'months'} || $cust_pkg->part_pkg->freq;
$amount += sprintf('%.2f', $discount->percent * $br / 100 );
my $chg_months = $param->{'months'} || $cust_pkg->part_pkg->freq;
@@
-124,10
+124,12
@@
sub calc_discount {
}
if ( ! defined $param->{'setup_charge'} ) {
}
if ( ! defined $param->{'setup_charge'} ) {
- my $error = $cust_pkg_discount->increment_months_used($months)
- if defined $param->{'real_pkgpart'}
- && $cust_pkg->pkgpart == $param->{'real_pkgpart'};
- die "error discounting: $error" if $error;
+ if ( $cust_pkg->pkgpart == $param->{'real_pkgpart'} ) {
+ push @{ $param->{precommit_hooks} }, sub {
+ my $error = $cust_pkg_discount->increment_months_used($months);
+ die "error discounting: $error" if $error;
+ };
+ }
$amount = min($amount, $br);
$amount *= $months;
$amount = min($amount, $br);
$amount *= $months;