Skip to content

Commit

Permalink
Merge pull request #1480 from adamdecaf/fix-issue1170
Browse files Browse the repository at this point in the history
fix: verify ACK and ATX amounts are zero
  • Loading branch information
adamdecaf authored Aug 28, 2024
2 parents 316e26a + b7899f5 commit 53b5fd1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,14 @@ func (batch *Batch) ValidAmountForCodes(entry *EntryDetail) error {
if batch.validateOpts != nil && batch.validateOpts.AllowZeroEntryAmount {
return nil
}

switch batch.Header.StandardEntryClassCode {
case ACK, ATX:
if entry.TransactionCode == CheckingZeroDollarRemittanceCredit || entry.TransactionCode == SavingsZeroDollarRemittanceCredit {
return nil
}
}

return fieldError("Amount", ErrBatchAmountZero, entry.Amount)
}
}
Expand Down
6 changes: 3 additions & 3 deletions batchACK.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ func (batch *BatchACK) Validate() error {
return batch.Error("TransactionCode", ErrBatchTransactionCode, entry.TransactionCode)
}
// // Verify the Amount is valid for SEC code and TransactionCode
// if err := batch.ValidAmountForCodes(entry); err != nil { // TODO(adam): https://github.com/moov-io/ach/issues/1170
// return err
// }
if err := batch.ValidAmountForCodes(entry); err != nil {
return err
}
// Verify the TransactionCode is valid for a ServiceClassCode
if err := batch.ValidTranCodeForServiceClassCode(entry); err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions batchATX.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ func (batch *BatchATX) Validate() error {
if len(entry.Addenda05) != addendaRecords {
return batch.Error("AddendaCount", NewErrBatchExpectedAddendaCount(len(entry.Addenda05), addendaRecords))
}
// // Verify the Amount is valid for SEC code and TransactionCode
// if err := batch.ValidAmountForCodes(entry); err != nil { // TODO(adam): https://github.com/moov-io/ach/issues/1170
// return err
// }
// Verify the Amount is valid for SEC code and TransactionCode
if err := batch.ValidAmountForCodes(entry); err != nil {
return err
}
// Verify the TransactionCode is valid for a ServiceClassCode
if err := batch.ValidTranCodeForServiceClassCode(entry); err != nil {
return err
Expand Down

0 comments on commit 53b5fd1

Please sign in to comment.