[freeside-commits] branch FREESIDE_3_BRANCH updated. 479ec8dd320258a22165d05da9624e6571c0daaf

Ivan ivan at 420.am
Wed Jun 18 18:13:23 PDT 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  479ec8dd320258a22165d05da9624e6571c0daaf (commit)
      from  4532048fddaf20751dda7721ee6bab4bac8755ac (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 479ec8dd320258a22165d05da9624e6571c0daaf
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jun 18 18:13:22 2014 -0700

    fix (part of) 3.x performance regression on customers with tons of invoices, RT#29646, RT#24850

diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 23ee6ba..1c373f9 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -2,7 +2,9 @@ package FS::Template_Mixin;
 
 use strict;
 use vars qw( $DEBUG $me
-             $money_char );
+             $money_char
+             $date_format
+           );
              # but NOT $conf
 use vars qw( $invoice_lines @buf ); #yuck
 use List::Util qw(sum);
@@ -26,7 +28,8 @@ $DEBUG = 0;
 $me = '[FS::Template_Mixin]';
 FS::UID->install_callback( sub { 
   my $conf = new FS::Conf; #global
-  $money_char       = $conf->config('money_char')       || '$';  
+  $money_char  = $conf->config('money_char')  || '$';  
+  $date_format = $conf->config('date_format') || '%x'; #/YY
 } );
 
 =item conf [ MODE ]
@@ -1799,7 +1802,8 @@ sub credit_balance_msg {
 
 =item _date_pretty
 
-Returns a string with the date, for example: "3/20/2008"
+Returns a string with the date, for example: "3/20/2008", localized for the
+customer.  Use _date_pretty_unlocalized for non-end-customer display use.
 
 =cut
 
@@ -1808,6 +1812,18 @@ sub _date_pretty {
   $self->time2str_local('short', $self->_date);
 }
 
+=item _date_pretty_unlocalized
+
+Returns a string with the date, for example: "3/20/2008", in the format
+configured for the back-office.  Use _date_pretty for end-customer display use.
+
+=cut
+
+sub _date_pretty_unlocalized {
+  my $self = shift;
+  $self->time2str($date_format, $self->_date);
+}
+
 =item _items_sections OPTIONS
 
 Generate section information for all items appearing on this invoice.
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index fda1c72..58288b4 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2462,9 +2462,12 @@ Returns a string with the invoice number and date, for example:
 
 =cut
 
+#note: this uses _date_pretty_unlocalized because _date_pretty is too expensive
+# for backend use (and also does the wrong thing, localizing for end customer
+# instead of backoffice configured date format)
 sub invnum_date_pretty {
   my $self = shift;
-  $self->mt('Invoice #'). $self->invnum. ' ('. $self->_date_pretty. ')';
+  $self->mt('Invoice #'). $self->invnum. ' ('. $self->_date_pretty_unlocalized. ')';
 }
 
 #sub _items_extra_usage_sections {

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

Summary of changes:
 FS/FS/Template_Mixin.pm |   22 +++++++++++++++++++---
 FS/FS/cust_bill.pm      |    5 ++++-
 2 files changed, 23 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list