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}).{3}(.).{11}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}\r?$',
31 $hash->{'paid'} = sprintf("%.2f", $hash->{'paid'} / 100 );
32 $hash->{'_date'} = time;
33 $hash->{'payinfo'} =~ s/^(\S+).*/$1/; # these often have trailing spaces
34 $hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'bank'};
38 $hash->{'status'} eq ' '
42 grep { $hash->{'status'} eq $_ } ('E', 'R', 'U', 'T');
44 'begin_condition' => sub {
46 $hash->{recordtype} eq '1'; # Detail Record
49 my( $hash, $total, $line ) = @_;
50 $total = sprintf("%.2f", $total);
51 # We assume here that this is an 'All Records' or 'Input Records'
53 my $batch_total = sprintf("%.2f", substr($line, 59, 18) / 100);
54 return "Our total $total does not match bank total $batch_total!"
55 if $total != $batch_total;
58 'end_condition' => sub {
60 $hash->{recordtype} eq '4'; # Client Trailer Record
62 'skip_condition' => sub {
64 $hash->{'subtype'} ne '0';
75 ) = $conf->config("batchconfig-RBC");
79 my $pay_batch = shift;
80 '$$AAPASTD0152[PROD[NL$$'."\n".
84 sprintf("%10s", $client_num).
85 sprintf("%-30s", $longname).
86 sprintf("%04u", $pay_batch->batchnum).
87 time2str("%Y%j", $pay_batch->download).
90 ' ' x 87 # filler/reserved fields
94 my ($cust_pay_batch, $pay_batch) = @_;
95 my ($account, $aba) = split('@', $cust_pay_batch->payinfo);
99 sprintf("%3s",$trans_code).
100 sprintf("%10s",$client_num).
102 sprintf("%-19s", $cust_pay_batch->paybatchnum).
104 sprintf("%09u", $aba).
105 sprintf("%-18s", $account).
107 sprintf("%010.0f",$cust_pay_batch->amount*100).
109 time2str("%Y%j", $pay_batch->download).
110 sprintf("%-30s", $cust_pay_batch->cust_main->first . ' ' .
111 $cust_pay_batch->cust_main->last).
114 sprintf("%-15s", $shortname).
119 'N' # no customer optional information follows
121 # Note: IAT Address Information and Remittance records are not
122 # supported. This means you probably can't process payments
123 # destined to U.S. bank accounts. If you need this feature, contact
124 # Freeside Internet Services.
127 my ($pay_batch, $batchcount, $batchtotal) = @_;
128 sprintf("%06u", $i + 1).
131 sprintf("%10s", $client_num).
133 sprintf("%06u", $batchcount).
134 sprintf("%014.0f", $batchtotal*100).
136 '000000' . # total number of customer information records