X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch%2FRBC.pm;h=f86eb37ba32ee20873eea020c502f8d9cd9f000b;hb=76c0399b07a8bc7d5642eeafa75b4862033bd7b5;hp=a5c468367a16403326e6515fd174bb5b8129a0cc;hpb=8dd41f364aaba88969dfd0908feb22709025e7f6;p=freeside.git diff --git a/FS/FS/pay_batch/RBC.pm b/FS/FS/pay_batch/RBC.pm index a5c468367..f86eb37ba 100644 --- a/FS/FS/pay_batch/RBC.pm +++ b/FS/FS/pay_batch/RBC.pm @@ -11,10 +11,24 @@ my ($client_num, $shortname, $longname, $trans_code, $i); $name = 'RBC'; # Royal Bank of Canada ACH Direct Payments Service +# Meaning of initial characters in records: +# 0 - header row, skipped by begin_condition +# 1 - Debit Detail Record (only when subtype is 0) +# 2 - Credit Detail Record, we die with a parse error (shouldn't appear in freeside-generated batches) +# 3 - Account Trailer Record (appears after Returned items, we skip) +# 4 - Client Trailer Record, indicates end of batch in end_condition +# +# Subtypes (27th char) indicate different kinds of Debit/Credit records +# 0 - Credit/Debit Detail Record +# 3 - Error Message Record +# 4 - Foreign Currency Information Records +# We skip all subtypes except 0 +# +# additional information available at https://www.rbcroyalbank.com/ach/file-451806.pdf %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 +75,8 @@ $name = 'RBC'; }, 'skip_condition' => sub { my $hash = shift; - $hash->{'subtype'} ne '0'; + $hash->{'recordtype'} eq '3' || + $hash->{'subtype'} ne '0'; }, ); @@ -108,7 +123,7 @@ $name = 'RBC'; sprintf("%3s",$trans_code). sprintf("%10s",$client_num). ' '. - sprintf("%-19s", $cust_pay_batch->cust_main->custnum). + sprintf("%-19s", $cust_pay_batch->paybatchnum). '00'. sprintf("%04s", $bankno). sprintf("%05s", $branch).