diff options
author | Christopher Burger <burgerc@freeside.biz> | 2018-07-09 08:27:53 -0400 |
---|---|---|
committer | Christopher Burger <burgerc@freeside.biz> | 2018-07-09 08:27:53 -0400 |
commit | cfb19dcc27824b46d9f74a7e01b16328c8e66f7f (patch) | |
tree | 9bf2804bbbdeee4c7b729bcc021a8999566caa89 /httemplate/edit/process/cust_refund.cgi | |
parent | 6de42f2b2f6c58cf6ce0db933c2d8d5d40b411ca (diff) |
RT# 74435 - Fixed error with refund link on payment history page not allowing batch refund when batch payment was made.
Diffstat (limited to 'httemplate/edit/process/cust_refund.cgi')
-rwxr-xr-x | httemplate/edit/process/cust_refund.cgi | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi index 77da8d5d2..1f96456e0 100755 --- a/httemplate/edit/process/cust_refund.cgi +++ b/httemplate/edit/process/cust_refund.cgi @@ -53,7 +53,7 @@ if ( $error ) { 'CHEK' => 'electronic check (ACH)', ); -my( $cust_payby, $payinfo, $paycvv, $month, $year, $payname ); +my( $cust_pay, $cust_payby, $payinfo, $paycvv, $month, $year, $payname ); my $paymask = ''; if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { @@ -73,6 +73,17 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { $payname = $cust_payby->payname; $cgi->param(-name=>"paytype", -value=>$cust_payby->paytype) unless $cgi->param("paytype"); +} 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; + } else { ## @@ -194,11 +205,13 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { $cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!"; my $paynum = $1; my $paydate; - if ($cust_payby->paydate) { $paydate = "$year-$month-01"; } - else { $paydate = "2037-12-01"; } + unless ($paynum) { + if ($cust_payby->paydate) { $paydate = "$year-$month-01"; } + else { $paydate = "2037-12-01"; } + } if ( $cgi->param('batch') ) { - + $paydate = "2037-12-01" unless $paydate; $error ||= $cust_main->batch_card( 'payby' => $payby, 'amount' => $refund, @@ -211,28 +224,23 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { ); errorpage($error) if $error; -#### post refund ##### my %hash = map { $_, scalar($cgi->param($_)) } fields('cust_refund'); - $paynum = $cgi->param('paynum'); - $paynum =~ /^(\d*)$/ or die "Illegal paynum!"; - if ($paynum) { - my $cust_pay = qsearchs('cust_pay',{ 'paynum' => $paynum }); - die "Could not find paynum $paynum" unless $cust_pay; - $error = $cust_pay->refund(\%hash); - } else { - my $new = new FS::cust_refund ( \%hash ); - $error = $new->insert; - } - # if not a batch refund run realtime. + + my $new = new FS::cust_refund ( { 'paynum' => $paynum, + %hash, + } ); + $error = $new->insert; + + # if not a batch refund run realtime. } else { $error = $cust_main->realtime_refund_bop( $bop, 'amount' => $refund, 'paynum' => $paynum, 'reasonnum' => scalar($cgi->param('reasonnum')), %options ); } -} else { +} else { # run cash refund. my %hash = map { $_, scalar($cgi->param($_)) } fields('cust_refund'); |