[freeside-commits] freeside/FS/FS pay_batch.pm,1.15.2.6,1.15.2.7
Ivan,,,
ivan at wavetail.420.am
Thu Aug 19 04:55:36 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv8732
Modified Files:
Tag: FREESIDE_1_9_BRANCH
pay_batch.pm
Log Message:
fix batching protection against transactions settled in the meantime, RT#7905
Index: pay_batch.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/pay_batch.pm,v
retrieving revision 1.15.2.6
retrieving revision 1.15.2.7
diff -u -w -d -r1.15.2.6 -r1.15.2.7
--- pay_batch.pm 23 Jul 2010 23:16:19 -0000 1.15.2.6
+++ pay_batch.pm 19 Aug 2010 11:55:34 -0000 1.15.2.7
@@ -478,29 +478,34 @@
$batch .= $h . "\n";
}
foreach my $cust_pay_batch (@cust_pay_batch) {
+
if($first_download) {
my $balance = $cust_pay_batch->cust_main->balance;
- my $error = '';
if($balance <= 0) { # then don't charge this customer
- $error = $cust_pay_batch->delete;
- undef $cust_pay_batch;
+ my $error = $cust_pay_batch->delete;
+ if ( $error ) {
+ $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
+ die $error;
}
- elsif($balance < $cust_pay_batch->amount) { # then reduce the charge to the remaining balance
+ next;
+ } elsif ($balance < $cust_pay_batch->amount) {
+ # reduce the charge to the remaining balance
$cust_pay_batch->amount($balance);
- $error = $cust_pay_batch->replace;
- }
- # else $balance >= $cust_pay_batch->amount
+ my $error = $cust_pay_batch->replace;
if($error) {
$dbh->rollback or die $dbh->errstr if $oldAutoCommit;
die $error;
}
}
- if($cust_pay_batch) { # that is, it wasn't deleted
+ # else $balance >= $cust_pay_batch->amount
+ }
+
$batchcount++;
$batchtotal += $cust_pay_batch->amount;
$batch .= &{$info->{'row'}}($cust_pay_batch, $self, $batchcount, $batchtotal) . "\n";
+
}
- }
+
my $f = $info->{'footer'};
if(ref($f) eq 'CODE') {
$batch .= &$f($self, $batchcount, $batchtotal) . "\n";
More information about the freeside-commits
mailing list