Skip to content

Commit

Permalink
FileHeader - CheckRoutingNumber
Browse files Browse the repository at this point in the history
FileHeader - CheckRoutingNumber
  • Loading branch information
bkmoovio committed Jun 24, 2019
1 parent 7f325e1 commit 1db1c32
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 58 deletions.
6 changes: 6 additions & 0 deletions fileHeader.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ func (fh *FileHeader) Validate() error {
if fh.ImmediateDestination == "000000000" {
return fieldError("ImmediateDestination", ErrConstructor, fh.ImmediateDestination)
}
if err := CheckRoutingNumber(fh.ImmediateOrigin); err != nil {
return fieldError("ImmediateOrigin", err, fh.ImmediateOrigin)
}
if err := CheckRoutingNumber(fh.ImmediateDestination); err != nil {
return fieldError("ImmediateDestination", err, fh.ImmediateDestination)
}
if err := fh.isAlphanumeric(fh.ImmediateOriginName); err != nil {
return fieldError("ImmediateOriginName", err, fh.ImmediateOriginName)
}
Expand Down
2 changes: 1 addition & 1 deletion merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestMergeFiles__splitFiles(t *testing.T) {
}

// read a third file
f3, err := readACHFilepath(filepath.Join("test", "testdata", "20110729A.ach"))
f3, err := readACHFilepath(filepath.Join("test", "testdata", "20110805A.ach"))
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ func BenchmarkACHFileRead(b *testing.B) {

// testACHFileRead2 validates reading a file with PPD and IAT entries
func testACHFileRead2(t testing.TB) {
f, err := os.Open("./test/testdata/20110729A.ach")
f, err := os.Open("./test/testdata/20110805A.ach")
if err != nil {
t.Errorf("%T: %s", err, err)
}
Expand Down
15 changes: 10 additions & 5 deletions test/ach-ppd-read/ppd-debit.ach
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
101 076401251 0764012510807291511A094101achdestname companyname
5225companyname origid PPDCHECKPAYMT000002080730 1076401250000001
62705320001912345 0000010500c-1 Bachman Eric DD0076401255655291
82250000010005320001000000010500000000000000origid 076401250000001
9000001000001000000010005320001000000010500000000000000
101 23138010401210428821906240000A094101Federal Reserve Bank My Bank Name
5225Name on Account 121042882 PPDREG.SALARY 190625 1121042880000001
62723138010412345678 0100000000 Receiver Account Name 0121042880000001
82250000010023138010000100000000000000000000121042882 121042880000001
9000001000001000000010023138010000100000000000000000000
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
4 changes: 2 additions & 2 deletions test/ach-ppd-write/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {

// BatchHeader identifies the originating entity and the type of transactions contained in the batch
bh := ach.NewBatchHeader()
bh.ServiceClassCode = ach.CreditsOnly
bh.ServiceClassCode = ach.DebitsOnly
bh.CompanyName = "Name on Account" // The name of the company/person that has relationship with receiver
bh.CompanyIdentification = fh.ImmediateOrigin
bh.StandardEntryClassCode = ach.PPD
Expand All @@ -35,7 +35,7 @@ func main() {
// can be multiple entry's per batch
entry := ach.NewEntryDetail()
// Identifies the entry as a debit and credit entry AND to what type of account (Savings, DDA, Loan, GL)
entry.TransactionCode = ach.CheckingCredit
entry.TransactionCode = ach.CheckingDebit
entry.SetRDFI("231380104") // Receivers bank transit routing number
entry.DFIAccountNumber = "12345678" // Receivers bank account number
entry.Amount = 100000000 // Amount of transaction with no decimal. One dollar and eleven cents = 111
Expand Down
18 changes: 9 additions & 9 deletions test/testdata/20110729A.ach
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
101 04200001312345678981107291600A094101US BANK NA TEST COMPANY
5225TEST COMPANY 11234567898PPDTEST BUYS 110801110801 1098765430000001
101 0420000132313801041107291600A094101US BANK NA TEST COMPANY
5225TEST COMPANY 1231380104PPDTEST BUYS 110801110801 1098765430000001
627021200025998412345 0011900000OA313 AYDEN DERS 0098765434200001
627021200025998412345 0009900000OA235 DYLAN HUNTER 0098765434200002
627021200025998412345 0015100000OA357 COLTON LOWE 0098765434200003
Expand Down Expand Up @@ -145,8 +145,8 @@
627021200025998412345 0005900000OA246 JESSICA WALKER 0098765434200143
627021200025998412345 0008700000OA231 ELIZABETH COLE 0098765434200144
627021200025998412345 0026100000OA351 LUKE CRAIG 0098765434200145
822500014503074002900024798000000000000000001234567898 098765430000001
5220TEST COMPANY 11234567898PPDVERIFY 110801110801 1098765430000003
82250001450307400290002479800000000000000000231380104 098765430000001
5220TEST COMPANY 1231380104PPDVERIFY 110801110801 1098765430000003
622021200025998412345 0000001800OA370 CHASE BLACK 0098765434200001
622021200025998412345 0000001300OA379 ANDREA BUTLER 0098765434200002
622021200025998412345 0000000700OA371 BLAKE REYES 0098765434200003
Expand All @@ -165,8 +165,8 @@
622021200025998412345 0000000200OA386 CONNOR MEDINA 0098765434200016
622021200025998412345 0000001600OA380 ANDREA BUTLER 0098765434200017
622021200025998412345 0000001200OA383 BRANDON ARMSTRONG 0098765434200018
822000001800381600360000000000000000000172001234567898 098765430000003
5225 FV3 CA1234567898IATTEST BUYS USDCAD110802 1098765430000004
82200000180038160036000000000000000000017200231380104 098765430000003
5225 FV3 CA231380104IATTEST BUYS USDCAD110802 1098765430000004
627091050234007 0012200000998412345 1098765430000001
710WEB DIEGO MAY 0000001
711TEST COMPANY 123 EASY STREET 0000001
Expand Down Expand Up @@ -271,8 +271,8 @@
714CENTRAL 01021200025 CA 0000013
715OA397 PO Box 340 0000013
716Metropolis*ON\ CA*01234\ 0000013
822500010401183652990002073000000000000000001234567898 098765430000004
5220 FV3 CA1234567898IATVERIFY USDCAD110802 1098765430000005
82250001040118365299000207300000000000000000231380104 098765430000004
5220 FV3 CA231380104IATVERIFY USDCAD110802 1098765430000005
622091050234007 0000001200998412345 1098765430000001
710WEB LEAH BRYANT 0000001
711TEST COMPANY 123 EASY STREET 0000001
Expand All @@ -289,5 +289,5 @@
714CENTRAL 01021200025 CA 0000002
715OA401 PO Box 410 0000002
716Metropolis*ON\ CA*01234\ 0000002
822000001600182100460000000000000000000013001234567898 098765430000005
82200000160018210046000000000000000000001300231380104 098765430000005
9000005000030000002830482135671002687100000000000018500
18 changes: 9 additions & 9 deletions test/testdata/20110805A.ach
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
101 04200001301234567891108052100A094101US BANK NA EXAMPLE COMPANY
5225EXAMPLE COMPANY 0123456789PPDBUY WIDGET110808110808 1042000010000001
101 04200001302313801041108052100A094101US BANK NA EXAMPLE COMPANY
5225EXAMPLE COMPANY 0231380104PPDBUY WIDGET110808110808 1042000010000001
627021200025998412345 0000027000A271 JULIAN PRICE 0042000010000001
627021200025998412345 0000062000A272 SYDNEY BUTLER 0042000010000002
627021200025998412345 0000209000A273 KEVIN CASTILLO 0042000010000003
Expand All @@ -25,8 +25,8 @@
627021200025998412345 0000255000A296 RYAN FLETCHER 0042000010000023
627021200025998412345 0000149000A297 PAYTON MCCOY 0042000010000024
627021200025998412345 0000217000A298 DESTINY COLEMAN 0042000010000025
822500002500530000500000046100000000000000000123456789 042000010000001
5220EXAMPLE COMPANY 0123456789PPDVERIFY 110808110808 1042000010000003
822500002500530000500000046100000000000000000231380104 042000010000001
5220EXAMPLE COMPANY 0231380104PPDVERIFY 110808110808 1042000010000003
622021200025998412345 0000000008A251 NATHAN NELSON 0042000010000001
622021200025998412345 0000000010A252 NATHAN NELSON 0042000010000002
622021200025998412345 0000000002A253 CHARLES REYES 0042000010000003
Expand All @@ -45,8 +45,8 @@
622021200025998412345 0000000009A268 WILLIAM HUDSON 0042000010000016
622021200025998412345 0000000013A269 JOSHUA OBRIEN 0042000010000017
622021200025998412345 0000000009A270 JOSHUA OBRIEN 0042000010000018
822000001800381600360000000000000000000001760123456789 042000010000003
5225ABC INC FV3 CA0123456789IATBUY WIDGETUSDCAD110808 1042000010000004
822000001800381600360000000000000000000001760231380104 042000010000003
5225ABC INC FV3 CA0231380104IATBUY WIDGETUSDCAD110808 1042000010000004
6270910502340007 0000109000998412345 1042000010000001
710WEB000000000000000000 HAYDEN BANKS 0000001
711EXAMPLE COMPANY 123 EASY STREET 0000001
Expand All @@ -71,8 +71,8 @@
714CENTRAL 01021200025 CA 0000003
715A293 PO Box 740 0000003
716Metropolis*ON\ CA*01234\ 0000003
822500002400273150690000004910000000000000000123456789 042000010000004
5220 FV3 CA0123456789IATVERIFY USDCAD110808 1042000010000005
822500002400273150690000004910000000000000000231380104 042000010000004
5220 FV3 CA0231380104IATVERIFY USDCAD110808 1042000010000005
6220910502340007 0000000018998412345 1042000010000001
710WEB000000000000000000 AIDAN BANKS 0000001
711EXAMPLE COMPANY 123 EASY STREET 0000001
Expand All @@ -89,5 +89,5 @@
714CENTRAL 01021200025 CA 0000002
715A258 PO Box 160 0000002
716Metropolis*ON\ CA*01234\ 0000002
822000001600182100460000000000000000000000240123456789 042000010000005
822000001600182100460000000000000000000000240231380104 042000010000005
9000005000010000000830136685201000005101000000000000200000000000000000000000000000000000000000
10 changes: 5 additions & 5 deletions test/testdata/20180713-IAT.ach
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
101 987654321 1234567891807130000A094101Federal Reserve Bank My Bank Name
5220 FF3 US123456789 IATTRADEPAYMTCADUSD010101 1231380100000001
6221210428820007 0000100000123456789 1231380100000001
101 031300012 2313801041807130000A094101Federal Reserve Bank My Bank Name
5220 FF3 US231380104 IATTRADEPAYMTCADUSD010101 1231380100000001
6221210428820007 0000100000231380104 1231380100000001
710ANN000000000000100000928383-23938 BEK Enterprises 0000001
711BEK Solutions 15 West Place Street 0000001
712JacobsTown*PA\ US19305\ 0000001
Expand All @@ -9,8 +9,8 @@
7159874654932139872121 Front Street 0000001
716LetterTown*AB\ CA*80014\ 0000001
82200000080012104288000000000000000000100000 231380100000001
5220 FF3 US123456789 IATTRADEPAYMTCADUSD010101 1231380100000002
6271210428820007 0000002000123456789 1231380100000001
5220 FF3 US231380104 IATTRADEPAYMTCADUSD010101 1231380100000002
6271210428820007 0000002000231380104 1231380100000001
710ANN000000000000100000928383-23938 BEK Enterprises 0000001
711BEK Solutions 15 West Place Street 0000001
712JacobsTown*PA\ US19305\ 0000001
Expand Down
18 changes: 9 additions & 9 deletions test/testdata/20180716-IAT-A17-A18.ach
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
101 987654321 1234567891807160000A094101Federal Reserve Bank My Bank Name
5220 FF3 US123456789 IATTRADEPAYMTCADUSD010101 1231380100000001
6221210428820007 0000100000123456789 1231380100000001
101 031300012 2313801041807160000A094101Federal Reserve Bank My Bank Name
5220 FF3 US231380104 IATTRADEPAYMTCADUSD010101 1231380100000001
6221210428820007 0000100000231380104 1231380100000001
710ANN000000000000100000928383-23938 BEK Enterprises 0000001
711BEK Solutions 15 West Place Street 0000001
712JacobsTown*PA\ US*19305\ 0000001
Expand All @@ -13,11 +13,11 @@
718Bank of Germany 01987987987654654 DE 00010000001
718Bank of Spain 01987987987123123 ES 00020000001
718Bank of France 01456456456987987 FR 00030000001
718Bank of Turkey 0112312345678910 TR 00040000001
718Bank of United Kingdom 011234567890123456789012345678901234GB 00050000001
718Bank of Turkey 0112323138010410 TR 00040000001
718Bank of United Kingdom 012313801040231380104023138010401234GB 00050000001
82200000150012104288000000000000000000100000 231380100000001
5220 FF3 US123456789 IATTRADEPAYMTCADUSD010101 1231380100000002
6271210428820007 0000002000123456789 1231380100000001
5220 FF3 US231380104 IATTRADEPAYMTCADUSD010101 1231380100000002
6271210428820007 0000002000231380104 1231380100000001
710ANN000000000000100000928383-23938 BEK Enterprises 0000001
711BEK Solutions 15 West Place Street 0000001
712JacobsTown*PA\ US*19305\ 0000001
Expand All @@ -30,8 +30,8 @@
718Bank of Germany 01987987987654654 DE 00010000001
718Bank of Spain 01987987987123123 ES 00020000001
718Bank of France 01456456456987987 FR 00030000001
718Bank of Turkey 0112312345678910 TR 00040000001
718Bank of United Kingdom 011234567890123456789012345678901234GB 00050000001
718Bank of Turkey 0112323138010410 TR 00040000001
718Bank of United Kingdom 012313801040231380104023138010401234GB 00050000001
82200000150012104288000000002000000000000000 231380100000002
9000002000004000000300024208576000000002000000000100000
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Expand Down
10 changes: 5 additions & 5 deletions test/testdata/20180716-IAT-A17.ach
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
101 987654321 1234567891807160000A094101Federal Reserve Bank My Bank Name
5220 FF3 US123456789 IATTRADEPAYMTCADUSD010101 1231380100000001
6221210428820007 0000100000123456789 1231380100000001
101 031300012 2313801041807160000A094101Federal Reserve Bank My Bank Name
5220 FF3 US231380104 IATTRADEPAYMTCADUSD010101 1231380100000001
6221210428820007 0000100000231380104 1231380100000001
710ANN000000000000100000928383-23938 BEK Enterprises 0000001
711BEK Solutions 15 West Place Street 0000001
712JacobsTown*PA\ US*19305\ 0000001
Expand All @@ -11,8 +11,8 @@
717This is an international payment 00010000001
717Transfer of money from one country to another 00020000001
82200000100012104288000000000000000000100000 231380100000001
5220 FF3 US123456789 IATTRADEPAYMTCADUSD010101 1231380100000002
6271210428820007 0000002000123456789 1231380100000001
5220 FF3 US231380104 IATTRADEPAYMTCADUSD010101 1231380100000002
6271210428820007 0000002000231380104 1231380100000001
710ANN000000000000100000928383-23938 BEK Enterprises 0000001
711BEK Solutions 15 West Place Street 0000001
712JacobsTown*PA\ US*19305\ 0000001
Expand Down
Loading

0 comments on commit 1db1c32

Please sign in to comment.