Skip to content

Commit

Permalink
Block fill was off by one
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwhitt committed Nov 23, 2015
1 parent 64b17b3 commit e1f891d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Nacha/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
49 changes: 47 additions & 2 deletions test/Nacha/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testBatchesAndEntries() {

public function testBlockFill() {
$this->assertEquals("101 051000033 0599999970602102232A094101ImdDest Name ImdOriginName Referenc
9000000000000000000000000000000000000000000000000000000
9000000000001000000000000000000000000000000000000000000
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e1f891d

Please sign in to comment.