8000 [pull] master from moov-io:master by pull[bot] · Pull Request #103 · wei/ach · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[pull] master from moov-io:master #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHu 8000 b”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fileControl.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type FileControl struct {
TotalDebitEntryDollarAmountInFile int `json:"totalDebit"`
// TotalCreditEntryDollarAmountInFile contains accumulated Batch credit totals within the file.
TotalCreditEntryDollarAmountInFile int `json:"totalCredit"`
// Reserved contains the data from 56-94. This may change if Nacha updates the File Control record.
Reserved string `json:"reserved"`
// Line number at which the record appears in the file
LineNumber int `json:"lineNumber,omitempty"`
// validator is composed for data validation
Expand Down Expand Up @@ -100,7 +102,7 @@ func (fc *FileControl) Parse(record string) {
fc.TotalCreditEntryDollarAmountInFile = fc.parseNumField(reset())
case 94:
// 56-94 Reserved Always blank (just fill with spaces)
reset()
fc.Reserved = reset()
}
}
}
Expand Down
77 changes: 77 additions & 0 deletions test/moov/moov_id_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package moov_test

import (
"os"
"path/filepath"
"testing"

"github.com/moov-io/ach"
"github.com/moov-io/ach/cmd/achcli/describe"

"github.com/stretchr/testify/require"
)

func TestReadWithMoovIDs(t *testing.T) {
fd, err := os.Open(filepath.Join("..", "testdata", "moov-ids.ach"))
require.NoError(t, err)

t.Cleanup(func() { fd.Close() })

r := ach.NewReader(fd)
r.SetValidation(&ach.ValidateOpts{
CustomTraceNumbers: true,
})

file, err := r.Read()
require.NoError(t, err)

if testing.Verbose() {
describe.File(os.Stdout, &file, nil)
}

// File Header changes
fh := file.Header
require.Equal(t, "123456789", fh.ImmediateOrigin)
require.Equal(t, "228591016", fh.ImmediateDestination)
require.Equal(t, "48104ccf-d5c9-49cc-a273-aaac7d14cd68", fh.ImmediateDestinationName+fh.ImmediateOriginName)

// Batch Header changes
require.Len(t, file.Batches, 2)

bh0 := file.Batches[0].GetHeader()
require.Equal(t, ach.CreditsOnly, bh0.ServiceClassCode)
require.Equal(t, ach.PPD, bh0.StandardEntryClassCode)
require.Equal(t, "2ada48fb-92bc-4882-890e-e39bc1bebc4f", bh0.CompanyName+bh0.CompanyDiscretionaryData)
require.Equal(t, "COMPANY", bh0.CompanyIdentification)

bh1 := file.Batches[1].GetHeader()
require.Equal(t, ach.CreditsOnly, bh1.ServiceClassCode)
require.Equal(t, ach.PPD, bh1.StandardEntryClassCode)
require.Equal(t, "f36eb0f2-65f6-4481-bce3-4c1c6e6a586c", bh1.CompanyName+bh1.CompanyDiscretionaryData)
require.Equal(t, "COMPANY2", bh1.CompanyIdentification)

// Entry changes
b0entries := file.Batches[0].GetEntries()
require.Len(t, b0entries, 2)
b1entries := file.Batches[1].GetEntries()
require.Len(t, b0entries, 2)

// Batch 0, Entry 0
require.Equal(t, "11122233", b0entries[0].RDFIIdentification)
require.Equal(t, "12345678901", b0entries[0].DFIAccountNumber)

// Batch 0, Entry 1
require.Equal(t, "11122233", b0entries[1].RDFIIdentification)
require.Equal(t, "12345678902", b0entries[1].DFIAccountNumber)

// Batch 1, Entry 0
require.Equal(t, "44455566", b1entries[0].RDFIIdentification)
require.Equal(t, "12345678903", b1entries[0].DFIAccountNumber)

// Batch 1, Entry 1
require.Equal(t, "77788899", b1entries[1].RDFIIdentification)
require.Equal(t, "12345678904", b1entries[1].DFIAccountNumber)

// File Control
require.Equal(t, "8c365fa8-460f-4665-99d0-735ec25e346b ", file.Control.Reserved)
}
10 changes: 10 additions & 0 deletions test/testdata/moov-ids.ach
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
101 228591016 1234567892505061342009410148104ccf-d5c9-49cc-a273-aaac7d14cd68 TESTTEST
52202ada48fb-92bc-4882-890e-e39bc1bebc4fCOMPANY PPDTESTDESC SD18002505060001540122100000001
62211122233712345678901 0000005521111222333444555BILLY BOB 0228591010000001
62211122233712345678902 0000005522111222333444555TIMMY STU 0228591010000002
82200000020022244466000000000000000000011043COMPANY 540122100000001
5220f36eb0f2-65f6-4481-bce3-4c1c6e6a586cCOMPANY2 PPDOTHERDESC SD18002505060001540122100000002
62244455566112345678903 0000005521111222333444555CLETUS JONES 0228591010000003
62277788899512345678904 0000005522111222333444555LOTHAR SMITH 0228591010000004
82200000020122244465000000000000000000011043COMPANY2 540122100000002
90000020000010000000499999999990000000000000000000220868c365fa8-460f-4665-99d0-735ec25e346b
Loading
0