fix over-discounting resulting in an error, RT#13450
authorivan <ivan>
Mon, 27 Jun 2011 21:27:36 +0000 (21:27 +0000)
committerivan <ivan>
Mon, 27 Jun 2011 21:27:36 +0000 (21:27 +0000)
FS/FS/part_pkg/discount_Mixin.pm

index a789ab3..87ec3a7 100644 (file)
@@ -130,11 +130,12 @@ sub calc_discount {
             && ! defined $param->{'setup_charge'});
     die "error discounting: $error" if $error;
 
+    $amount = min($amount, $br);
     $amount *= $months;
     $amount = sprintf('%.2f', $amount);
 
     next unless $amount > 0;
-            
+
     # transfer remainder of discount, if any, to setup
     if ( $discount->setup && $discount->amount
         && (!$discount->months || $discount->months != 1)