-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support acknowledgment entries - ACK & ATX #327
read and write test change SetOriginalTraceNumber argument from int to string
- Loading branch information
Showing
8 changed files
with
147 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
101 031300012 2313801041810260000A094101Federal Reserve Bank My Bank Name | ||
5220Name on Account 231380104 ACKVndr Pay 181027 0231380100000001 | ||
624031300012744-5678-99 0000000000031300010000001Best. #1 S 0231380100000001 | ||
624031300012744-5678-99 0000000000031300010000002Best. #1 S 0231380100000002 | ||
82200000020006260002000000000000000000000000231380104 231380100000001 | ||
9000001000001000000020006260002000000000000000000000000 | ||
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 | ||
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 | ||
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 | ||
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/moov-io/ach" | ||
) | ||
|
||
func main() { | ||
// open a file for reading. Any io.Reader Can be used | ||
f, err := os.Open("ack-read.ach") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
r := ach.NewReader(f) | ||
achFile, err := r.Read() | ||
if err != nil { | ||
fmt.Printf("Issue reading file: %+v \n", err) | ||
} | ||
// ensure we have a validated file structure | ||
if achFile.Validate(); err != nil { | ||
fmt.Printf("Could not validate entire read file: %v", err) | ||
} | ||
// If you trust the file but it's formatting is off building will probably resolve the malformed file. | ||
if achFile.Create(); err != nil { | ||
fmt.Printf("Could not build file with read properties: %v", err) | ||
} | ||
|
||
fmt.Printf("Credit Total Amount: %v \n", achFile.Control.TotalCreditEntryDollarAmountInFile) | ||
fmt.Printf("Total Amount: %v \n", achFile.Batches[0].GetEntries()[0].Amount) | ||
fmt.Printf("SEC Code: %v \n", achFile.Batches[0].GetHeader().StandardEntryClassCode) | ||
fmt.Printf("Original Trace Number: %v \n", achFile.Batches[0].GetEntries()[0].OriginalTraceNumberField()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func Test(t *testing.T) { | ||
main() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"time" | ||
|
||
"github.com/moov-io/ach" | ||
) | ||
|
||
func main() { | ||
// Example transfer to write an ACH ACK file acknowledging a credit | ||
// Important: All financial institutions are different and will require registration and exact field values. | ||
|
||
// Set originator bank ODFI and destination Operator for the financial institution | ||
// this is the funding/receiving source of the transfer | ||
fh := ach.NewFileHeader() | ||
fh.ImmediateDestination = "031300012" // Routing Number of the ACH Operator or receiving point to which the file is being sent | ||
fh.ImmediateOrigin = "231380104" // Routing Number of the ACH Operator or sending point that is sending the file | ||
fh.FileCreationDate = time.Now() // Today's Date | ||
fh.ImmediateDestinationName = "Federal Reserve Bank" | ||
fh.ImmediateOriginName = "My Bank Name" | ||
|
||
// BatchHeader identifies the originating entity and the type of transactions contained in the batch | ||
bh := ach.NewBatchHeader() | ||
bh.ServiceClassCode = 220 // ACH credit pushes money out, 225 debits/pulls money in. | ||
bh.CompanyName = "Name on Account" // The name of the company/person that has relationship with receiver | ||
bh.CompanyIdentification = fh.ImmediateOrigin | ||
bh.StandardEntryClassCode = "ACK" // Consumer destination vs Company CCD | ||
bh.CompanyEntryDescription = "Vndr Pay" // will be on receiving accounts statement | ||
bh.EffectiveEntryDate = time.Now().AddDate(0, 0, 1) | ||
bh.ODFIIdentification = "23138010" // Originating Routing Number | ||
|
||
// Identifies the receivers account information | ||
// 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 = 24 // Code 22: Demand Debit(deposit) to checking account | ||
entry.SetRDFI("031300012") // Receivers bank transit routing number | ||
entry.DFIAccountNumber = "744-5678-99" // Receivers bank account number | ||
entry.Amount = 0 // Amount of transaction with no decimal. One dollar and eleven cents = 111 | ||
entry.SetOriginalTraceNumber("031300010000001") | ||
entry.SetReceivingCompany("Best. #1") | ||
entry.SetTraceNumber(bh.ODFIIdentification, 1) | ||
entry.DiscretionaryData = "S" | ||
|
||
entryOne := ach.NewEntryDetail() // Fee Entry | ||
entryOne.TransactionCode = 24 // Demand Credit | ||
entryOne.SetRDFI("031300012") // Receivers bank transit routing number | ||
entryOne.DFIAccountNumber = "744-5678-99" // Receivers bank account number | ||
entryOne.Amount = 0 // Amount of transaction with no decimal. One dollar and eleven cents = 111 | ||
entryOne.SetOriginalTraceNumber("031300010000002") | ||
entryOne.SetReceivingCompany("Best. #1") | ||
entryOne.SetTraceNumber(bh.ODFIIdentification, 2) | ||
entryOne.DiscretionaryData = "S" | ||
|
||
// build the batch | ||
batch := ach.NewBatchACK(bh) | ||
batch.AddEntry(entry) | ||
batch.AddEntry(entryOne) | ||
if err := batch.Create(); err != nil { | ||
log.Fatalf("Unexpected error building batch: %s\n", err) | ||
} | ||
|
||
// build the file | ||
file := ach.NewFile() | ||
file.SetHeader(fh) | ||
file.AddBatch(batch) | ||
if err := file.Create(); err != nil { | ||
log.Fatalf("Unexpected error building file: %s\n", err) | ||
} | ||
|
||
// write the file to std out. Anything io.Writer | ||
w := ach.NewWriter(os.Stdout) | ||
if err := w.Write(file); err != nil { | ||
log.Fatalf("Unexpected error: %s\n", err) | ||
} | ||
w.Flush() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func Test(t *testing.T) { | ||
main() | ||
} | ||
|