-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from bkmoovio/CIE-Test
#209 CIE Test
- Loading branch information
Showing
9 changed files
with
136 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
101 231380104 1210428821806200000A094101Federal Reserve Bank My Bank Name | ||
5220Name on Account 121042882 CIEPayment 180621 0121042880000001 | ||
62223138010412345678 0100000000 Receiver Account Name 011121042880000001 | ||
705Credit Store Account 00010000001 | ||
82200000020023138010000000000000000100000000121042882 121042880000001 | ||
9000001000001000000020023138010000000000000000100000000 | ||
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,34 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/bkmoovio/ach" | ||
"log" | ||
"os" | ||
) | ||
|
||
func main() { | ||
// open a file for reading. Any io.Reader Can be used | ||
f, err := os.Open("cie-credit.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("Total Amount Debit: %v \n", achFile.Control.TotalDebitEntryDollarAmountInFile) | ||
fmt.Printf("Total Amount Credit: %v \n", achFile.Control.TotalCreditEntryDollarAmountInFile) | ||
fmt.Printf("SEC Code: %v \n", achFile.Batches[0].GetHeader().StandardEntryClassCode) | ||
fmt.Printf("Addenda05: %v \n", achFile.Batches[0].GetEntries()[0].Addendum[0].String()) | ||
} |
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,72 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/bkmoovio/ach" | ||
"log" | ||
"os" | ||
"time" | ||
) | ||
|
||
func main() { | ||
// Example transfer to write an ACH CIE file to send/credit a external institutions account | ||
// 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 = "231380104" // Routing Number of the ACH Operator or receiving point to which the file is being sent | ||
fh.ImmediateOrigin = "121042882" // 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 = "CIE" // Consumer destination vs Company CCD | ||
bh.CompanyEntryDescription = "Payment" // will be on receiving accounts statement | ||
bh.EffectiveEntryDate = time.Now().AddDate(0, 0, 1) | ||
bh.ODFIIdentification = "121042882" // 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 = 22 // Code 22: Credit to Store checking account | ||
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 | ||
entry.SetTraceNumber(bh.ODFIIdentification, 1) | ||
entry.IndividualName = "Receiver Account Name" // Identifies the receiver of the transaction | ||
entry.DiscretionaryData = "01" | ||
|
||
addenda05 := ach.NewAddenda05() | ||
addenda05.PaymentRelatedInformation = "Credit Store Account" | ||
addenda05.SequenceNumber = 1 | ||
addenda05.EntryDetailSequenceNumber = 0000001 | ||
|
||
// build the batch | ||
batch := ach.NewBatchCIE(bh) | ||
batch.AddEntry(entry) | ||
batch.GetEntries()[0].AddAddenda(addenda05) | ||
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.WriteAll([]*ach.File{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,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
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