[freeside-commits] branch FREESIDE_4_BRANCH updated. 410e35e2437b99743f7c336cfae296e4150d5a49

Christopher Burger burgerc at freeside.biz
Wed Nov 7 09:52:46 PST 2018


The branch, FREESIDE_4_BRANCH has been updated
       via  410e35e2437b99743f7c336cfae296e4150d5a49 (commit)
       via  b0cfff0976fc64de456b233c61dd9617887e297e (commit)
      from  a64ea9882e4a754d3fd9efb57e2cbf9337baf879 (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 410e35e2437b99743f7c336cfae296e4150d5a49
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Nov 7 12:42:56 2018 -0500

    RT# 74435 - fixed error where payment account no longer exists

diff --git a/httemplate/edit/cust_refund.cgi b/httemplate/edit/cust_refund.cgi
index 149213991..0a5324ad2 100755
--- a/httemplate/edit/cust_refund.cgi
+++ b/httemplate/edit/cust_refund.cgi
@@ -44,10 +44,14 @@
     <TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff"><% time2str($date_format, $cust_pay->_date) %></TD>
   </TR>
 
+% if ( $cust_payby ) {
   <TR>
-    <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff"><% $payby %> # <% $paymask %></TD>
-    <INPUT TYPE="hidden" NAME="custpaybynum" VALUE="<% $cust_payby->custpaybynum %>">
+    <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff">
+      <% $payby %> # <% $paymask %>
+      <INPUT TYPE="hidden" NAME="custpaybynum" VALUE="<% $cust_payby->custpaybynum %>">
+    </TD>
   </TR>
+% }
 
 % unless ( $paydate || $cust_pay->payby ne 'CARD' ) {  # possibly other reasons: i.e. card has since expired
   <TR>
@@ -134,10 +138,7 @@
 %                      ? scalar($cgi->param('custpaybynum'))
 %                      : scalar(@cust_payby) && $cust_payby[0]->custpaybynum;
 
-% if ($cust_pay) {
-  <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10>
-% }
-% else {
+% if ( !$cust_payby ) {
   <& /elements/tr-select-cust_payby.html,
      'cust_payby' => \@cust_payby,
      'curr_value' => $custpaybynum,
@@ -161,7 +162,7 @@
     </TABLE>
 <P>
 
-%   if ( !$cust_pay ) {
+%   if ( !$cust_payby ) {
 <DIV ID="cust_payby"
   <% $custpaybynum ? 'STYLE="display:none"'
                    : ''
@@ -176,7 +177,7 @@
 
 </TABLE>
 </DIV>
-%   } # end if cust_pay
+%   } # end if cust_payby
 
 %  } else {
     <INPUT TYPE="hidden" NAME="payinfo" VALUE="">
@@ -234,10 +235,10 @@ if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
       unless $custnum == $cust_pay->custnum;
   } else {
     $custnum = $cust_pay->custnum;
+    $cgi->param(-name=>"custnum", -value=>$custnum) unless $cgi->param("custnum");
   }
   # get custpayby
-  die "Can not find payby record!"
-  unless $cust_payby = qsearchs(
+  $cust_payby = qsearchs(
     'cust_payby', { paymask => $cust_pay->paymask, custnum => $custnum }
   );
 

commit b0cfff0976fc64de456b233c61dd9617887e297e
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Nov 7 11:32:05 2018 -0500

    RT# 74435 - fixed so payment would auto unapply when doing a batch refund

diff --git a/httemplate/edit/cust_refund.cgi b/httemplate/edit/cust_refund.cgi
index f3dec98e1..149213991 100755
--- a/httemplate/edit/cust_refund.cgi
+++ b/httemplate/edit/cust_refund.cgi
@@ -46,6 +46,7 @@
 
   <TR>
     <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff"><% $payby %> # <% $paymask %></TD>
+    <INPUT TYPE="hidden" NAME="custpaybynum" VALUE="<% $cust_payby->custpaybynum %>">
   </TR>
 
 % unless ( $paydate || $cust_pay->payby ne 'CARD' ) {  # possibly other reasons: i.e. card has since expired
@@ -221,7 +222,7 @@ my $batch   = $cgi->param('batch');
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->refund_access_right($payby);
 
-my( $paynum, $cust_pay, $batchnum ) = ( '', '', '' );
+my( $paynum, $cust_pay, $batchnum, $cust_payby ) = ( '', '', '', '' );
 if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
   $paynum = $1;
   $cust_pay = qsearchs('cust_pay', { paynum=>$paynum } )
@@ -234,6 +235,12 @@ if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
   } else {
     $custnum = $cust_pay->custnum;
   }
+  # get custpayby
+  die "Can not find payby record!"
+  unless $cust_payby = qsearchs(
+    'cust_payby', { paymask => $cust_pay->paymask, custnum => $custnum }
+  );
+
 }
 die "no custnum or paynum specified!" unless $custnum;
 
diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi
index 1f96456e0..9175eb136 100755
--- a/httemplate/edit/process/cust_refund.cgi
+++ b/httemplate/edit/process/cust_refund.cgi
@@ -55,6 +55,17 @@ if ( $error ) {
 
 my( $cust_pay, $cust_payby, $payinfo, $paycvv, $month, $year, $payname );
 my $paymask = '';
+
+## get cust pay info if paynum exists
+if ( $cgi->param('paynum') > 0) {
+  $cust_pay = qsearchs({
+    'table'     => 'cust_pay',
+    'hashref'   => { 'paynum' => $cgi->param('paynum') },
+    'select'    => 'cust_pay.*, cust_pay_batch.payname ',
+    'addl_from' => "left join cust_pay_batch on cust_pay_batch.batchnum = cust_pay.batchnum and cust_pay_batch.custnum = $custnum ",
+  });
+}
+
 if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
 
   ##
@@ -75,12 +86,6 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
 
 } elsif ( $cgi->param('paynum') > 0) {
 
-  $cust_pay = qsearchs({
-    'table'     => 'cust_pay',
-    'hashref'   => { 'paynum' => $cgi->param('paynum') },
-    'select'    => 'cust_pay.*, cust_pay_batch.payname ',
-    'addl_from' => "left join cust_pay_batch on cust_pay_batch.batchnum = cust_pay.batchnum and cust_pay_batch.custnum = $custnum ",
-  });
   $payinfo = $cust_pay->payinfo;
   $payname = $cust_pay->payname;
 
@@ -228,6 +233,15 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
       $_, scalar($cgi->param($_))
     } fields('cust_refund');
 
+    ## unapply payment before creating refund.
+    while ( $cust_pay && $cust_pay->unapplied < $refund ) {
+      my @cust_bill_pay = $cust_pay->cust_bill_pay;
+      last unless @cust_bill_pay;
+      my $cust_bill_pay = pop @cust_bill_pay;
+      my $error = $cust_bill_pay->delete;
+      last if $error;
+    }
+
     my $new = new FS::cust_refund ( { 'paynum' => $paynum,
                                       %hash,
                                   } );

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

Summary of changes:
 httemplate/edit/cust_refund.cgi         | 24 ++++++++++++++++--------
 httemplate/edit/process/cust_refund.cgi | 26 ++++++++++++++++++++------
 2 files changed, 36 insertions(+), 14 deletions(-)




More information about the freeside-commits mailing list