#33286: Direct Debit by BillBuddy for Bank Accounts
[freeside.git] / FS / FS / pay_batch.pm
index f41b3e3..a7628f6 100644 (file)
@@ -222,17 +222,17 @@ takes precedence over I<format>.
 
 Supported format keys (defined in the specified FS::pay_batch module) are:
 
-I<filetype> - CSV, fixed, variable, XML
+I<filetype> - required, can be CSV, fixed, variable, XML
 
-I<fields> - list of field names for each row/line
+I<fields> - required list of field names for each row/line
 
 I<formatre> - regular expression for fixed filetype
 
-I<parse> - for variable filetype
+I<parse> - required for variable filetype
 
-I<xmlkeys> - for XML filetype
+I<xmlkeys> - required for XML filetype
 
-I<xmlrow> - for XML filetype
+I<xmlrow> - required for XML filetype
 
 I<begin_condition> - sub, ignore all lines before this returns true
 
@@ -242,11 +242,11 @@ I<end_hook> - sub, runs immediately after end_condition returns true
 
 I<skip_condition> - sub, skip lines when this returns true
 
-I<hook> - sub, runs before approved/declined conditions are checked
+I<hook> - required, sub, runs before approved/declined conditions are checked
 
-I<approved> - sub, returns true when approved
+I<approved> - required, sub, returns true when approved
 
-I<declined> - sub, returns true when declined
+I<declined> - required, sub, returns true when declined
 
 I<close_condition> - sub, decide whether or not to close the batch
 
@@ -558,7 +558,14 @@ sub import_from_gateway {
 
   my $processor = $gateway->batch_processor(%proc_opt);
 
-  my @batches = $processor->receive;
+  my @processor_ids = map { $_->processor_id } 
+                        qsearch({
+                          'table' => 'pay_batch',
+                          'hashref' => { 'status' => 'I' },
+                          'extra_sql' => q( AND processor_id != '' AND processor_id IS NOT NULL)
+                        });
+
+  my @batches = $processor->receive(@processor_ids);
 
   my $num = 0;
 
@@ -1044,6 +1051,11 @@ sub export_to_gateway {
   );
   $processor->submit($batch);
 
+  if ($batch->processor_id) {
+    $self->set('processor_id',$batch->processor_id);
+    $self->replace;
+  }
+
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
   '';
 }