summaryrefslogtreecommitdiff
path: root/httemplate/misc/process
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-07-29 20:54:53 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-07-31 21:16:21 -0500
commit1d84ced5422aff16e5f2fdebdd1d1fe4bb806016 (patch)
tree359625e844dc2e7bb3f40c3bf4172ab29c6d20a5 /httemplate/misc/process
parent6a24b8134d19a68339b927c9887f796ba7a04e0e (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/misc/process')
-rw-r--r--httemplate/misc/process/delete-cust_pay_batch.cgi37
1 files changed, 37 insertions, 0 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>