[freeside-commits] freeside/FS/FS pay_batch.pm,1.16,1.17
Ivan,,,
ivan at wavetail.420.am
Tue Nov 3 12:44:07 PST 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv15738
Modified Files:
pay_batch.pm
Log Message:
fix warning replacing pay_batch, RT#5650
Index: pay_batch.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/pay_batch.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- pay_batch.pm 24 Oct 2009 23:37:41 -0000 1.16
+++ pay_batch.pm 3 Nov 2009 20:44:04 -0000 1.17
@@ -393,8 +393,8 @@
}
-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,27 +402,24 @@
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;
my $batchcount = 0;
@@ -440,7 +437,7 @@
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 @@
}
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;
More information about the freeside-commits
mailing list