[freeside-commits] freeside/FS/FS cust_bill.pm, 1.350.2.12, 1.350.2.13 cust_pay.pm, 1.93.2.2, 1.93.2.3

Mark Wells mark at wavetail.420.am
Sat Nov 26 16:49:42 PST 2011


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv539/FS/FS

Modified Files:
      Tag: FREESIDE_2_3_BRANCH
	cust_bill.pm cust_pay.pm 
Log Message:
correct display of prepay discount info with non-monthly packages, #15040

Index: cust_pay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pay.pm,v
retrieving revision 1.93.2.2
retrieving revision 1.93.2.3
diff -u -w -d -r1.93.2.2 -r1.93.2.3
--- cust_pay.pm	13 Oct 2011 07:56:12 -0000	1.93.2.2
+++ cust_pay.pm	27 Nov 2011 00:49:40 -0000	1.93.2.3
@@ -194,7 +194,14 @@
       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 ) {

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.350.2.12
retrieving revision 1.350.2.13
diff -u -w -d -r1.350.2.12 -r1.350.2.13
--- cust_bill.pm	15 Nov 2011 19:41:49 -0000	1.350.2.12
+++ cust_bill.pm	27 Nov 2011 00:49:39 -0000	1.350.2.13
@@ -5203,16 +5203,18 @@
     foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
       my $cust_pkg = $cust_bill_pkg->cust_pkg or next;
       my $part_pkg = $cust_pkg->part_pkg or next;
-
-      next if $part_pkg->freq ne '1';
+      my $freq = $part_pkg->freq;
       my $setup = $cust_bill_pkg->setup || 0;
       my $recur = $cust_bill_pkg->recur || 0;
+
+      if ( $freq eq '1' ) { #monthly
       my $permonth = $part_pkg->base_recur_permonth || 0;
 
       my ($discount) = grep { $_->months == $months } 
                        map { $_->discount } $part_pkg->part_pkg_discount;
 
       $hash->{base} += $setup + $recur + ($months - 1) * $permonth;
+
       if ($discount) {
 
         my $discountable;
@@ -5243,6 +5245,12 @@
         $hash->{discounted} += $setup + $recur + ($months - 1) * $permonth;
         $hash->{list_pkgnums} = 1;
       }
+      } #if $freq eq '1'
+      else { # all non-monthly packages: include current charges only
+        $hash->{discounted} += $setup + $recur;
+        $hash->{base} += $setup + $recur;
+        $hash->{list_pkgnums} = 1;
+      }
     } #foreach $cust_bill_pkg
 
     # don't show this line if no packages have discounts at this term



More information about the freeside-commits mailing list