diff options
| author | Ivan Kohler <ivan@freeside.biz> | 2015-10-13 10:10:40 -0700 |
|---|---|---|
| committer | Ivan Kohler <ivan@freeside.biz> | 2015-10-13 10:10:40 -0700 |
| commit | 2b2dd969f3c18751afc583ad1e836ab8e6f73b5d (patch) | |
| tree | 72ad19092f9d3a5118add9a55067b8a97c168f46 /httemplate/edit/process/cust_refund.cgi | |
| parent | d31d59c63c8f4dfd52ca19a02ffcf32fcf49f497 (diff) | |
| parent | cd468ecb9a321ca96254b7204f6dc193b11cd903 (diff) | |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/edit/process/cust_refund.cgi')
| -rwxr-xr-x | httemplate/edit/process/cust_refund.cgi | 31 |
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..6ad468b6c 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=$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> |
