fix fixed-amount discounts against packages with pkg add-ons, RT#9669
authorivan <ivan>
Thu, 19 Aug 2010 10:15:21 +0000 (10:15 +0000)
committerivan <ivan>
Thu, 19 Aug 2010 10:15:21 +0000 (10:15 +0000)
FS/FS/cust_main.pm
FS/FS/part_pkg/flat.pm

index ac5e456..c0fb5d2 100644 (file)
@@ -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';
index cc23105..648a83d 100644 (file)
@@ -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;