[freeside-commits] freeside/FS/FS/cust_main Billing.pm,1.21,1.22

Erik Levinson levinse at wavetail.420.am
Thu Jan 13 08:35:18 PST 2011


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

Modified Files:
	Billing.pm 
Log Message:
optionally generate line items which are fully discounted, RT10481

Index: Billing.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main/Billing.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -w -d -r1.21 -r1.22
--- Billing.pm	28 Nov 2010 00:02:03 -0000	1.21
+++ Billing.pm	13 Jan 2011 16:35:16 -0000	1.22
@@ -584,17 +584,23 @@
   my @cust_bill_pkg = ();
   my @cust_bill_pkg_bundle = ();
   my $sum = 0;
+  my $discount_show_always = 0;
 
   foreach my $cust_bill_pkg ( @_ ) {
+    $discount_show_always = ($cust_bill_pkg->get('discounts')
+				&& scalar(@{$cust_bill_pkg->get('discounts')})
+				&& $conf->exists('discount-show-always'));
     if (scalar(@cust_bill_pkg_bundle) && !$cust_bill_pkg->pkgpart_override) {
-      push @cust_bill_pkg, @cust_bill_pkg_bundle if $sum > 0;
+      push @cust_bill_pkg, @cust_bill_pkg_bundle 
+			if ($sum > 0 || ($sum == 0 && $discount_show_always));
       @cust_bill_pkg_bundle = ();
       $sum = 0;
     }
     $sum += $cust_bill_pkg->setup + $cust_bill_pkg->recur;
     push @cust_bill_pkg_bundle, $cust_bill_pkg;
   }
-  push @cust_bill_pkg, @cust_bill_pkg_bundle if $sum > 0;
+  push @cust_bill_pkg, @cust_bill_pkg_bundle
+			if ($sum > 0 || ($sum == 0 && $discount_show_always));
 
   (@cust_bill_pkg);
 
@@ -956,9 +962,13 @@
       return "negative recur $recur for pkgnum ". $cust_pkg->pkgnum;
     }
 
+    my $discount_show_always = ($recur == 0 && scalar(@discounts) 
+				&& $conf->exists('discount-show-always'));
+
     if ( $setup != 0 ||
          $recur != 0 ||
-         !$part_pkg->hidden && $options{has_hidden} ) #include some $0 lines
+         (!$part_pkg->hidden && $options{has_hidden}) || #include some $0 lines
+	 $discount_show_always ) 
     {
 
       warn "    charges (setup=$setup, recur=$recur); adding line items\n"
@@ -1004,9 +1014,11 @@
       # handle taxes
       ###
 
+      unless ( $discount_show_always ) {
       my $error = 
         $self->_handle_taxes($part_pkg, $taxlisthash, $cust_bill_pkg, $cust_pkg, $options{invoice_time}, $real_pkgpart, \%options);
       return $error if $error;
+      }
 
       push @$cust_bill_pkgs, $cust_bill_pkg;
 



More information about the freeside-commits mailing list