Skip to content

Commit

Permalink
Merge pull request #191 from moov-io/resp-entryType-match-tx-code
Browse files Browse the repository at this point in the history
response: compare entryType directly against TransactionCode as well
  • Loading branch information
adamdecaf committed Nov 21, 2023
2 parents 631654a + 5b76ce3 commit cfec8d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ match:
individualName: <string> # Compare the IndividualName on EntryDetail records
routingNumber: <string> # Exact match of ABA routing number (RDFIIdentification and CheckDigit)
traceNumber: <string> # Exact match of TraceNumber
entryType: <string> # Checks TransactionCode. Accepted values: credit, debit or prenote.
# Matching will find at most two Actions in the config file order. One Copy Action and one Return/Correction Action.
entryType: <string> # Checks TransactionCode. Accepted values: credit, debit or prenote. Also can be Nacha value (e.g. 27, 32)
# Matching will find at most two Actions in the config file order. One Copy Action and one Return/Correction Action.
# Both actions will be executed if the Return/Correction Action has a delay.
# Valid combinations include:
# 1. Copy
Expand Down
6 changes: 5 additions & 1 deletion pkg/response/match/matcher.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package match

import (
"fmt"
"strings"

"github.com/moov-io/ach"
Expand Down Expand Up @@ -204,7 +205,10 @@ func matchedEntryType(m service.Match, ed *ach.EntryDetail) bool {
case m.EntryType == service.EntryTypePrenote && matchedPrenote(m, ed):
return true
default:
return false
exists := m.EntryType != ""
matches := string(m.EntryType) == fmt.Sprintf("%d", ed.TransactionCode)

return exists && matches
}
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/response/match/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ func TestMatchEntryType(t *testing.T) {

require.Equal(t, tc.want, matchedEntryType(m, ed))
}

t.Run("exact value", func(t *testing.T) {
m := service.Match{
EntryType: "",
}
ed := ach.NewEntryDetail()
ed.TransactionCode = ach.CheckingCredit

require.False(t, matchedEntryType(m, ed))

// Make them match
m.EntryType = "22"
require.True(t, matchedEntryType(m, ed))
})
}

func TestMatchIndividualName(t *testing.T) {
Expand Down

0 comments on commit cfec8d9

Please sign in to comment.