[freeside-commits] branch FREESIDE_4_BRANCH updated. c790ded0e7c4724048ab103532946ae8a66befd4

Jonathan Prykop jonathan at 420.am
Thu Feb 25 09:36:46 PST 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  c790ded0e7c4724048ab103532946ae8a66befd4 (commit)
       via  e20d5b22c42670855f0ec5e666078788b9e5aebe (commit)
      from  0959b1a2648c998f81cce61bb5d06c50cef4556e (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 c790ded0e7c4724048ab103532946ae8a66befd4
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu Feb 25 11:27:03 2016 -0600

    RT#30600: Auto Apply for CC payments [no_invnum flag]

diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index e2a0267..53070df 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -154,9 +154,13 @@ specified invoice.  If the customer has exactly one open invoice, that
 invoice number will be assumed.  If you don't specify an I<invnum> you might 
 want to call the B<apply_payments> method or set the I<apply> option.
 
+I<no_invnum> can be set to true to prevent that default invnum from being set.
+
 I<apply> can be set to true to run B<apply_payments_and_credits> on success.
 
-I<no_auto_apply> can be set to true to prevent resulting payment from being automatically applied.
+I<no_auto_apply> can be set to true to set that flag on the resulting payment
+(prevents payment from being applied by B<apply_payments> or B<apply_payments_and_credits>,
+but will still be applied if I<invnum> exists...use with I<no_invnum> for intended effect.)
 
 I<quiet> can be set true to surpress email decline notices.
 
@@ -279,7 +283,7 @@ sub _bop_defaults {
   }
 
   # Default invoice number if the customer has exactly one open invoice.
-  if( ! $options->{'invnum'} ) {
+  unless ( $options->{'invnum'} || $options->{'no_invnum'} ) {
     $options->{'invnum'} = '';
     my @open = $self->open_cust_bill;
     $options->{'invnum'} = $open[0]->invnum if scalar(@open) == 1;
diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi
index a3cfbae..d232fe7 100644
--- a/httemplate/misc/process/payment.cgi
+++ b/httemplate/misc/process/payment.cgi
@@ -232,6 +232,7 @@ if ( $cgi->param('batch') ) {
     'paynum_ref' => \$paynum,
     'discount_term' => $discount_term,
     'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '',
+    'no_invnum'     => 1,
     map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}}
   );
   errorpage($error) if $error;

commit e20d5b22c42670855f0ec5e666078788b9e5aebe
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu Feb 25 09:14:26 2016 -0600

    RT#30600: Auto Apply for CC payments

diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index 747f4af..e2a0267 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -154,7 +154,9 @@ specified invoice.  If the customer has exactly one open invoice, that
 invoice number will be assumed.  If you don't specify an I<invnum> you might 
 want to call the B<apply_payments> method or set the I<apply> option.
 
-I<apply> can be set to true to apply a resulting payment.
+I<apply> can be set to true to run B<apply_payments_and_credits> on success.
+
+I<no_auto_apply> can be set to true to prevent resulting payment from being automatically applied.
 
 I<quiet> can be set true to surpress email decline notices.
 
@@ -903,7 +905,7 @@ sub _realtime_bop_result {
        'processor'      => $payment_gateway->gateway_module,
        'auth'           => $transaction->authorization,
        'order_number'   => $order_number || '',
-
+       'no_auto_apply'  => $options{'no_auto_apply'} ? 'Y' : '',
     } );
     #doesn't hurt to know, even though the dup check is in cust_pay_pending now
     $cust_pay->payunique( $options{payunique} )
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index 02648a8..f30e409 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -33,6 +33,57 @@
     &>
 % }
 
+% my $disallow_no_auto_apply = 0;
+% if ( $conf->exists("batch-enable")
+%      || grep $payby eq $_, $conf->config('batch-enable_payby')
+%    ) {
+%
+%     if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
+%       $disallow_no_auto_apply = 1;
+
+          <INPUT TYPE="hidden" NAME="batch" VALUE="1">
+
+%     } else {
+
+          <TR>
+            <TH ALIGN="right">   <% mt('Add to current batch') |h %></TH>
+            <TD>
+              <INPUT TYPE="checkbox" NAME="batch" VALUE="1" ID="batch_checkbox" ONCHANGE="change_batch_checkbox()">
+            </TD>
+          </TR>
+
+%     }
+% }
+
+% unless ($disallow_no_auto_apply) {
+%   # false laziness with edit/cust_pay.cgi
+
+<TR ID="apply_box_row">
+  <TH ALIGN="right"><% mt('Auto-apply to invoices') |h %></TH>
+  <TD COLSPAN=2>
+    <SELECT NAME="apply" ID="apply_box">
+      <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION> 
+      <OPTION VALUE=""><% mt('not now') |h %></OPTION>
+      <OPTION VALUE="never"><% mt('never') |h %></OPTION>
+    </SELECT>
+  </TD>
+</TR>
+
+% # this can go away if no_auto_apply handling gets added to batch payment processing
+<SCRIPT>
+function change_batch_checkbox () {
+  if (document.getElementById('batch_checkbox').checked) {
+    document.getElementById('apply_box').disabled = true;
+    document.getElementById('apply_box_row').style.display = 'none';
+  } else {
+    document.getElementById('apply_box').disabled = false;
+    document.getElementById('apply_box_row').style.display = '';
+  }
+}
+</SCRIPT>
+
+% }
+
 <SCRIPT TYPE="text/javascript">
   function cust_payby_changed (what) {
     var custpaybynum = what.options[what.selectedIndex].value
@@ -234,26 +285,6 @@
   </TD>
 </TR>
 
-% if ( $conf->exists("batch-enable")
-%      || grep $payby eq $_, $conf->config('batch-enable_payby')
-%    ) {
-%
-%     if ( grep $payby eq $_, $conf->config('realtime-disable_payby') ) {
-
-          <INPUT TYPE="hidden" NAME="batch" VALUE="1">
-
-%     } else {
-
-          <TR>
-            <TD COLSPAN=2>
-              <INPUT TYPE="checkbox" NAME="batch" VALUE="1">
-              <% mt('Add to current batch') |h %> 
-            </TD>
-          </TR>
-
-%     }
-% }
-
 <TR>
   <TD COLSPAN=8>
     <INPUT TYPE="checkbox"<% $auto ? ' CHECKED' : '' %> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi
index 79b43b7..a3cfbae 100644
--- a/httemplate/misc/process/payment.cgi
+++ b/httemplate/misc/process/payment.cgi
@@ -231,6 +231,7 @@ if ( $cgi->param('batch') ) {
     'paycvv'     => $paycvv,
     'paynum_ref' => \$paynum,
     'discount_term' => $discount_term,
+    'no_auto_apply' => ($cgi->param('apply') eq 'never') ? 'Y' : '',
     map { $_ => scalar($cgi->param($_)) } @{$payby2fields{$payby}}
   );
   errorpage($error) if $error;
@@ -251,7 +252,7 @@ if ( $cgi->param('batch') ) {
 
   }
 
-  $cust_main->apply_payments;
+  $cust_main->apply_payments if ($cgi->param('apply') eq 'yes');
 
 }
 

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

Summary of changes:
 FS/FS/cust_main/Billing_Realtime.pm |   12 ++++--
 httemplate/misc/payment.cgi         |   71 +++++++++++++++++++++++++----------
 httemplate/misc/process/payment.cgi |    4 +-
 3 files changed, 63 insertions(+), 24 deletions(-)




More information about the freeside-commits mailing list