projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
04980f3
)
parse last line from TD Canada Trust
author
ivan
<ivan>
Thu, 9 Oct 2003 17:40:02 +0000
(17:40 +0000)
committer
ivan
<ivan>
Thu, 9 Oct 2003 17:40:02 +0000
(17:40 +0000)
FS/FS/cust_pay_batch.pm
patch
|
blob
|
history
diff --git
a/FS/FS/cust_pay_batch.pm
b/FS/FS/cust_pay_batch.pm
index
97c1681
..
f53e55b
100644
(file)
--- a/
FS/FS/cust_pay_batch.pm
+++ b/
FS/FS/cust_pay_batch.pm
@@
-210,6
+210,8
@@
sub import_results {
my $paybatch = $param->{'paybatch'};
my @fields;
my $paybatch = $param->{'paybatch'};
my @fields;
+ my $end_condition;
+ my $end_hook;
my $condition;
my $hook;
my $condition;
my $hook;
@@
-236,9
+238,23
@@
sub import_results {
'', # Terminal ID: Terminal ID used to process the transaction
);
'', # Terminal ID: Terminal ID used to process the transaction
);
+ $end_condition = sub {
+ my $hash = shift;
+ $hash->{'type'} eq '0BC';
+ };
+
+ $end_hook = sub {
+ my( $hash, $total) = @_;
+ $total = sprintf("%.2f", $total);
+ my $batch_total = sprintf("%.2f", $hash->{'paybatchnum'} / 100 );
+ return "Our total $total does not match bank total $batch_total!"
+ if $total != $batch_total;
+ '';
+ };
+
$condition = sub {
my $hash = shift;
$condition = sub {
my $hash = shift;
- $hash->{'result'} == 3 && $hash->{'type'}
== 0
;
+ $hash->{'result'} == 3 && $hash->{'type'}
eq '0'
;
};
$hook = sub {
};
$hook = sub {
@@
-269,9
+285,12
@@
sub import_results {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
+ my $total = 0;
my $line;
while ( defined($line=<$fh>) ) {
my $line;
while ( defined($line=<$fh>) ) {
+ next if $line =~ /^\s*$/; #skip blank lines
+
$csv->parse($line) or do {
$dbh->rollback if $oldAutoCommit;
return "can't parse: ". $csv->error_input();
$csv->parse($line) or do {
$dbh->rollback if $oldAutoCommit;
return "can't parse: ". $csv->error_input();
@@
-285,6
+304,15
@@
sub import_results {
$hash{$field} = $value;
}
$hash{$field} = $value;
}
+ if ( &{$end_condition}(\%hash) ) {
+ my $error = &{$end_hook}(\%hash, $total);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ last;
+ }
+
my $cust_pay_batch =
qsearchs('cust_pay_batch', { 'paybatchnum' => $hash{'paybatchnum'} } );
unless ( $cust_pay_batch ) {
my $cust_pay_batch =
qsearchs('cust_pay_batch', { 'paybatchnum' => $hash{'paybatchnum'} } );
unless ( $cust_pay_batch ) {
@@
-314,6
+342,7
@@
sub import_results {
$dbh->rollback if $oldAutoCommit;
return "error adding payment paybatchnum $hash{'paybatchnum'}: $error\n";
}
$dbh->rollback if $oldAutoCommit;
return "error adding payment paybatchnum $hash{'paybatchnum'}: $error\n";
}
+ $total += $hash{'paid'};
$cust_pay->cust_main->apply_payments;
$cust_pay->cust_main->apply_payments;