},
);
+## this format can handle credit transactions
+sub can_handle_credits {
+ 1;
+}
+
1;
<BR>Refund
-
<% ntable("#cccccc", 2) %>
<TR>
}
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);
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 } )
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;
$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>