X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch%2FRBC.pm;h=4b11fdb893289a835f5865a769c7b8ffb8861a5e;hb=fdfa8184f05c879f3b41e13525695139d1459942;hp=daf6548da02d444eef1fab4f60f474f73085d251;hpb=20b563c398c5c9264a998d31ae0d3d95454d526e;p=freeside.git diff --git a/FS/FS/pay_batch/RBC.pm b/FS/FS/pay_batch/RBC.pm index daf6548da..4b11fdb89 100644 --- a/FS/FS/pay_batch/RBC.pm +++ b/FS/FS/pay_batch/RBC.pm @@ -14,7 +14,7 @@ $name = 'RBC'; %import_info = ( 'filetype' => 'fixed', 'formatre' => - '^(.).{18}(.{4}).{3}(.).{11}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}$', + '^(.).{18}(.{4}).{3}(.).{11}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}\r?$', 'fields' => [ qw( recordtype batchnum @@ -93,6 +93,15 @@ $name = 'RBC'; row => sub { my ($cust_pay_batch, $pay_batch) = @_; my ($account, $aba) = split('@', $cust_pay_batch->payinfo); + my($bankno, $branch); + if ( $aba =~ /^0(\d{3})(\d{5})$/ ) { # standard format for Canadian bank ID + ($bankno, $branch) = ( $1, $2 ); + } elsif ( $aba =~ /^(\d{5})\.(\d{3})$/ ) { #how we store branches + ($branch, $bankno) = ( $1, $2 ); + } else { + die "invalid branch/routing number '$aba'\n"; + } + $i++; sprintf("%06u", $i). 'D'. @@ -101,10 +110,11 @@ $name = 'RBC'; ' '. sprintf("%-19s", $cust_pay_batch->paybatchnum). '00'. - sprintf("%09u", $aba). + sprintf("%04s", $bankno). + sprintf("%05s", $branch). sprintf("%-18s", $account). ' '. - sprintf("%010u",$cust_pay_batch->amount*100). + sprintf("%010.0f",$cust_pay_batch->amount*100). ' '. time2str("%Y%j", $pay_batch->download). sprintf("%-30s", $cust_pay_batch->cust_main->first . ' ' . @@ -129,9 +139,9 @@ $name = 'RBC'; 'Z'. 'TRL'. sprintf("%10s", $client_num). - ' ' x 20 . + '0' x 20 . sprintf("%06u", $batchcount). - sprintf("%014u", $batchtotal*100). + sprintf("%014.0f", $batchtotal*100). '00' . '000000' . # total number of customer information records ' ' x 84