%import_info = (
'filetype' => 'fixed',
'formatre' =>
- '^(.).{18}(.{4}).{15}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}$',
+ '^(.).{18}(.{4}).{3}(.).{11}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}\r?$',
'fields' => [ qw(
recordtype
batchnum
+ subtype
paybatchnum
custname
bank
) ],
'hook' => sub {
my $hash = shift;
- $hash->{'paid'} = sprintf("%.df", $hash->{'paid'} / 100 );
+ $hash->{'paid'} = sprintf("%.2f", $hash->{'paid'} / 100 );
$hash->{'_date'} = time;
+ $hash->{'payinfo'} =~ s/^(\S+).*/$1/; # these often have trailing spaces
$hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'bank'};
},
'approved' => sub {
my $hash = shift;
grep { $hash->{'status'} eq $_ } ('E', 'R', 'U', 'T');
},
+ 'begin_condition' => sub {
+ my $hash = shift;
+ $hash->{recordtype} eq '1'; # Detail Record
+ },
'end_hook' => sub {
my( $hash, $total, $line ) = @_;
$total = sprintf("%.2f", $total);
- my $batch_total = sprintf("%.2f", substr($line, 140, 18) / 100);
+ # We assume here that this is an 'All Records' or 'Input Records'
+ # report.
+ my $batch_total = sprintf("%.2f", substr($line, 59, 18) / 100);
return "Our total $total does not match bank total $batch_total!"
if $total != $batch_total;
'';
},
'end_condition' => sub {
my $hash = shift;
- $hash->{recordtype} == '3'; # Account Trailer Record
+ $hash->{recordtype} eq '4'; # Client Trailer Record
+ },
+ 'skip_condition' => sub {
+ my $hash = shift;
+ $hash->{'subtype'} ne '0';
},
);
sprintf("%09u", $aba).
sprintf("%-18s", $account).
' '.
- sprintf("%010u",$cust_pay_batch->amount*100).
+ sprintf("%010.0f",$cust_pay_batch->amount*100).
' '.
time2str("%Y%j", $pay_batch->download).
sprintf("%-30s", $cust_pay_batch->cust_main->first . ' ' .
sprintf("%10s", $client_num).
' ' x 20 .
sprintf("%06u", $batchcount).
- sprintf("%014u", $batchtotal*100).
+ sprintf("%014.0f", $batchtotal*100).
'00' .
'000000' . # total number of customer information records
' ' x 84