X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fdiscount_Mixin.pm;h=ec37624f2ad8cb1345a5ad9040d4b3012a736de5;hb=dc83512c36dc6bea2585abada4f88d714c600e55;hp=801737b04b891737198e8bfbc5f3e287908d2750;hpb=b663d0e826c248c218dc9365d4e2d74db2648e48;p=freeside.git diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm index 801737b04..ec37624f2 100644 --- a/FS/FS/part_pkg/discount_Mixin.pm +++ b/FS/FS/part_pkg/discount_Mixin.pm @@ -46,7 +46,11 @@ sub calc_discount { my $conf = new FS::Conf; my $br = $self->base_recur($cust_pkg, $sdate); - $br += $param->{'override_charges'} * ($cust_pkg->part_pkg->freq || 0) if $param->{'override_charges'}; + + ## can not multiply non monthly recurring frequency so skip. + unless ($cust_pkg->part_pkg->freq !~ /^\d+$/) { + $br += $param->{'override_charges'} * ($cust_pkg->part_pkg->freq || 0) if $param->{'override_charges'}; + } my $tot_discount = 0; #UI enforces just 1 for now, will need ordering when they can be stacked @@ -98,7 +102,10 @@ sub calc_discount { # $chg_months: the number of months we are charging recur for # $months: $chg_months or the months left on the discount, whchever is less - my $chg_months = $cust_pkg->part_pkg->freq || 1; + my $chg_months = 1; + unless ($cust_pkg->part_pkg->freq !~ /^\d+$/) { + $chg_months = $cust_pkg->part_pkg->freq || 1; + } if ( defined($param->{'months'}) ) { # then override $chg_months = $param->{'months'}; } @@ -147,6 +154,9 @@ sub calc_discount { # the "estimated recurring fee" is only for as long as the discount # lasts. + # can not multiply non monthly recurring frequency so skip. + next if $self->freq !~ /^\d+$/; + my $recur_charge = $br * $months / $self->freq; # round this, because the real recur charge is rounded $recur_charge = sprintf('%.2f', $recur_charge);