1 package FS::pay_batch::td_eft1464;
4 use vars qw(@ISA %import_info %export_info $name);
5 use Date::Format 'time2str';
7 use FS::Record qw(qsearch);
11 td_eft1464 - TD Commercial Banking EFT1464 format
15 The Freeside option 'batchconfig-td_eft1464' must be set
16 with the following values on separate lines:
22 =item TD Datacenter Location
35 =item Returned Payment Branch (5 digits)
37 =item Returned Payment Account
39 =item Transaction Type Code - defaults to "437" (Internet access)
50 # TD Bank EFT 1464 Byte format
52 %import_info = ( filetype => 'NONE' );
53 # just to suppress warning; importing this format is a fatal error
67 } = $conf->config("batchconfig-td_eft1464");
68 $opt{'origid'} = sprintf('%-10.10s', $opt{'origid'});
69 $opt{'shortname'} = sprintf('%-15.15s', $opt{'shortname'});
70 $opt{'longname'} = sprintf('%-30.30s', $opt{'longname'});
71 $opt{'retbranch'} = '0004'.sprintf('%5.5s',$opt{'retbranch'});
72 $opt{'retacct'} = sprintf('%-11.11s', $opt{'retacct'}). ' ';
76 my $pay_batch = shift;
77 my @cust_pay_batch = @{(shift)};
78 my $time = $pay_batch->download || time;
79 my $now = sprintf("%03u%03u",
80 (localtime(time))[5] % 100,#year since 1900
81 (localtime(time))[7]+1);#day of year
83 # Request settlement the next day
84 my $duedate = time+86400;
85 $opt{'due'} = sprintf("%03u%03u",
86 (localtime($duedate))[5] % 100,
87 (localtime($duedate))[7]+1);
90 sprintf('%04u', ($pay_batch->batchnum % 9999)+1), # file creation number
93 sprintf('%09u', 1), #record number
102 my ($cust_pay_batch, $pay_batch) = @_;
103 my ($account, $aba) = split('@', $cust_pay_batch->payinfo);
105 # The 1464 byte format supports up to 5 payments per line,
106 # but we're only going to send 1.
107 my $control = join('',
109 sprintf("%09u", $i), #record number
113 my $payment = join('',
114 $opt{'cpacode'} || 437, # CPA code, defaults to "Internet access"
115 sprintf('%010.0f', $cust_pay_batch->amount*100),
116 $opt{'due'}, #due date...? XXX
117 sprintf('%09u', $aba),
118 sprintf('%-12.12s', $account),
124 $cust_pay_batch->first, $cust_pay_batch->last)
128 sprintf('%-19.19s', $cust_pay_batch->paybatchnum), # originator reference num
136 return sprintf('%-1464s',$control . $payment) ;
139 my ($pay_batch, $batchcount, $batchtotal) = @_;
142 sprintf('%09u', $batchcount + 2),
145 sprintf('%014.0f', $batchtotal*100), # total of debit txns
146 sprintf('%08u', $batchcount), # number of debit txns
147 '0' x 14, # total of credit txns
148 '0' x 8, # total of credit txns