diff options
author | ivan <ivan> | 2009-11-03 20:44:04 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-11-03 20:44:04 +0000 |
commit | 70253c9e1bf2287d144f0da44304190d64577300 (patch) | |
tree | cb313614366bf72132696b63a9227e2025aaaa91 /FS/FS/pay_batch.pm | |
parent | 95053c1edcfa416ff272a4e5afd421316410a715 (diff) |
fix warning replacing pay_batch, RT#5650
Diffstat (limited to 'FS/FS/pay_batch.pm')
-rw-r--r-- | FS/FS/pay_batch.pm | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index e0531f4..c1262e0 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; |