summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/cust_refund.cgi
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-08-28 00:56:49 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-08-29 17:23:58 -0500
commit8508117a6127dc363736da08be6e71cb7aefc9d3 (patch)
tree1cf9cbad185a4a6485e9706a69dec841f68440f3 /httemplate/edit/process/cust_refund.cgi
parent225f922a9b48c5179b3fd9b28d9eb442d7e8598d (diff)
RT#37064: Add action link to manually refund a payment
Diffstat (limited to 'httemplate/edit/process/cust_refund.cgi')
-rwxr-xr-xhttemplate/edit/process/cust_refund.cgi31
1 files changed, 15 insertions, 16 deletions
diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi
index 52fede8ec..ce72c9253 100755
--- a/httemplate/edit/process/cust_refund.cgi
+++ b/httemplate/edit/process/cust_refund.cgi
@@ -12,7 +12,7 @@
</BODY></HTML>
% } else {
-<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %>
+<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum;show=payment_history") %>
% }
%}
<%init>
@@ -30,16 +30,8 @@ my $link = $cgi->param('popup') ? 'popup' : '';
my $payby = $cgi->param('payby');
-my @rights = ();
-push @rights, 'Post refund' if $payby =~ /^(BILL|CASH|MCRD|MCHK)$/;
-push @rights, 'Post check refund' if $payby eq 'BILL';
-push @rights, 'Post cash refund ' if $payby eq 'CASH';
-push @rights, 'Refund payment' if $payby =~ /^(CARD|CHEK)$/;
-push @rights, 'Refund credit card payment' if $payby eq 'CARD';
-push @rights, 'Refund Echeck payment' if $payby eq 'CHEK';
-
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
+ unless $FS::CurrentUser::CurrentUser->refund_access_right($payby);
$cgi->param('reasonnum') =~ /^(-?\d+)$/ or die "Illegal reasonnum";
my ($reasonnum, $error) = $m->comp('/misc/process/elements/reason');
@@ -63,12 +55,19 @@ if ( $error ) {
'reason' => $reason,
%options );
} else {
- my $new = new FS::cust_refund ( {
- map {
- $_, scalar($cgi->param($_));
- } fields('cust_refund') #huh? , 'paynum' )
- } );
- $error = $new->insert;
+ my %hash = map {
+ $_, scalar($cgi->param($_))
+ } fields('cust_refund');
+ my $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;
+ }
}
</%init>