fix flat-rate discounts when charging zero months, #17043
authorMark Wells <mark@freeside.biz>
Sat, 24 Mar 2012 23:35:26 +0000 (16:35 -0700)
committerMark Wells <mark@freeside.biz>
Sat, 24 Mar 2012 23:35:26 +0000 (16:35 -0700)
FS/FS/part_pkg/discount_Mixin.pm

index 335ff6d..1edf258 100644 (file)
@@ -84,7 +84,9 @@ sub calc_discount {
     $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;
+    my $chg_months = defined($param->{'months'}) ?
+                      $param->{'months'} :
+                      $cust_pkg->part_pkg->freq;
 
     my $months = $discount->months
     ? min( $chg_months,