[freeside-commits] freeside/FS/FS/pay_batch RBC.pm, 1.1.2.3, 1.1.2.4

Mark Wells mark at wavetail.420.am
Thu Jan 7 01:49:14 PST 2010


Update of /home/cvs/cvsroot/freeside/FS/FS/pay_batch
In directory wavetail.420.am:/tmp/cvs-serv12203/FS/FS/pay_batch

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	RBC.pm 
Log Message:
Fix problems with RBC batch import (RT#6967)

Index: RBC.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/pay_batch/RBC.pm,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- RBC.pm	31 Dec 2009 23:04:13 -0000	1.1.2.3
+++ RBC.pm	7 Jan 2010 09:49:11 -0000	1.1.2.4
@@ -14,10 +14,11 @@
 %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
+    subtype
     paybatchnum
     custname
     bank
@@ -27,8 +28,9 @@
     ) ],
   '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 { 
@@ -39,17 +41,27 @@
       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';
   },
 );
 



More information about the freeside-commits mailing list