X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=d98d11ecb38162a4b39c087e261510b630e5f386;hb=573139dbd6c37808697bfa72a3a468bb0980d4dd;hp=60c437a9216fa1836018ace8431157a519ae6e87;hpb=90596b8e3f530a9a9f6ab36c2844b719a34e55ae;p=freeside.git 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 ) {