summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2010-08-19 10:15:21 +0000
committerivan <ivan>2010-08-19 10:15:21 +0000
commit3f4c9d34c4a031ca061f2f53f6ec4d893b5c3d40 (patch)
tree46df77c89c071d9a935f57fcd12e4a1f62345c39
parent2a282861974954f3ae072363845b8dbffd6decc0 (diff)
fix fixed-amount discounts against packages with pkg add-ons, RT#9669
-rw-r--r--FS/FS/cust_main.pm1
-rw-r--r--FS/FS/part_pkg/flat.pm5
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;