From e1f891d87bc9deceaa447abdf32e22a41c9521eb Mon Sep 17 00:00:00 2001 From: Philip W Date: Mon, 23 Nov 2015 15:52:06 -0600 Subject: [PATCH] Block fill was off by one --- src/Nacha/File.php | 2 +- test/Nacha/FileTest.php | 49 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/Nacha/File.php b/src/Nacha/File.php index a706a8a..f386419 100644 --- a/src/Nacha/File.php +++ b/src/Nacha/File.php @@ -64,7 +64,7 @@ public function __toString() { $block .= (new Block)."\n"; } - $fileFooter->setBlockCount(round($totalRecords / 10)); + $fileFooter->setBlockCount(ceil($totalRecords / 10)); $fileFooter->setEntryAddendaCount($totalEntryCount); $fileFooter->setTotalDebits($totalDebits); $fileFooter->setTotalCredits($totalCredits); diff --git a/test/Nacha/FileTest.php b/test/Nacha/FileTest.php index 3734329..9c933c2 100644 --- a/test/Nacha/FileTest.php +++ b/test/Nacha/FileTest.php @@ -56,7 +56,7 @@ public function testBatchesAndEntries() { public function testBlockFill() { $this->assertEquals("101 051000033 0599999970602102232A094101ImdDest Name ImdOriginName Referenc -9000000000000000000000000000000000000000000000000000000 +9000000000001000000000000000000000000000000000000000000 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 @@ -67,6 +67,51 @@ public function testBlockFill() { 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", (string)$this->file); } + public function testNoBlockFill() { + // given + $batchA = $this->getBatch(); + $batchA->getHeader()->setCompanyEntryDescription('EXPENSES'); + $batchA->addDebitEntry((new DebitEntry) + ->setTransactionCode(27) + ->setReceivingDfiId('09101298') + ->setCheckDigit(7) + ->setDFiAccountNumber('46479999') + ->setAmount('550.00') + ->setIndividualId('SomePerson1255') + ->setIdividualName('Philip Whitt') + ->setDiscretionaryData('S') + ->setAddendaRecordIndicator(0) + ->setTraceNumber('99936340', 15)); + + $batchA->addDebitEntry((new DebitEntry) + ->setTransactionCode(27) + ->setReceivingDfiId('09101298') + ->setCheckDigit(7) + ->setDFiAccountNumber('46479999') + ->setAmount('550.00') + ->setIndividualId('SomePerson1255') + ->setIdividualName('Philip Whitt') + ->setDiscretionaryData('S') + ->setAddendaRecordIndicator(0) + ->setTraceNumber('99936340', 15)); + + // when + $this->file->addBatch($this->getBatch()); + $this->file->addBatch($batchA); + + // then + $this->assertEquals("101 051000033 0599999970602102232A094101ImdDest Name ImdOriginName Referenc +5225MY BEST COMP INCLUDES OVERTIME 1419871234PPDPAYROLL 0602 0112 2010212340000001 +62709101298746479999 0000055000SomePerson1255 Alex Dubrovsky S 0999363400000015 +822500000100091012980000000550000000000000001419871234 010212340000001 +5225MY BEST COMP INCLUDES OVERTIME 1419871234PPDEXPENSES 0602 0112 2010212340000002 +62709101298746479999 0000055000SomePerson1255 Alex Dubrovsky S 0999363400000015 +62709101298746479999 0000055000SomePerson1255 Philip Whitt S 0999363400000015 +62709101298746479999 0000055000SomePerson1255 Philip Whitt S 0999363400000015 +822500000300273038940000001650000000000000001419871234 010212340000002 +9000002000001000000040036405192000000220000000000000000 ", (string)$this->file); + } + public function testBlockWithEntries() { // given $batchA = $this->getBatch(); @@ -100,7 +145,7 @@ public function testBlockWithEntries() { 62709101298746479999 0000055000SomePerson1255 Alex Dubrovsky S 0999363400000015 62709101298746479999 0000055000SomePerson1255 Philip Whitt S 0999363400000015 822500000200182025960000001100000000000000001419871234 010212340000003 -9000003000001000000040036405192000000220000000000000000 +9000003000002000000040036405192000000220000000000000000 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999