projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
90c18c7
)
Fix problems with RBC batch import (RT#6967)
author
mark
<mark>
Thu, 7 Jan 2010 09:48:51 +0000
(09:48 +0000)
committer
mark
<mark>
Thu, 7 Jan 2010 09:48:51 +0000
(09:48 +0000)
FS/FS/pay_batch.pm
patch
|
blob
|
history
FS/FS/pay_batch/RBC.pm
patch
|
blob
|
history
diff --git
a/FS/FS/pay_batch.pm
b/FS/FS/pay_batch.pm
index
c1262e0
..
59ff2c3
100644
(file)
--- a/
FS/FS/pay_batch.pm
+++ b/
FS/FS/pay_batch.pm
@@
-202,6
+202,7
@@
sub import_results {
my $begin_condition = $info->{'begin_condition'};
my $end_condition = $info->{'end_condition'};
my $end_hook = $info->{'end_hook'};
my $begin_condition = $info->{'begin_condition'};
my $end_condition = $info->{'end_condition'};
my $end_hook = $info->{'end_hook'};
+ my $skip_condition = $info->{'skip_condition'};
my $hook = $info->{'hook'};
my $approved_condition = $info->{'approved'};
my $declined_condition = $info->{'declined'};
my $hook = $info->{'hook'};
my $approved_condition = $info->{'approved'};
my $declined_condition = $info->{'declined'};
@@
-295,8
+296,13
@@
sub import_results {
$hash{$field} = $value;
}
$hash{$field} = $value;
}
- if ( defined($begin_condition) and &{$begin_condition}(\%hash, $line)) {
- undef $begin_condition;
+ if ( defined($begin_condition) ) {
+ if ( &{$begin_condition}(\%hash, $line) ) {
+ undef $begin_condition;
+ }
+ else {
+ next;
+ }
}
if ( defined($end_condition) and &{$end_condition}(\%hash, $line) ) {
}
if ( defined($end_condition) and &{$end_condition}(\%hash, $line) ) {
@@
-309,6
+315,10
@@
sub import_results {
last;
}
last;
}
+ if ( defined($skip_condition) and &{$skip_condition}(\%hash, $line) ) {
+ next;
+ }
+
my $cust_pay_batch =
qsearchs('cust_pay_batch', { 'paybatchnum' => $hash{'paybatchnum'}+0 } );
unless ( $cust_pay_batch ) {
my $cust_pay_batch =
qsearchs('cust_pay_batch', { 'paybatchnum' => $hash{'paybatchnum'}+0 } );
unless ( $cust_pay_batch ) {
@@
-455,7
+465,7
@@
sub export_batch {
if($cust_pay_batch) { # that is, it wasn't deleted
$batchcount++;
$batchtotal += $cust_pay_batch->amount;
if($cust_pay_batch) { # that is, it wasn't deleted
$batchcount++;
$batchtotal += $cust_pay_batch->amount;
- $batch .= &{$info->{'row'}}($cust_pay_batch, $self) . "\n";
+ $batch .= &{$info->{'row'}}($cust_pay_batch, $self
, $batchcount, $batchtotal
) . "\n";
}
}
my $f = $info->{'footer'};
}
}
my $f = $info->{'footer'};
diff --git
a/FS/FS/pay_batch/RBC.pm
b/FS/FS/pay_batch/RBC.pm
index
33a725e
..
daf6548
100644
(file)
--- a/
FS/FS/pay_batch/RBC.pm
+++ b/
FS/FS/pay_batch/RBC.pm
@@
-14,10
+14,11
@@
$name = 'RBC';
%import_info = (
'filetype' => 'fixed',
'formatre' =>
%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}$',
'fields' => [ qw(
recordtype
batchnum
'fields' => [ qw(
recordtype
batchnum
+ subtype
paybatchnum
custname
bank
paybatchnum
custname
bank
@@
-27,8
+28,9
@@
$name = 'RBC';
) ],
'hook' => sub {
my $hash = shift;
) ],
'hook' => sub {
my $hash = shift;
- $hash->{'paid'} = sprintf("%.
d
f", $hash->{'paid'} / 100 );
+ $hash->{'paid'} = sprintf("%.
2
f", $hash->{'paid'} / 100 );
$hash->{'_date'} = time;
$hash->{'_date'} = time;
+ $hash->{'payinfo'} =~ s/^(\S+).*/$1/; # these often have trailing spaces
$hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'bank'};
},
'approved' => sub {
$hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'bank'};
},
'approved' => sub {
@@
-39,17
+41,27
@@
$name = 'RBC';
my $hash = shift;
grep { $hash->{'status'} eq $_ } ('E', 'R', 'U', 'T');
},
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);
'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;
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';
},
);
},
);