[freeside-commits] branch FREESIDE_4_BRANCH updated. 40b9222778f9642c80b9a45c2f50b6012b098c48

Mark Wells mark at 420.am
Thu Oct 1 21:15:48 PDT 2015


The branch, FREESIDE_4_BRANCH has been updated
       via  40b9222778f9642c80b9a45c2f50b6012b098c48 (commit)
      from  2014cdef6d9243215d92f7b9fabffa11e32cede5 (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 40b9222778f9642c80b9a45c2f50b6012b098c48
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Oct 1 21:05:14 2015 -0700

    refine disable_previous_balance behavior to show new charges only, #35222, #37396

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 6943fa5..5c9026a 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4300,7 +4300,7 @@ and customer address. Include units.',
   {
     'key'         => 'disable_previous_balance',
     'section'     => 'invoicing',
-    'description' => 'Disable inclusion of previous balance, payment, and credit lines on invoices.',
+    'description' => 'Show new charges only; do not list previous invoices, payments, or credits on the invoice.',
     'type'        => 'checkbox',
     'per_agent'   => 1,
   },
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 206c03c..1a3217c 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -684,7 +684,12 @@ sub print_generic {
   my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance
 #  my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits
   #my $balance_due = $self->owed + $pr_total - $cr_total;
-  my $balance_due = $self->owed + $pr_total;
+  my $balance_due = $self->owed;
+  if ( $self->enable_previous ) {
+    $balance_due += $pr_total;
+  }
+  # otherwise the previous balance is not shown, so including it in the
+  # balance due is just confusing
 
   # the sum of amount owed on all invoices
   # (this is used in the summary & on the payment coupon)
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 54488f9..085a9f1 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2833,8 +2833,7 @@ sub _items_total {
   my ($previous_charges_desc, $new_charges_desc, $new_charges_amount);
 
   if ( $conf->exists('previous_balance-exclude_from_total') ) {
-    # can we do some caching on this stuff? it's going to change infrequently
-    # in production
+    # if enabled, specifically add a line for the previous balance total
     $previous_charges_desc = $self->mt(
       $conf->config('previous_balance-text') || 'Previous Balance'
     );
@@ -2846,6 +2845,12 @@ sub _items_total {
           total_amount  => sprintf('%.2f',$pr_total)
         };
     }
+  }
+
+  if (   $conf->exists('previous_balance-exclude_from_total')
+      or !$self->enable_previous ) {
+    # show new charges only
+
     $new_charges_desc = $self->mt(
       $conf->config('previous_balance-text-total_new_charges')
        || 'Total New Charges'
@@ -2854,9 +2859,14 @@ sub _items_total {
     $new_charges_amount = $self->charged;
 
   } else {
+    # show new charges + previous invoice total
 
     $new_charges_desc = $self->mt('Total Charges');
-    $new_charges_amount = sprintf('%.2f',$self->charged + $pr_total);
+    if ( $self->enable_previous ) {
+      $new_charges_amount = sprintf('%.2f', $self->charged + $pr_total);
+    } else {
+      $new_charges_amount = sprintf('%.2f', $self->charged);
+    }
 
   }
 

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

Summary of changes:
 FS/FS/Conf.pm           |    2 +-
 FS/FS/Template_Mixin.pm |    7 ++++++-
 FS/FS/cust_bill.pm      |   16 +++++++++++++---
 3 files changed, 20 insertions(+), 5 deletions(-)




More information about the freeside-commits mailing list