From 3f4c9d34c4a031ca061f2f53f6ec4d893b5c3d40 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Aug 2010 10:15:21 +0000 Subject: [PATCH] fix fixed-amount discounts against packages with pkg add-ons, RT#9669 --- FS/FS/cust_main.pm | 1 + FS/FS/part_pkg/flat.pm | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ac5e45614..c0fb5d297 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -3473,6 +3473,7 @@ sub _make_lines { my %param = ( 'precommit_hooks' => $precommit_hooks, 'increment_next_bill' => $increment_next_bill, 'discounts' => \@discounts, + 'real_pkgpart' => $real_pkgpart, ); my $method = $options{cancel} ? 'calc_cancel' : 'calc_recur'; diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index cc2310503..648a83ddc 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -154,7 +154,7 @@ sub calc_setup { sub unit_setup { my($self, $cust_pkg, $sdate, $details ) = @_; - $self->option('setup_fee'); + $self->option('setup_fee') || 0; } sub calc_recur { @@ -185,7 +185,8 @@ sub calc_discount { my $discount = $cust_pkg_discount->discount; #UI enforces one or the other (for now? probably for good) my $amount = 0; - $amount += $discount->amount; + $amount += $discount->amount + if $cust_pkg->pkgpart == $param->{real_pkgpart}; $amount += sprintf('%.2f', $discount->percent * $br / 100 ); my $chg_months = $param->{'months'} || $cust_pkg->part_pkg->freq; -- 2.11.0