[freeside-commits] branch master updated. 4918b795f15330720ac379fde8d99855ece06c17

Ivan ivan at 420.am
Sun Jan 20 01:38:30 PST 2013


The branch, master has been updated
       via  4918b795f15330720ac379fde8d99855ece06c17 (commit)
      from  1df8ca6e580bffa11c412b8ae59cd98028ed6470 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4918b795f15330720ac379fde8d99855ece06c17
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Jan 20 01:38:28 2013 -0800

    NACHA batching, RT#20443

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 736fe14..c14600b 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3533,7 +3533,7 @@ and customer address. Include units.',
     'section'     => 'billing',
     'description' => 'Default format for batches.',
     'type'        => 'select',
-    'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch',
+    'select_enum' => [ 'NACHA', 'csv-td_canada_trust-merchant_pc_batch',
                        'csv-chase_canada-E-xactBatch', 'BoM', 'PAP',
                        'paymentech', 'ach-spiritone', 'RBC'
                     ]
@@ -3595,9 +3595,9 @@ and customer address. Include units.',
     'section'     => 'billing',
     'description' => 'Fixed (unchangeable) format for electronic check batches.',
     'type'        => 'select',
-    'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP',
-                       'paymentech', 'ach-spiritone', 'RBC', 'td_eft1464',
-                       'eft_canada'
+    'select_enum' => [ 'NACHA', 'csv-td_canada_trust-merchant_pc_batch', 'BoM',
+                       'PAP', 'paymentech', 'ach-spiritone', 'RBC',
+                       'td_eft1464', 'eft_canada'
                      ]
   },
 
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 6fb84d9..70928a8 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1688,13 +1688,13 @@ sub tables_hashref {
         'zip',      'varchar', 'NULL', 10, '', '', 
         'country',  'char', '',     2, '', '', 
         #        'trancode', 'int', '', '', '', ''
-        'payby',    'char',   '',     4, '', '', # CARD/BILL/COMP, should be
-        'payinfo',  'varchar', '',     512, '', '', 
+        'payby',    'char',        '',       4, '', '',
+        'payinfo',  'varchar', 'NULL',     512, '', '', 
         #'exp',      @date_type, '', ''
-        'exp',      'varchar', 'NULL',     11, '', '', 
+        'exp',      'varchar', 'NULL',      11, '', '', 
         'payname',  'varchar', 'NULL', $char_d, '', '', 
         'amount',   @money_type, '', '', 
-        'status',   'varchar', 'NULL',     $char_d, '', '', 
+        'status',   'varchar', 'NULL', $char_d, '', '', 
       ],
       'primary_key' => 'paybatchnum',
       'unique' => [],
diff --git a/FS/FS/pay_batch/nacha.pm b/FS/FS/pay_batch/nacha.pm
index 999cd9e..17c175d 100644
--- a/FS/FS/pay_batch/nacha.pm
+++ b/FS/FS/pay_batch/nacha.pm
@@ -1,13 +1,15 @@
 package FS::pay_batch::nacha;
 
 use strict;
-use vars qw( %import_info %export_info $name $conf );
+use vars qw( %import_info %export_info $name $conf $entry_hash $DEBUG );
 use Date::Format;
 #use Time::Local 'timelocal';
 #use FS::Conf;
 
 $name = 'NACHA';
 
