[freeside-commits] freeside/httemplate/misc upload-batch.cgi, 1.8, 1.9

Ivan,,, ivan at wavetail.420.am
Mon Feb 5 01:44:41 PST 2007


Update of /home/cvs/cvsroot/freeside/httemplate/misc
In directory wavetail:/tmp/cvs-serv3051/httemplate/misc

Modified Files:
	upload-batch.cgi 
Log Message:
move cust_pay_batch::upload results subroutine to an FS::pay_batch method.  upon first download, have batches auto-reset their amounts to the customer balance upon if it is smaller.

Index: upload-batch.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/upload-batch.cgi,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- upload-batch.cgi	10 Jan 2007 00:42:23 -0000	1.8
+++ upload-batch.cgi	5 Feb 2007 09:44:38 -0000	1.9
@@ -1,32 +1,37 @@
-%
-%
-%  my $fh = $cgi->upload('batch_results');
-%  $cgi->param('batchnum') =~ /^(\d+)$/;
-%  my $paybatch = $1;
-%
-%  my $error = defined($fh)
-%    ? FS::cust_pay_batch::import_results( {
-%        'filehandle' => $fh,
-%        'format'     => $cgi->param('format'),
-%        'paybatch'   => $paybatch,
-%      } )
-%    : 'No file';
-%
 %  if ( $error ) {
-%    
 
     <!-- mason kludge -->
-%
+
 %    eidiot($error);
 %#    $cgi->param('error', $error);
 %#    print $cgi->redirect( "${p}cust_main-import.cgi
 %  } else {
-%    
 
-    <!-- mason kludge -->
     <% include("/elements/header.html",'Batch results upload successful') %> 
-%
+
 %  }
-%
+<%init>
 
+my $error;
+
+my $fh = $cgi->upload('batch_results');
+$error = 'No file uploaded' unless defined($fh);
+
+unless ( $error ) {
+
+  $cgi->param('batchnum') =~ /^(\d+)$/;
+  my $batchnum = $1;
+
+  my $pay_batch = qsearchs( 'pay_batch', { 'batchnum' => $batchnum } );
+  if ( ! $pay_batch ) {
+    $error = "batchnum $batchnum not found";
+  } elsif ( $pay_batch->status ne 'I' ) {
+    $error = "batch $paybatch is not in transit";
+  } else {
+    $error = $pay_batch->import_results(
+                                         'filehandle' => $fh,
+                                         'format'     => $cgi->param('format'),
+                                       );
+  }
 
+<%/init>



More information about the freeside-commits mailing list