X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=d98d11ecb38162a4b39c087e261510b630e5f386;hp=60c437a9216fa1836018ace8431157a519ae6e87;hb=d492bb51af64fc85678cd73e8dfe6dd2cdcf8748;hpb=65d56ae6b77952ffacfbff6dcef09f30e5e94949 diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 60c437a92..d98d11ecb 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -194,7 +194,14 @@ sub insert { my ($cust_bill) = ($cust_main->cust_bill)[-1]; # most recent invoice return "can't accept prepayment for an unbilled customer" if !$cust_bill; - my %billing_pkgs = map { $_->pkgnum => $_ } $cust_main->billing_pkgs; + # %billing_pkgs contains this customer's active monthly packages. + # Recurring fees for those packages will be credited and then rebilled + # for the full discount term. Other packages on the last invoice + # (canceled, non-monthly recurring, or one-time charges) will be + # left as they are. + my %billing_pkgs = map { $_->pkgnum => $_ } + grep { $_->part_pkg->freq eq '1' } + $cust_main->billing_pkgs; my $credit = 0; # sum of recurring charges from that invoice my $last_bill_date = 0; # the real bill date foreach my $item ( $cust_bill->cust_bill_pkg ) {