1 package FS::pay_batch::RBC;
4 use vars qw(@ISA %import_info %export_info $name);
5 use Date::Format 'time2str';
9 my ($client_num, $shortname, $longname, $trans_code, $i);
12 # Royal Bank of Canada ACH Direct Payments Service
15 'filetype' => 'fixed',
17 '^(.).{18}(.{4}).{15}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}$',
30 $hash->{'paid'} = sprintf("%.df", $hash->{'paid'} / 100 );
31 $hash->{'_date'} = time;
32 $hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'bank'};
36 $hash->{'status'} eq ' '
40 grep { $hash->{'status'} eq $_ } ('E', 'R', 'U', 'T');
43 my( $hash, $total, $line ) = @_;
44 $total = sprintf("%.2f", $total);
45 my $batch_total = sprintf("%.2f", substr($line, 140, 18) / 100);
46 return "Our total $total does not match bank total $batch_total!"
47 if $total != $batch_total;
50 'end_condition' => sub {
52 $hash->{recordtype} == '3'; # Account Trailer Record
63 ) = $conf->config("batchconfig-RBC");
67 my $pay_batch = shift;
68 '$$AAPASTD0152[PROD[NL$$'."\n".
72 sprintf("%10s", $client_num).
73 sprintf("%-30s", $longname).
74 sprintf("%04u", $pay_batch->batchnum).
75 time2str("%Y%j", $pay_batch->download).
78 ' ' x 87 # filler/reserved fields
82 my ($cust_pay_batch, $pay_batch) = @_;
83 my ($account, $aba) = split('@', $cust_pay_batch->payinfo);
87 sprintf("%3s",$trans_code).
88 sprintf("%10s",$client_num).
90 sprintf("%-19s", $cust_pay_batch->paybatchnum).
92 sprintf("%09u", $aba).
93 sprintf("%-18s", $account).
95 sprintf("%010u",$cust_pay_batch->amount*100).
97 time2str("%Y%j", $pay_batch->download).
98 sprintf("%-30s", $cust_pay_batch->cust_main->first . ' ' .
99 $cust_pay_batch->cust_main->last).
102 sprintf("%-15s", $shortname).
107 'N' # no customer optional information follows
109 # Note: IAT Address Information and Remittance records are not
110 # supported. This means you probably can't process payments
111 # destined to U.S. bank accounts. If you need this feature, contact
112 # Freeside Internet Services.
115 my ($pay_batch, $batchcount, $batchtotal) = @_;
116 sprintf("%06u", $i + 1).
119 sprintf("%10s", $client_num).
121 sprintf("%06u", $batchcount).
122 sprintf("%014u", $batchtotal*100).
124 '000000' . # total number of customer information records