diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-07-29 20:54:53 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-07-29 20:54:53 -0500 |
commit | 6821ffc8988f64ddeefe1219b32d00cc57c4ccde (patch) | |
tree | 4b8df87970b15cda83b2bb27da45d3f77b0d96c3 /httemplate | |
parent | ee10b43452faa00be4ce3b06cac7596655fa5988 (diff) |
RT#35100: how to void a payment in the cust_pay_batch before file has been uploaded to the bank
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/misc/process/delete-cust_pay_batch.cgi | 37 | ||||
-rwxr-xr-x | httemplate/search/cust_pay_batch.cgi | 34 |
2 files changed, 70 insertions, 1 deletions
diff --git a/httemplate/misc/process/delete-cust_pay_batch.cgi b/httemplate/misc/process/delete-cust_pay_batch.cgi new file mode 100644 index 000000000..4937b58e2 --- /dev/null +++ b/httemplate/misc/process/delete-cust_pay_batch.cgi @@ -0,0 +1,37 @@ +<% $server->process %> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Process batches') + || $curuser->access_right('Process global batches'); + +# look up paybatch using agentnums_sql & status constraints +# to validate access for this particular cust_pay_batch, +# similar to how it's done in cust_pay_batch.cgi + +my %arg = $cgi->param('arg'); +my $paybatchnum = $arg{'paybatchnum'}; +$paybatchnum =~ /^\d+$/ or die "Illegal paybatchnum"; +my @search = (); +push @search, 'cust_pay_batch.paybatchnum = ' . $paybatchnum; +push @search, '(cust_pay_batch.status = \'\' OR cust_pay_batch.status IS NULL)'; +push @search, 'pay_batch.status = \'O\''; +push @search, $curuser->agentnums_sql({ table => 'cust_main' }); +push @search, $curuser->agentnums_sql({ table => 'pay_batch', + null_right => 'Process global batches', + }); +my $search = ' WHERE ' . join(' AND ', @search); +die "permission denied" unless qsearchs({ + 'table' => 'cust_pay_batch', + 'hashref' => {}, + 'addl_from' => 'LEFT JOIN pay_batch USING ( batchnum ) '. + 'LEFT JOIN cust_main USING ( custnum ) '. + 'LEFT JOIN cust_pay USING ( batchnum, custnum ) ', + 'extra_sql' => $search +}); + +my $server = new FS::UI::Web::JSRPC 'FS::cust_pay_batch::process_unbatch_and_delete', $cgi; + +</%init> diff --git a/httemplate/search/cust_pay_batch.cgi b/httemplate/search/cust_pay_batch.cgi index c0f84ec87..cc958b96d 100755 --- a/httemplate/search/cust_pay_batch.cgi +++ b/httemplate/search/cust_pay_batch.cgi @@ -14,6 +14,7 @@ 'Exp', 'Amount', 'Status', + '', # delete link '', # error_message ], 'fields' => [ 'paybatchnum', @@ -31,9 +32,10 @@ sprintf('%.02f', $_[0]->amount) }, sub { $_[0]->display_status }, + $sub_unbatch, 'error_message', ], - 'align' => 'rrrlllcrlll', + 'align' => 'rrrlllcrllll', 'links' => [ '', ["${p}view/cust_bill.cgi?", 'invnum'], (["${p}view/cust_main.cgi?", 'custnum']) x 2, @@ -129,6 +131,36 @@ my $sub_receipt = sub { ); }; +my $sub_unbatch = ''; +if ( ($pay_batch && ($pay_batch->status eq 'O')) + && ( $curuser->access_right('Process batches') + || $curuser->access_right('Process global batches') ) +) { + $sub_unbatch = sub { + my $self = shift; + return '' if $self->status; # sanity check, shouldn't happen + my $batchnum = $self->batchnum; + my $paybatchnum = $self->paybatchnum; + my $out = <<EOF; +<FORM name="delete_cust_pay_batch_$paybatchnum"> +<INPUT TYPE="hidden" name="paybatchnum" value="$paybatchnum"> +</FORM> +EOF + $out .= include('/elements/progress-init.html', + "delete_cust_pay_batch_$paybatchnum", + [ 'paybatchnum' ], + $p.'misc/process/delete-cust_pay_batch.cgi', + $p.'search/cust_pay_batch.cgi?' . $cgi->query_string, + "paybatchnum$paybatchnum", + ); + my $onclick = 'if ( confirm(\''; + $onclick .= emt('Are you sure you want to delete batch payment ') . $self->paybatchnum; + $onclick .= emt(' from payment batch ') . $self->batchnum; + $onclick .= '\') ) { paybatchnum' . $paybatchnum . 'process() }'; + return $out . '<A HREF="javascript:void(0)" ONCLICK="' . $onclick . '">delete</A>'; + }; +} + my $html_init = ''; if ( $pay_batch ) { $html_init = include('elements/cust_pay_batch_top.html', |