X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fdiscount_plan.pm;h=6a456766d4d790599f2e13428f8656ab45db041d;hb=368ed08e24400e9d1faf401a1e4e23ea54d2c969;hp=3ae44c8d417493bca7acbafddb5845426d49d3a6;hpb=0aa75d8f76fd378816c1761307c39a68dd689974;p=freeside.git diff --git a/FS/FS/discount_plan.pm b/FS/FS/discount_plan.pm index 3ae44c8d4..6a456766d 100644 --- a/FS/FS/discount_plan.pm +++ b/FS/FS/discount_plan.pm @@ -80,19 +80,24 @@ sub new { $self->{discounted} += $setup; } - if ( $discount->percent ) { + if ( $discount->percent > 0 ) { $discountable += $months * $permonth; $discountable -= ($discountable * $discount->percent / 100); $discountable -= ($permonth - $recur); # correct for prorate $self->{discounted} += $discountable; } - else { + elsif ( $discount->amount > 0 ) { $discountable += $recur; $discountable -= $discount->amount * $recur/$permonth; $discountable += ($months - 1) * max($permonth - $discount->amount,0); + $self->{discounted} += $discountable; + } + else { + warn "discountnum ".$discount->discountnum. + " has no amount or percentage, ignored\n"; + $self->{discounted} = $self->{base}; } - $self->{discounted} += $discountable; push @{ $self->{pkgnums} }, $cust_pkg->pkgnum; } else { #no discount