From 31b49b580727c2c9dca516b9ccbb67b10e6d0fcf Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 11 Jun 2013 23:07:07 -0700 Subject: fix discounts w/quantities, RT#23530 --- FS/FS/part_pkg/flat.pm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'FS') diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index 22eb69815..757e1ceb6 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -120,9 +120,7 @@ sub calc_setup { push @$details, $self->option( 'additional_info' . $i++ ); } - my $quantity = $cust_pkg->quantity || 1; - - my $charge = $quantity * $self->unit_setup($cust_pkg, $sdate, $details); + my $charge = $self->unit_setup($cust_pkg, $sdate, $details); my $discount = 0; if ( $charge > 0 ) { @@ -131,7 +129,7 @@ sub calc_setup { delete $param->{'setup_charge'}; } - sprintf('%.2f', $charge - $discount); + sprintf( '%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) ); } sub unit_setup { @@ -162,11 +160,9 @@ sub calc_recur { $charge *= $param->{freq_override} if $param->{freq_override}; } - my $quantity = $cust_pkg->quantity || 1; - $charge *= $quantity; - my $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param); - return sprintf('%.2f', $charge - $discount); + + sprintf( '%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) ); } sub cutoff_day { -- cgit v1.2.1