[freeside-commits] branch master updated. 573a1f97af61acd6d31c70321acbf7bb06bbcebf

Jonathan Prykop jonathan at 420.am
Mon Jul 6 19:17:10 PDT 2015


The branch, master has been updated
       via  573a1f97af61acd6d31c70321acbf7bb06bbcebf (commit)
      from  6400a0ec71fc47b217f4ab12bf95b74b77aeb260 (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 573a1f97af61acd6d31c70321acbf7bb06bbcebf
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Jul 6 21:16:33 2015 -0500

    RT#24684: Payments for Online Bill Pay [Credit Balance Display]

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 85f85de..420ed06 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -23,7 +23,7 @@ use FS::Conf;
 #use FS::UID qw(dbh);
 use FS::Record qw(qsearch qsearchs dbh);
 use FS::Msgcat qw(gettext);
-use FS::Misc qw(card_types);
+use FS::Misc qw(card_types money_pretty);
 use FS::Misc::DateTime qw(parse_datetime);
 use FS::TicketSystem;
 use FS::ClientAPI_SessionCache;
@@ -609,6 +609,7 @@ sub customer_info_short {
         $return{next_bill_date} ? time2str('%m/%d/%Y', $return{next_bill_date} )
                                 : '(none)';
     }
+    $return{balance_pretty} = money_pretty($return{balance});
 
     $return{countrydefault} = scalar($conf->config('countrydefault'));
 
@@ -692,6 +693,7 @@ sub billing_history {
   }
 
   $return{balance} = $cust_main->balance;
+  $return{balance_pretty} = money_pretty($return{balance});
   $return{next_bill_date} = $cust_main->next_bill_date;
   $return{next_bill_date_pretty} =
     $return{next_bill_date} ? time2str('%m/%d/%Y', $return{next_bill_date} )
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index 9aeff93..e1f654c 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -23,6 +23,7 @@ use Encode;
                  csv_from_fixed
                  ocr_image
                  bytes_substr
+                 money_pretty
                );
 
 $DEBUG = 0;
@@ -828,7 +829,7 @@ sub _pslatex {
   }
 
   return if -e "$file.dvi" && -s "$file.dvi";
-  die "pslatex $file.tex failed; see $file.log for details?\n";
+  die "pslatex $file.tex failed, see $file.log for details?\n";
 
 }
 
@@ -982,6 +983,22 @@ sub bytes_substr {
   return Encode::decode('utf8', $bytes, $chk);
 }
 
+=item money_pretty
+
+Accepts a postive or negative numerical value.
+Returns amount formatted for display,
+including money character.
+
+=cut
+
+sub money_pretty {
+  my $amount = shift;
+  my $money_char = $conf->{'money_char'} || '$';
+  $amount = sprintf("%0.2f",$amount);
+  $amount =~ s/^(-?)/$1$money_char/;
+  return $amount;
+}
+
 =back
 
 =head1 BUGS
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 46df3ff..c6602c1 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -32,7 +32,7 @@ use Locale::Country;
 use FS::UID qw( dbh driver_name );
 use FS::Record qw( qsearchs qsearch dbdef regexp_sql );
 use FS::Cursor;
-use FS::Misc qw( generate_email send_email generate_ps do_print );
+use FS::Misc qw( generate_email send_email generate_ps do_print money_pretty );
 use FS::Msgcat qw(gettext);
 use FS::CurrentUser;
 use FS::TicketSystem;
@@ -4241,8 +4241,7 @@ sub payment_history {
     }
     $$item{'balance'} = sprintf("%.2f",$balance);
     foreach my $key ( qw(amount balance) ) {
-      $$item{$key.'_pretty'} = $$item{$key};
-      $$item{$key.'_pretty'} =~ s/^(-?)/$1$money_char/;
+      $$item{$key.'_pretty'} = money_pretty($$item{$key});
     }
     push(@out,$item);
   }
diff --git a/fs_selfservice/FS-SelfService/cgi/small_custview.html b/fs_selfservice/FS-SelfService/cgi/small_custview.html
index 919df56..bcbdbda 100644
--- a/fs_selfservice/FS-SelfService/cgi/small_custview.html
+++ b/fs_selfservice/FS-SelfService/cgi/small_custview.html
@@ -59,10 +59,17 @@ Customer #<B><%= $display_custnum %></B>
 
 </TR></TABLE>
 
-<%= unless ( $access_pkgnum ) {
-      $OUT .= '<BR>Balance: <B>$'. $balance. '</B><BR>';
-    }
-    '';
+<%= 
+unless ( $access_pkgnum ) {
+  if ($balance >= 0) {
+    $OUT .= '<BR>Balance: <B>'. $balance_pretty . '</B><BR>';
+  } else {
+    my $credit_balance_pretty = $balance_pretty;
+    $credit_balance_pretty =~ s/-//;
+    $OUT .= '<BR>Credit Balance: <B>'. $credit_balance_pretty . '</B><BR>';
+  }
+}
+'';
 %>
 
 </DIV>

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                        |    4 +++-
 FS/FS/Misc.pm                                       |   19 ++++++++++++++++++-
 FS/FS/cust_main.pm                                  |    5 ++---
 .../FS-SelfService/cgi/small_custview.html          |   15 +++++++++++----
 4 files changed, 34 insertions(+), 9 deletions(-)




More information about the freeside-commits mailing list