[freeside-commits] freeside/FS/FS Conf.pm, 1.397.2.34, 1.397.2.35 cust_bill.pm, 1.299.2.22, 1.299.2.23

Mark Wells mark at wavetail.420.am
Mon Mar 7 17:47:05 PST 2011


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

Modified Files:
      Tag: FREESIDE_2_1_BRANCH
	Conf.pm cust_bill.pm 
Log Message:
show credit balance on invoices, #11564

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.397.2.34
retrieving revision 1.397.2.35
diff -u -w -d -r1.397.2.34 -r1.397.2.35
--- Conf.pm	4 Mar 2011 02:26:26 -0000	1.397.2.34
+++ Conf.pm	8 Mar 2011 01:47:03 -0000	1.397.2.35
@@ -3435,6 +3435,13 @@
   },
 
   {
+    'key'         => 'previous_balance-show_credit',
+    'section'     => 'invoicing',
+    'description' => 'Show the customer\'s credit balance on invoices when applicable.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'balance_due_below_line',
     'section'     => 'invoicing',
     'description' => 'Place the balance due message below a line.  Only meaningful when when invoice_sections is false.',

Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.299.2.22
retrieving revision 1.299.2.23
diff -u -w -d -r1.299.2.22 -r1.299.2.23
--- cust_bill.pm	5 Mar 2011 20:44:17 -0000	1.299.2.22
+++ cust_bill.pm	8 Mar 2011 01:47:03 -0000	1.299.2.23
@@ -2402,6 +2402,12 @@
                            );
   my $embolden_function = $embolden_functions{$format};
 
+  my %newline_tokens = (  'latex'     => '\\\\',
+                          'html'      => '<br>',
+                          'template'  => "\n",
+                        );
+  my $newline_token = $newline_tokens{$format};
+
   warn "$me generating template variables\n"
     if $DEBUG > 1;
 
@@ -3086,6 +3092,26 @@
       push @buf,[$self->balance_due_msg, $money_char. 
         sprintf("%10.2f", $balance_due ) ];
     }
+
+    if ( $conf->exists('previous_balance-show_credit')
+        and $cust_main->balance < 0 ) {
+      my $credit_total = {
+        'total_item'    => &$embolden_function($self->credit_balance_msg),
+        'total_amount'  => &$embolden_function(
+          $other_money_char. sprintf('%.2f', -$cust_main->balance)
+        ),
+      };
+      if ( $multisection ) {
+        $adjust_section->{'posttotal'} .= $newline_token .
+          $credit_total->{'total_item'} . ' ' . $credit_total->{'total_amount'};
+      }
+      else {
+        push @total_items, $credit_total;
+      }
+      push @buf,['','-----------'];
+      push @buf,[$self->credit_balance_msg, $money_char. 
+        sprintf("%10.2f", -$cust_main->balance ) ];
+    }
   }
 
   if ( $multisection ) {
@@ -3445,6 +3471,8 @@
   $duedate;
 }
 
+sub credit_balance_msg { 'Credit Balance Remaining' }
+
 =item invnum_date_pretty
 
 Returns a string with the invoice number and date, for example:



More information about the freeside-commits mailing list