+$DEBUG = 1;
+
 %import_info = (
   #XXX stub finish me
   'filetype' => 'CSV',
@@ -57,6 +59,10 @@ $name = 'NACHA';
     #though they would probably want them numbered per company
     my $batchnum = substr( ('0'x7). $pay_batch->batchnum, -7);
 
+    $entry_hash = 0;
+
+    warn "building File & Batch Header Records\n" if $DEBUG;
+
     ##
     # File Header Record
     ##
@@ -113,19 +119,28 @@ $name = 'NACHA';
 
     my ($account, $aba) = split('@', $cust_pay_batch->payinfo);
 
+    # "Total of all positions 4-11 on each 6 record"
+    $entry_hash += substr($aba,0,8); 
+
     my $cust_main = $cust_pay_batch->cust_main;
     my $cust_identifier = substr($cust_main->display_custnum. (' 'x15), 0, 15);
 
+    #XXX paytype should actually be in the batch, but this will do for now
+    #27 checking debit, 37 savings debit
+    my $transaction_code = ( $cust_main->paytype =~ /savings/i ? '37' : '27' );
+
     my $cust_name = substr($cust_main->name. (' 'x22), 0, 22);
 
     #non-PPD transactions?  future
 
+    warn "building PPD Record\n" if $DEBUG;
+
     ###
     # PPD Entry Detail Record
     ###
 
     '6'.                              #Record Type Code
-    '27'.                             #27 checking debit, 37 savings debit XXX
+    $transaction_code.                #Transaction Code
     $aba.                             #Receiving DFI Identification, check digit
     substr($account.(' 'x17), 0, 17). #DFI Account number (Left justify)
     sprintf('%010d', $cust_pay_batch->amount * 100). #Amount
@@ -140,6 +155,9 @@ $name = 'NACHA';
   'footer' => sub {
     my( $pay_batch, $batchcount, $batchtotal ) = @_;
 
+    #Only use the final 10 positions in the entry
+    $entry_hash = substr( '00'.$entry_hash, -10); 
+
     $conf->config('batchconfig-nacha-destination') =~ /^\s*(\d{9})\s*$/
       or die 'illegal NACHA Destination';
     my $dest = $1;
@@ -150,6 +168,8 @@ $name = 'NACHA';
 
     my $batchnum = substr( ('0'x7). $pay_batch->batchnum, -7);
 
+    warn "building Batch and File Control Records\n" if $DEBUG;
+
     ###
     # Batch Control Record
     ###
@@ -158,7 +178,7 @@ $name = 'NACHA';
     '225'.                        #Service Class Code (220 credits only,
                                   #                    200 mixed debits&credits)
     sprintf('%06d', $batchcount). #Entry / Addenda Count
-    '1234567890'. #XXX "Entry Hash" Total of all positions 4-11 on each 6 record.  Only use the final 10 positions in the entry
+    $entry_hash.
     sprintf('%012d', $batchtotal * 100). #Debit total
     '000000000000'.               #Credit total
     $origin.                      #Company Identification (Immediate Origin)
@@ -175,7 +195,7 @@ $name = 'NACHA';
     '000001'.                            #Batch Counter (# of batch header recs)
     sprintf('%06d', $batchcount + 4).    #num of physical blocks on the file..?
     sprintf('%08d', $batchcount).        #total # of entry detail and addenda
-    '1234567890'. #XXX "Entry Hash" Total of all positions 4-11 on each 6 record.  Only use the final 10 positions in the entry
+    $entry_hash.
     sprintf('%012d', $batchtotal * 100). #Debit total
     '000000000000'.                      #Credit total
     ( ' 'x39 )                           #Reserved / blank
diff --git a/httemplate/search/elements/cust_pay_batch_top.html b/httemplate/search/elements/cust_pay_batch_top.html
index 1dcc37a..bf30477 100644
--- a/httemplate/search/elements/cust_pay_batch_top.html
+++ b/httemplate/search/elements/cust_pay_batch_top.html
@@ -120,6 +120,7 @@ my $fixed = $conf->config("batch-fixed_format-$payby");
 
 tie my %download_formats, 'Tie::IxHash', (
 '' => 'Default batch mode',
+'NACHA' => '94 byte NACHA',
 'csv-td_canada_trust-merchant_pc_batch' => 
               'CSV file for TD Canada Trust Merchant PC Batch',
 'csv-chase_canada-E-xactBatch' =>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                                      |    8 +++---
 FS/FS/Schema.pm                                    |    8 +++---
 FS/FS/pay_batch/nacha.pm                           |   28 +++++++++++++++++---
 httemplate/search/elements/cust_pay_batch_top.html |    1 +
 4 files changed, 33 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list