fix td_eft1464 echeck batch format for modern style Canadian separate branch number...
[freeside.git] / FS / FS / pay_batch / td_eft1464.pm
index 7f58ab5..3a6befe 100644 (file)
@@ -53,6 +53,7 @@ $name = 'td_eft1464';
 # just to suppress warning; importing this format is a fatal error
 
 %export_info = (
+  delimiter => '',
   init => sub {
     $conf = shift;
     @opt{
@@ -64,11 +65,11 @@ $name = 'td_eft1464';
       'retacct',
       'cpacode',
     } = $conf->config("batchconfig-td_eft1464");
-    $opt{'origid'} = sprintf('%-10s', $opt{'origid'});
-    $opt{'shortname'} = sprintf('%-15s', $opt{'shortname'});
-    $opt{'longname'} = sprintf('%-30s', $opt{'longname'});
-    $opt{'retbranch'} = '0004'.sprintf('%5s',$opt{'retbranch'});
-    $opt{'retacct'} = sprintf('%-11s', $opt{'retacct'}). ' ';
+    $opt{'origid'} = sprintf('%-10.10s', $opt{'origid'});
+    $opt{'shortname'} = sprintf('%-15.15s', $opt{'shortname'});
+    $opt{'longname'} = sprintf('%-30.30s', $opt{'longname'});
+    $opt{'retbranch'} = '0004'.sprintf('%5.5s',$opt{'retbranch'});
+    $opt{'retacct'} = sprintf('%-11.11s', $opt{'retacct'}). ' ';
     $i = 1;
   },
   header => sub { 
@@ -95,12 +96,14 @@ $name = 'td_eft1464';
       $now,
       $opt{'datacenter'},
       ' ' x 1429, #filler
-      "\r"
     );
   },
   row => sub {
     my ($cust_pay_batch, $pay_batch) = @_;
     my ($account, $aba) = split('@', $cust_pay_batch->payinfo);
+    if ( $aba =~ /^(\d+)\.(\d+)$/ ) {  #branch.route
+      $aba = $2.$1; #routebranch
+    }
     $i++;
     # The 1464 byte format supports up to 5 payments per line,
     # but we're only going to send 1.
@@ -115,17 +118,17 @@ $name = 'td_eft1464';
       sprintf('%010.0f', $cust_pay_batch->amount*100),
       $opt{'due'}, #due date...? XXX
       sprintf('%09u', $aba),
-      sprintf('%-12s', $account),
-      ' ' x 22,
+      sprintf('%-12.12s', $account),
+      '0' x 22,
       '0' x 3,
       $opt{'shortname'},
-      sprintf('%-30s', 
+      sprintf('%-30.30s', 
         join(' ',
           $cust_pay_batch->first, $cust_pay_batch->last)
       ),
       $opt{'longname'},
       $opt{'origid'},
-      sprintf('%-19s', $cust_pay_batch->paybatchnum), # originator reference num
+      sprintf('%-19.19s', $cust_pay_batch->paybatchnum), # originator reference num
       $opt{'retbranch'},
       $opt{'retacct'}, 
       ' ' x 15,
@@ -133,7 +136,7 @@ $name = 'td_eft1464';
       ' ' x 2,
       '0' x 11,
     );
-    return sprintf('%-1464s',$control . $payment) . "\r";
+    return sprintf('%-1464s',$control . $payment) ;
   },
   footer => sub {
     my ($pay_batch, $batchcount, $batchtotal) = @_;
@@ -147,7 +150,6 @@ $name = 'td_eft1464';
       '0' x 14, # total of credit txns
       '0' x 8, # total of credit txns
       ' ' x 1396,
-      "\r"
     )
   },
 );