summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2017-12-04 13:06:20 -0500
committerChristopher Burger <burgerc@freeside.biz>2018-04-02 10:47:03 -0400
commit48bbf0e77b2350ef14d2dc47fe1d2d768a89fd8a (patch)
tree078705be3f02635c34b93b38c4d2cc202b74b40a /FS/FS/part_pkg
parent5ec5514cc0b77a4ba930223bccca71f3877ce6d7 (diff)
RT# 33362 - fixed discount_mixin to not throw perl error when trying to discount non monthly recuring.
Diffstat (limited to 'FS/FS/part_pkg')
-rw-r--r--FS/FS/part_pkg/discount_Mixin.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm
index 801737b..1e46536 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
@@ -147,6 +151,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);