[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 988ca5d2ed7121f00e11456e4919e42529d1aaec

Mark Wells mark at 420.am
Mon Jan 27 16:52:55 PST 2014


The branch, FREESIDE_2_3_BRANCH has been updated
       via  988ca5d2ed7121f00e11456e4919e42529d1aaec (commit)
       via  c8fcbf5ff7dde3f2bf826a9a9098d8c046f0cff4 (commit)
      from  e2c0189bf2deb08a5423226a5adc4d245e64bf4f (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 988ca5d2ed7121f00e11456e4919e42529d1aaec
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Jan 27 16:04:10 2014 -0800

    localize dates that will appear on invoices, #24850

diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 26288bf..9d1631f 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1745,6 +1745,7 @@ sub send_csv {
   my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/cust_bill";
   mkdir $spooldir, 0700 unless -d $spooldir;
 
+  # don't localize dates here, they're a defined format
   my $tracctnum = $self->invnum. time2str('-%Y%m%d%H%M%S', time);
   my $file = "$spooldir/$tracctnum.csv";
   
@@ -2146,7 +2147,7 @@ sub print_csv {
             ? time2str("%x", $cust_bill_pkg->sdate)
             : '' ),
           ($cust_bill_pkg->edate 
-            ?time2str("%x", $cust_bill_pkg->edate)
+            ? time2str("%x", $cust_bill_pkg->edate)
             : '' ),
         );
   
@@ -2746,8 +2747,8 @@ sub print_generic {
     #invoice info
     'invnum'          => $self->invnum,
     '_date'           => $self->_date,
-    'date'            => time2str($date_format, $self->_date),
-    'today'           => time2str($date_format_long, $today),
+    'date'            => $self->time2str_local($date_format, $self->_date),
+    'today'           => $self->time2str_local($date_format_long, $today),
     'terms'           => $self->terms,
     'template'        => $template, #params{'template'},
     'notice_name'     => ($params{'notice_name'} || 'Invoice'),#escape_function?
@@ -2790,16 +2791,10 @@ sub print_generic {
 
   );
  
-  #localization
-  my $lh = FS::L10N->get_handle( $params{'locale'} || $cust_main->locale );
+  #localization (see FS::cust_main_Mixin)
   $invoice_data{'emt'} = sub { &$escape_function($self->mt(@_)) };
-  my %info = FS::Locales->locale_info($cust_main->locale || 'en_US');
-  # eval to avoid death for unimplemented languages
-  my $dh = eval { Date::Language->new($info{'name'}) } ||
-           Date::Language->new(); # fall back to English
   # prototype here to silence warnings
-  $invoice_data{'time2str'} = sub ($;$$) { $dh->time2str(@_) };
-  # eventually use this date handle everywhere in here, too
+  $invoice_data{'time2str'} = sub ($;$$) { $self->time2str_local(@_) };
 
   my $min_sdate = 999999999999;
   my $max_edate = 0;
@@ -2812,8 +2807,9 @@ sub print_generic {
   }
 
   $invoice_data{'bill_period'} = '';
-  $invoice_data{'bill_period'} = time2str('%e %h', $min_sdate) 
-    . " to " . time2str('%e %h', $max_edate)
+  $invoice_data{'bill_period'} = $self->time2str_local('%e %h', $min_sdate) 
+                                 . " to " .
+                                 $self->time2str_local('%e %h', $max_edate)
     if ($max_edate != 0 && $min_sdate != 999999999999);
 
   $invoice_data{finance_section} = '';
@@ -3828,7 +3824,7 @@ sub due_date {
 
 sub due_date2str {
   my $self = shift;
-  $self->due_date ? time2str(shift, $self->due_date) : '';
+  $self->due_date ? $self->time2str_local(shift, $self->due_date) : '';
 }
 
 sub balance_due_msg {
@@ -3850,7 +3846,7 @@ sub balance_due_date {
   my $duedate = '';
   if (    $conf->exists('invoice_default_terms') 
        && $conf->config('invoice_default_terms')=~ /^\s*Net\s*(\d+)\s*$/ ) {
-    $duedate = time2str($rdate_format, $self->_date + ($1*86400) );
+    $duedate = $self->time2str_local($rdate_format, $self->_date + ($1*86400) );
   }
   $duedate;
 }
@@ -3880,7 +3876,7 @@ Returns a string with the date, for example: "3/20/2008"
 
 sub _date_pretty {
   my $self = shift;
-  time2str($date_format, $self->_date);
+  $self->time2str_local($date_format, $self->_date);
 }
 
 =item _items_sections LATE SUMMARYPAGE ESCAPE EXTRA_SECTIONS FORMAT
@@ -4823,7 +4819,7 @@ sub _items_previous {
   foreach ( @pr_cust_bill ) {
     my $date = $conf->exists('invoice_show_prior_due_date')
                ? 'due '. $_->due_date2str($date_format)
-               : time2str($date_format, $_->_date);
+               : $self->time2str_local($date_format, $_->_date);
     push @b, {
       'description' => $self->mt('Previous Balance, Invoice #'). $_->invnum. " ($date)",
       #'pkgpart'     => 'N/A',
@@ -5139,16 +5135,16 @@ sub _items_cust_bill_pkg {
                                             $cust_main->agentnum
                                           );
             if ( defined($date_style) && $date_style eq 'month_of' ) {
-              $time_period = time2str('The month of %B', $cust_bill_pkg->sdate);
+              $time_period = $self->time2str_local('The month of %B', $cust_bill_pkg->sdate);
             } elsif ( defined($date_style) && $date_style eq 'X_month' ) {
               my $desc = $conf->config( 'cust_bill-line_item-date_description',
                                          $cust_main->agentnum
                                       );
               $desc .= ' ' unless $desc =~ /\s$/;
-              $time_period = $desc. time2str('%B', $cust_bill_pkg->sdate);
+              $time_period = $desc. $self->time2str_local('%B', $cust_bill_pkg->sdate);
             } else {
-              $time_period =      time2str($date_format, $cust_bill_pkg->sdate).
-                           " - ". time2str($date_format, $cust_bill_pkg->edate);
+              $time_period =      $self->time2str_local($date_format, $cust_bill_pkg->sdate).
+                           " - ". $self->time2str_local($date_format, $cust_bill_pkg->edate);
             }
             $description .= " ($time_period)";
           }
@@ -5301,8 +5297,8 @@ sub _items_cust_bill_pkg {
         if ( $cust_bill_pkg->recur != 0 ) {
           push @b, {
             'description' => "$desc (".
-                             time2str($date_format, $cust_bill_pkg->sdate). ' - '.
-                             time2str($date_format, $cust_bill_pkg->edate). ')',
+                             $self->time2str_local($date_format, $cust_bill_pkg->sdate). ' - '.
+                             $self->time2str_local($date_format, $cust_bill_pkg->edate). ')',
             'amount'      => sprintf("%.2f", $cust_bill_pkg->recur),
           };
         }
@@ -5376,7 +5372,7 @@ sub _items_credits {
       #                 " (". time2str("%x",$_->cust_credit->_date) .")".
       #                 $reason,
       'description' => $self->mt('Credit applied').' '.
-                       time2str($date_format,$obj->_date). $reason,
+                       $self->time2str_local($date_format,$obj->_date). $reason,
       'amount'      => sprintf("%.2f",$obj->amount),
     };
   }
@@ -5420,7 +5416,7 @@ sub _items_payments {
   foreach my $obj (@objects) {
     my $cust_pay = $obj->isa('FS::cust_pay') ? $obj : $obj->cust_pay;
     my $desc = $self->mt('Payment received').' '.
-               time2str($date_format, $cust_pay->_date );
+               $self->time2str_local($date_format, $cust_pay->_date );
     $desc .= $self->mt(' via ') .
              $cust_pay->payby_payinfo_pretty( $self->cust_main->locale )
       if $detailed;
diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm
index a067706..5a2eccd 100644
--- a/FS/FS/cust_main_Mixin.pm
+++ b/FS/FS/cust_main_Mixin.pm
@@ -578,6 +578,28 @@ sub mt {
   return $lh->maketext(@_);
 }
 
+=item time2str_local FORMAT, TIME
+
+Localizes a date (see L<Date::Language>) for the customer's locale.
+
+=cut
+
+sub time2str_local {
+  # renamed so that we don't have to change every single reference to 
+  # time2str everywhere
+  my $self = shift;
+  if (!exists($self->{_dh})) {
+    my $cust_main = $self->cust_main;
+    my $locale = $cust_main->locale  if $cust_main;
+    $locale ||= 'en_US';
+    my %info = FS::Locales->locale_info($locale);
+    my $dh = eval { Date::Language->new($info{'name'}) } ||
+             Date::Language->new(); # fall back to English
+    $self->{_dh} = $dh;
+  }
+  $self->{_dh}->time2str(@_);
+}
+
 =back
 
 =head1 BUGS

commit c8fcbf5ff7dde3f2bf826a9a9098d8c046f0cff4
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Jan 23 16:08:53 2014 -0800

    also mask EDI acct# on invoices, #26859

diff --git a/FS/FS/payinfo_Mixin.pm b/FS/FS/payinfo_Mixin.pm
index f202bbd..23d24a8 100644
--- a/FS/FS/payinfo_Mixin.pm
+++ b/FS/FS/payinfo_Mixin.pm
@@ -169,6 +169,13 @@ sub mask_payinfo {
              substr($account,(length($account)-2)).
              ( length($aba) ? "@".$aba : '');
 
+    } elsif ($payby eq 'EDI') {
+      # EDI.
+      # These numbers have been seen anywhere from 8 to 30 digits, and 
+      # possibly more.  Lacking any better idea I'm going to mask all but
+      # the last 4 digits.
+      return 'x' x (length($payinfo) - 4) . substr($payinfo, -4);
+
     } else { # Tie up loose ends
       return $payinfo;
     }
@@ -277,6 +284,8 @@ sub payby_payinfo_pretty {
     $lh->maketext('Western Union');
   } elsif ( $self->payby eq 'MCRD' ) {
     $lh->maketext('Manual credit card');
+  } elsif ( $self->payby eq 'EDI' ) {
+    $lh->maketext('EDI') . ' ' . $self->paymask;
   } else {
     $self->payby. ' '. $self->payinfo;
   }

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

Summary of changes:
 FS/FS/cust_bill.pm       |   46 +++++++++++++++++++++-------------------------
 FS/FS/cust_main_Mixin.pm |   22 ++++++++++++++++++++++
 FS/FS/payinfo_Mixin.pm   |    9 +++++++++
 3 files changed, 52 insertions(+), 25 deletions(-)




More information about the freeside-commits mailing list