[freeside-commits] freeside/FS/FS pay_batch.pm,1.21,1.22

Ivan,,, ivan at wavetail.420.am
Thu Aug 19 04:55:35 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv8723

Modified Files:
	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.21
retrieving revision 1.22
diff -u -w -d -r1.21 -r1.22
--- pay_batch.pm	23 Jul 2010 23:16:18 -0000	1.21
+++ pay_batch.pm	19 Aug 2010 11:55:33 -0000	1.22
@@ -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