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;
71 sprintf("%10s", $client_num).
72 sprintf("%-30s", $longname).
73 sprintf("%04u", $pay_batch->batchnum).
74 time2str("%Y%j", $pay_batch->download).
77 ' ' x 87 # filler/reserved fields
81 my ($cust_pay_batch, $pay_batch) = @_;
82 my ($account, $aba) = split('@', $cust_pay_batch->payinfo);
86 sprintf("%3s",$trans_code).
87 sprintf("%10s",$client_num).
89 sprintf("%-19s", $cust_pay_batch->paybatchnum).
91 sprintf("%09u", $aba).
92 sprintf("%-18s", $account).
94 sprintf("%010u",$cust_pay_batch->amount*100).
96 time2str("%Y%j", $pay_batch->download).
97 sprintf("%-30s", $cust_pay_batch->cust_main->first . ' ' .
98 $cust_pay_batch->cust_main->last).
101 sprintf("%-15s", $shortname).
106 'N' # no customer optional information follows
108 # Note: IAT Address Information and Remittance records are not
109 # supported. This means you probably can't process payments
110 # destined to U.S. bank accounts. If you need this feature, contact
111 # Freeside Internet Services.
114 my ($pay_batch, $batchcount, $batchtotal) = @_;
115 sprintf("%06u", $i + 1).
118 sprintf("%10s", $client_num).
120 sprintf("%06u", $batchcount).
121 sprintf("%014u", $batchtotal*100).
123 '000000' . # total number of customer information records