[freeside-commits] branch FREESIDE_4_BRANCH updated. 0431b7a1654c5eebaa9d8cc5c6b0de8494687e59

Jonathan Prykop jonathan at 420.am
Mon Jul 6 20:27:33 PDT 2015


The branch, FREESIDE_4_BRANCH has been updated
       via  0431b7a1654c5eebaa9d8cc5c6b0de8494687e59 (commit)
       via  76ee5744397527a0f9421972b4c93aaeed7ba26f (commit)
      from  10adcf87ec8dc7e17d7ef180a924e7cd8a1ff917 (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 0431b7a1654c5eebaa9d8cc5c6b0de8494687e59
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 e9276ff..37b8e79 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;
@@ -608,6 +608,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'));
 
@@ -691,6 +692,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>

commit 76ee5744397527a0f9421972b4c93aaeed7ba26f
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Jun 26 01:08:34 2015 -0500

    RT#24684: Payments for Online Bill Pay

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 610754c..e9276ff 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -130,7 +130,7 @@ sub skin_info {
       ),
       'menu_disable' => [ $conf->config('selfservice-menu_disable',$agentnum) ],
       ( map { $_ => $conf->exists("selfservice-$_", $agentnum ) }
-        qw( menu_skipblanks menu_skipheadings menu_nounderline no_logo )
+        qw( menu_skipblanks menu_skipheadings menu_nounderline no_logo enable_payment_without_balance )
       ),
       ( map { $_ => scalar($conf->config_binary("selfservice-$_", $agentnum)) }
         qw( title_left_image title_right_image
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index a4b084d..b384d85 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5825,6 +5825,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'selfservice-enable_payment_without_balance',
+    'section'     => 'self-service',
+    'description' => 'Allow selfservice customers to make payments even if balance is zero or below (resulting in an unapplied payment and negative balance.)',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'logout-timeout',
     'section'     => 'UI',
     'description' => 'If set, automatically log users out of the backoffice after this many minutes.',
diff --git a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html
index e33ad57..8c2dfe3 100644
--- a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html
+++ b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html
@@ -3,19 +3,25 @@
 <FORM NAME="OneTrueForm" METHOD="POST" ACTION="<%=$selfurl%>" onSubmit="document.OneTrueForm.process.disabled=true">
 <INPUT TYPE="hidden" NAME="action" VALUE="ach_payment_results">
 <TABLE BGCOLOR="#cccccc">
+<%= 
+if ($balance > 0) {
+  $OUT .= <<EOF;
 <TR>
   <TD ALIGN="right">Amount Due</TD>
   <TD>
     <TABLE><TR><TD BGCOLOR="#ffffff">
-      $<%=sprintf("%.2f",$balance)%>
+      $money_char$balance
     </TD></TR></TABLE>
   </TD>
 </TR>
+EOF
+}
+%>
 <TR>
   <TD ALIGN="right">Payment amount</TD>
   <TD>
     <TABLE><TR><TD BGCOLOR="#ffffff">
-      $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%=sprintf("%.2f",$balance)%>">
+      <%= $money_char %><INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%= ($balance > 0) ? $balance : '' %>">
     </TD></TR></TABLE>
   </TD>
 </TR>
diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html
index 5f5bc1c..503901e 100644
--- a/fs_selfservice/FS-SelfService/cgi/make_payment.html
+++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html
@@ -3,14 +3,21 @@
 <FORM NAME="OneTrueForm" METHOD="POST" ACTION="<%=$selfurl%>" onSubmit="document.OneTrueForm.process.disabled=true">
 <INPUT TYPE="hidden" NAME="action" VALUE="payment_results">
 <TABLE BGCOLOR="#cccccc">
+
+<%= 
+if ($balance > 0) {
+  $OUT .= <<EOF;
 <TR>
   <TH ALIGN="right">Amount Due</TH>
   <TD COLSPAN=7>
     <TABLE><TR><TD BGCOLOR="#ffffff">
-      <FONT COLOR="#000000">$<%=sprintf("%.2f",$balance)%></FONT>
+      $money_char$balance
     </TD></TR></TABLE>
   </TD>
 </TR>
+EOF
+}
+%>
 
 <%= $tr_amount_fee %>
 
diff --git a/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html b/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html
index 9a5678e..8c5b1a8 100755
--- a/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html
+++ b/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html
@@ -8,16 +8,23 @@ onSubmit="document.OneTrueForm.process.disabled=true">
 <INPUT TYPE="hidden" NAME="action" VALUE="post_thirdparty_payment">
 <INPUT TYPE="hidden" NAME="payby_method" VALUE="<%= $payby_method %>">
 <TABLE BGCOLOR="#cccccc">
+<%= 
+if ($balance > 0) {
+  $OUT .= <<EOF;
 <TR>
   <TH ALIGN="right">Balance due</TH>
   <TD COLSPAN=7>
-    <SPAN STYLE="background-color: #ffffff;">$<%=sprintf("%.2f", $balance)%>
+    <SPAN STYLE="background-color: #ffffff;">$money_char$balance</SPAN>
   </TD>
 </TR>
+EOF
+} 
+%>
+
 <TR>
   <TH ALIGN="right">Payment amount</TH>
   <TD COLSPAN=7>
-    $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%=sprintf("%.2f", $balance)%>">
+    <%= $money_char %><INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%= ($balance > 0) ? $balance : '' %>">
   </TD>
 </TR>
 <TR><TH></TH>
diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
index 61926bd..6af5e5e 100644
--- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
+++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
@@ -28,7 +28,7 @@ my %payby_mode;
 # $payby_mode{FOO} is true if FOO is thirdparty, false if it's B::OP,
 # nonexistent if it's not supported
 
-if ( ($balance || 0) > 0 ) { #XXXFIXME "enable selfservice prepay features" flag or something, eventually per-pkg or something really fancy
+if ( $enable_payment_without_balance || (($balance || 0) > 0) ) { #eventually per-pkg or something really fancy
 
   if ( exists( $payby_mode{CARD} ) ) {
     push @menu, { title  => 'Recharge my account with a credit card',
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
index 4c666cb..b2ebaef 100755
--- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
@@ -583,10 +583,15 @@ sub make_payment {
 
   my $payment_info = payment_info( 'session_id' => $session_id );
 
+  my $amount = 
+    ($payment_info->{'balance'} && ($payment_info->{'balance'} > 0))
+    ? $payment_info->{'balance'}
+    : '';
+
   my $tr_amount_fee = mason_comp(
     'session_id' => $session_id,
     'comp'       => '/elements/tr-amount_fee.html',
-    'args'       => [ 'amount' => $payment_info->{'balance'},
+    'args'       => [ 'amount' => $amount,
                     ],
   );
 

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                        |    6 ++++--
 FS/FS/Conf.pm                                       |    7 +++++++
 FS/FS/Misc.pm                                       |   19 ++++++++++++++++++-
 FS/FS/cust_main.pm                                  |    5 ++---
 .../FS-SelfService/cgi/make_ach_payment.html        |   10 ++++++++--
 fs_selfservice/FS-SelfService/cgi/make_payment.html |    9 ++++++++-
 .../FS-SelfService/cgi/make_thirdparty_payment.html |   11 +++++++++--
 .../FS-SelfService/cgi/myaccount_menu.html          |    2 +-
 fs_selfservice/FS-SelfService/cgi/selfservice.cgi   |    7 ++++++-
 .../FS-SelfService/cgi/small_custview.html          |   15 +++++++++++----
 10 files changed, 74 insertions(+), 17 deletions(-)




More information about the freeside-commits mailing list