[freeside-commits] freeside/FS/bin freeside-eftca-upload,1.1,1.2

Ivan,,, ivan at wavetail.420.am
Fri Oct 21 16:08:17 PDT 2011


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

Modified Files:
	freeside-eftca-upload 
Log Message:
agent-virt batches and batchconfig-eftcanada config (argh!), RT#14859

Index: freeside-eftca-upload
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-eftca-upload,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- freeside-eftca-upload	22 Jul 2011 19:07:43 -0000	1.1
+++ freeside-eftca-upload	21 Oct 2011 23:08:15 -0000	1.2
@@ -38,15 +38,11 @@
 }
 
 my $conf = new FS::Conf;
-my @batchconf = $conf->config('batchconfig-eft_canada');
-my $username = $batchconf[0] or die "no EFT Canada batch username configured\n";
-my $password = $batchconf[1] or die "no EFT Canada batch password configured\n";
 
 my $tmpdir = tempdir( CLEANUP => 1 ); #DIR=>somewhere?
 
-my @filenames;
-
 foreach my $pay_batch (@batches) {
+
   my $batchnum = $pay_batch->batchnum;
   my $filename = time2str('%Y%m%d', time) . '-' . sprintf('%06d.csv',$batchnum);
   print STDERR "Exporting batch $batchnum to $filename...\n" if $opt_v;
@@ -54,27 +50,27 @@
   open OUT, ">$tmpdir/$filename";
   print OUT $text;
   close OUT;
-  push @filenames, $filename;
-}
+
+  my @batchconf = $conf->config('batchconfig-eft_canada', $pay_batch->agentnum);
+  my $user = $batchconf[0] or die "no EFT Canada batch username configured\n";
+  my $pass = $batchconf[1] or die "no EFT Canada batch password configured\n";
 
 my $host = 'ftp.eftcanada.com';
-print STDERR "Connecting to $username\@$host...\n" if $opt_v;
+  print STDERR "Connecting to $user\@$host...\n" if $opt_v;
 
 my $sftp = Net::SFTP::Foreign->new( host => $host,
-                                    user => $username,
-                                    password => $password,
+                                      user     => $user,
+                                      password => $pass,
                                     timeout => 30,
                                     );
-die "failed to connect to '$username\@$host'\n(".$sftp->error.")\n" 
+  die "failed to connect to '$user\@$host'\n(".$sftp->error.")\n" 
     if $sftp->error;
 
-foreach my $filename (@filenames) {
   $sftp->put("$tmpdir/$filename", "$filename")
     or die "failed to upload file (".$sftp->error.")\n";
-}
 
-$FS::UID::AutoCommit = 0;
-foreach my $pay_batch (@batches) {
+  undef $sftp; #$sftp->disconnect;
+
   # Auto-approve and close the batch.  Some false laziness with manual_approve.
   my $batchnum = $pay_batch->batchnum;
   my $error;
@@ -86,7 +82,6 @@
   $error ||= $pay_batch->set_status('R');
   die "error closing batch $batchnum: $error\n\n" if $error;
 }
-dbh->commit;
 
 print STDERR "Finished!\n" if $opt_v;
 



More information about the freeside-commits mailing list