summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2018-07-16 14:40:39 -0400
committerChristopher Burger <burgerc@freeside.biz>2018-07-16 15:02:49 -0400
commita439c0c5998c428e7bfd533353911ae48b4bee7b (patch)
treeb1fd64c1bcf589dbae9f8659892191f2033e458c
parenta90d069b1f1d814a91bf7cb3eb0d7ac9fdec7e08 (diff)
RT# 74435 - added check, to make sure batch format can handle refunds
Conflicts: httemplate/misc/download-batch.cgi
-rw-r--r--FS/FS/pay_batch/RBC.pm5
-rwxr-xr-xhttemplate/edit/cust_refund.cgi4
-rwxr-xr-xhttemplate/edit/process/cust_refund.cgi7
-rw-r--r--httemplate/misc/download-batch.cgi11
4 files changed, 15 insertions, 12 deletions
diff --git a/FS/FS/pay_batch/RBC.pm b/FS/FS/pay_batch/RBC.pm
index 05ee4e501..c4388d156 100644
--- a/FS/FS/pay_batch/RBC.pm
+++ b/FS/FS/pay_batch/RBC.pm
@@ -230,5 +230,10 @@ $name = 'RBC';
},
);
+## this format can handle credit transactions
+sub can_handle_credits {
+ 1;
+}
+
1;
diff --git a/httemplate/edit/cust_refund.cgi b/httemplate/edit/cust_refund.cgi
index 55f06642b..c79c39a80 100755
--- a/httemplate/edit/cust_refund.cgi
+++ b/httemplate/edit/cust_refund.cgi
@@ -85,7 +85,6 @@
<BR>Refund
-
<% ntable("#cccccc", 2) %>
<TR>
@@ -176,9 +175,6 @@ if ( $cgi->param('paynum') =~ /^(\d+)$/ ) {
}
die "no custnum or paynum specified!" unless $custnum;
-my $cust_main = qsearchs( 'cust_main', { 'custnum'=>$custnum } );
-die "unknown custnum $custnum" unless $cust_main;
-
my $_date = time;
my $p1 = popurl(1);
diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi
index 49aedf3fe..44605bf42 100755
--- a/httemplate/edit/process/cust_refund.cgi
+++ b/httemplate/edit/process/cust_refund.cgi
@@ -21,8 +21,6 @@ die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Refund payment')
|| $FS::CurrentUser::CurrentUser->access_right('Post refund');
-my $conf = new FS::Conf;
-
$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!";
my $custnum = $1;
my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
@@ -62,12 +60,7 @@ if ( $error ) {
my $refund = "$1$2";
$cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!";
my $paynum = $1;
- #my $paydate;
my $paydate = $cgi->param('exp_year'). '-'. $cgi->param('exp_month'). '-01';
- #unless ($paynum) {
- # if ($cust_payby->paydate) { $paydate = "$year-$month-01"; }
- # else { $paydate = "2037-12-01"; }
- #}
if ( $cgi->param('batch') ) {
$paydate = "2037-12-01" unless $paydate;
diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi
index f3a31eb3b..7b56f2aa1 100644
--- a/httemplate/misc/download-batch.cgi
+++ b/httemplate/misc/download-batch.cgi
@@ -20,7 +20,16 @@ elsif ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) {
$opt{'format'} = $1;
}
-my $pay_batch = qsearchs('pay_batch', { batchnum => $batchnum } );
+my $credit_transactions = "EXISTS (SELECT 1 FROM cust_pay_batch WHERE batchnum = $batchnum AND paycode = 'C') AS arecredits";
+my $pay_batch = qsearchs({ 'select' => "*, $credit_transactions",
+ 'table' => 'pay_batch',
+ 'hashref' => { batchnum => $batchnum },
+ });
die "Batch not found: '$batchnum'" if !$pay_batch;
+if ($pay_batch->{Hash}->{arecredits}) {
+ my $export_format = "FS::pay_batch::".$opt{'format'};
+ die "This format can not handle refunds." unless $export_format->can('can_handle_credits');
+}
+
</%init>