RT#39586 Manual check refunds cannot be unapplied
[freeside.git] / httemplate / misc / unapply-cust_credit_refund.cgi
diff --git a/httemplate/misc/unapply-cust_credit_refund.cgi b/httemplate/misc/unapply-cust_credit_refund.cgi
new file mode 100755 (executable)
index 0000000..55a81b0
--- /dev/null
@@ -0,0 +1,18 @@
+<% $cgi->redirect($p. "view/cust_main.cgi?custnum=". $custnum. ";show=payment_history") %>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Unapply credit');
+
+#untaint crednum
+my($query) = $cgi->keywords;
+$query =~ /^(\d+)$/ || die "Illegal crednum";
+my $crednum = $1;
+
+my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
+my $custnum = $cust_credit->custnum;
+
+my $error = $cust_credit->unapply_refund;
+errorpage($error) if $error;
+
+</%init>