X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch%2FRBC.pm;h=a9b670dccaf66a5f3886eddc565f8f79c355f7ee;hb=1fc0d74aab287141c02c74978b0e95b44ff8e319;hp=6ee5771fec9dfea317a49481306535a7180d9cf4;hpb=91e7650c03c9194ee2fee6334699203f31efa7ce;p=freeside.git diff --git a/FS/FS/pay_batch/RBC.pm b/FS/FS/pay_batch/RBC.pm index 6ee5771fe..a9b670dcc 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}\r?$', + '^([0134]).{18}(.{4}).{3}(.).{11}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}\r?$', 'fields' => [ qw( recordtype batchnum @@ -61,7 +61,8 @@ $name = 'RBC'; }, 'skip_condition' => sub { my $hash = shift; - $hash->{'subtype'} ne '0'; + $hash->{'recordtype'} eq '3' || + $hash->{'subtype'} ne '0'; }, ); @@ -93,6 +94,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,7 +111,8 @@ $name = 'RBC'; ' '. sprintf("%-19s", $cust_pay_batch->paybatchnum). '00'. - sprintf("%09u", $aba). + sprintf("%04s", $bankno). + sprintf("%05s", $branch). sprintf("%-18s", $account). ' '. sprintf("%010.0f",$cust_pay_batch->amount*100). @@ -129,7 +140,7 @@ $name = 'RBC'; 'Z'. 'TRL'. sprintf("%10s", $client_num). - ' ' x 20 . + '0' x 20 . sprintf("%06u", $batchcount). sprintf("%014.0f", $batchtotal*100). '00' .