[freeside-commits] branch FREESIDE_3_BRANCH updated. 67aa98260da193dcda207e63fd94adbd90a13131

Ivan ivan at 420.am
Fri Dec 5 08:07:31 PST 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  67aa98260da193dcda207e63fd94adbd90a13131 (commit)
      from  7fd1e227ab1b06d27896686b7b86766d87e750be (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 67aa98260da193dcda207e63fd94adbd90a13131
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Dec 5 08:07:30 2014 -0800

    fix invoice viewing

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index b153d31..346e781 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -702,12 +702,13 @@ sub print_generic {
       # "balance_date_range" unfortunately is unsuitable for this, since it
       # cares about application dates.  We want to know the sum of all 
       # _top-level transactions_ dated before the last invoice.
-      my @sql = (
-        "SELECT      COALESCE( SUM(charged), 0 ) FROM cust_bill",
-        "SELECT -1 * COALESCE( SUM(amount),  0 ) FROM cust_credit",
-        "SELECT -1 * COALESCE( SUM(paid),    0 ) FROM cust_pay",
-        "SELECT      COALESCE( SUM(refund),  0 ) FROM cust_refund",
-      );
+      my @sql =
+        map "$_ WHERE _date <= ? AND custnum = ?", (
+          "SELECT      COALESCE( SUM(charged), 0 ) FROM cust_bill",
+          "SELECT -1 * COALESCE( SUM(amount),  0 ) FROM cust_credit",
+          "SELECT -1 * COALESCE( SUM(paid),    0 ) FROM cust_pay",
+          "SELECT      COALESCE( SUM(refund),  0 ) FROM cust_refund",
+        );
 
       # the customer's current balance immediately after generating the last 
       # bill
@@ -715,7 +716,7 @@ sub print_generic {
       my $last_bill_balance = $last_bill->charged;
       foreach (@sql) {
         my $delta = FS::Record->scalar_sql(
-          "$_ WHERE _date <= ? AND custnum = ?",
+          $_,
           $last_bill->_date - 1,
           $self->custnum,
         );
@@ -737,13 +738,11 @@ sub print_generic {
       # to immediately before this one
       my $before_this_bill_balance = 0;
       foreach (@sql) {
-        #warn "$_\n";
         my $delta = FS::Record->scalar_sql(
           $_,
           $self->_date - 1,
           $self->custnum,
         );
-        #warn "$delta\n";
         $before_this_bill_balance += $delta;
       }
       $invoice_data{'balance_adjustments'} =

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Template_Mixin.pm |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)




More information about the freeside-commits mailing list