summaryrefslogtreecommitdiff
path: root/httemplate/misc/download-batch.cgi
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2018-10-01 12:03:01 -0700
committerIvan Kohler <ivan@freeside.biz>2018-10-01 12:03:01 -0700
commitd5988a9f7a3617de33da3058f2e9f1151b24420e (patch)
tree3ed8d80cd6a81f160c76c90fcf089e81fe7ffddf /httemplate/misc/download-batch.cgi
parent1ab515df162a76347d8146cae4ff34656cc4bcd3 (diff)
parentb6088672c87e2c5984183326b4c0e2d9bd6c34f6 (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/misc/download-batch.cgi')
-rw-r--r--httemplate/misc/download-batch.cgi11
1 files changed, 10 insertions, 1 deletions
diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi
index c4bc37e93..c6a0b68c3 100644
--- a/httemplate/misc/download-batch.cgi
+++ b/httemplate/misc/download-batch.cgi
@@ -20,9 +20,18 @@ 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');
+}
+
my $exporttext = $pay_batch->export_batch(%opt);
unless ($exporttext) {
http_header('Content-Type' => 'text/html' );