fix edge case with prorated packages discounted 100% causing discounts to be off...
[freeside.git] / FS / FS / part_pkg / discount_Mixin.pm
index 0657f3e..63909b3 100644 (file)
@@ -133,7 +133,7 @@ sub calc_discount {
       $amount *= $months;
     }
 
-    $amount = sprintf('%.2f', $amount);
+    $amount = sprintf('%.2f', $amount + 0.00000001 ); #so 1.005 rounds to 1.01
 
     next unless $amount > 0;
 
@@ -155,7 +155,7 @@ sub calc_discount {
     my $cust_bill_pkg_discount = new FS::cust_bill_pkg_discount {
       'pkgdiscountnum' => $cust_pkg_discount->pkgdiscountnum,
       'amount'         => $amount,
-      'months'         => $months,
+      'months'         => ( defined($param->{'setup_charge'}) ? 0 : $months ),
     };
     push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;