From: ivan Date: Tue, 3 Nov 2009 20:44:04 +0000 (+0000) Subject: fix warning replacing pay_batch, RT#5650 X-Git-Tag: root_of_svc_elec_features~705 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=70253c9e1bf2287d144f0da44304190d64577300 fix warning replacing pay_batch, RT#5650 --- diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index e0531f445..c1262e097 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -393,8 +393,8 @@ sub import_results { } -sub export_batch { # Formerly httemplate/misc/download-batch.cgi +sub export_batch { my $self = shift; my $conf = new FS::Conf; my $format = shift || $conf->config('batch-default_format') @@ -402,26 +402,23 @@ sub export_batch { my $info = $export_info{$format} or die "Format not found: '$format'\n"; &{$info->{'init'}}($conf) if exists($info->{'init'}); + my $curuser = $FS::CurrentUser::CurrentUser; + my $oldAutoCommit = $FS::UID::AutoCommit; local $FS::UID::AutoCommit = 0; my $dbh = dbh; - my $error; - my $first_download; - if($self->status eq 'O') { + my $status = $self->status; + if ($status eq 'O') { $first_download = 1; - } - elsif($self->status eq 'I' and - $FS::CurrentUser::CurrentUser->access_right('Reprocess batches')) { + my $error = $self->set_status('I'); + die "error updating pay_batch status: $error\n" if $error; + } elsif ($status eq 'I' && $curuser->access_right('Reprocess batches')) { $first_download = 0; + } else { + die "No pending batch.\n"; } - else { - die "No pending batch.\n" - } - - $error = $self->set_status('I'); - die "error updating pay_batch status: $error\n" if $error; my $batch = ''; my $batchtotal = 0; @@ -440,7 +437,7 @@ sub export_batch { foreach my $cust_pay_batch (@cust_pay_batch) { if($first_download) { my $balance = $cust_pay_batch->cust_main->balance; - $error = ''; + my $error = ''; if($balance <= 0) { # then don't charge this customer $error = $cust_pay_batch->delete; undef $cust_pay_batch; @@ -470,7 +467,7 @@ sub export_batch { } if ($info->{'autopost'}) { - $error = &{$info->{'autopost'}}($self, $batch); + my $error = &{$info->{'autopost'}}($self, $batch); if($error) { $dbh->rollback or die $dbh->errstr if $oldAutoCommit; die $error;