X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch%2Fnacha.pm;h=0361304e384a7d1cd2b9213752cd42b6c2546a84;hb=725118b4ae55c06cefb2d0b2ef41c7addf4a3a97;hp=d6786e03508fa7999cf2ea5ce0116c642199fe89;hpb=7a7a0c736e3cfbd10b06151a93bf499d185d37d3;p=freeside.git diff --git a/FS/FS/pay_batch/nacha.pm b/FS/FS/pay_batch/nacha.pm index d6786e035..0361304e3 100644 --- a/FS/FS/pay_batch/nacha.pm +++ b/FS/FS/pay_batch/nacha.pm @@ -148,7 +148,7 @@ $DEBUG = 0; $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 + sprintf('%010.0f', $cust_pay_batch->amount * 100). #Amount $cust_identifier. #Individual Identification Number, 15 char $cust_name. #Individual name (22-char) ' '. #2 char "company internal use if desired" @@ -174,6 +174,15 @@ $DEBUG = 0; my $batchnum = substr( ('0'x7). $pay_batch->batchnum, -7); + my $lines = $batchcount + 4; + my $blocks = int($lines/10); + my $fill = ''; + + if ( my $remainder = $lines % 10 ) { + $blocks++; + $fill = ("\n".('9'x94))x( 10 - $remainder ); + } + warn "building Batch & File Control Records\n" if $DEBUG; ### @@ -199,12 +208,18 @@ $DEBUG = 0; '9'. #Record Type Code '000001'. #Batch Counter (# of batch header recs) - sprintf('%06d', $batchcount + 4). #num of physical blocks on the file..? + sprintf('%06d', $blocks). #num of physical blocks on the file sprintf('%08d', $batchcount). #total # of entry detail and addenda $entry_hash. sprintf('%012.0f', $batchtotal * 100). #Debit total '000000000000'. #Credit total - ( ' 'x39 ) #Reserved / blank + ( ' 'x39 ). #Reserved / blank + + ### + # Pad with 9999 records to blocks of 10 + ### + + $fill },