forked from moov-io/ach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (33 loc) · 1.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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("trc-debit.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 err := achFile.Create(); err != nil {
fmt.Printf("Could not create file with read properties: %v", err)
}
fmt.Printf("Total Amount Debit: %v \n", achFile.Control.TotalDebitEntryDollarAmountInFile)
fmt.Printf("SEC Code: %v \n", achFile.Batches[0].GetHeader().StandardEntryClassCode)
fmt.Printf("Check Serial Number: %v \n", achFile.Batches[0].GetEntries()[0].CheckSerialNumberField())
fmt.Printf("Process Control Field: %v \n", achFile.Batches[0].GetEntries()[0].ProcessControlField())
fmt.Printf("Item Research Number: %v \n", achFile.Batches[0].GetEntries()[0].ItemResearchNumber())
fmt.Printf("Item Type Indicator: %v \n", achFile.Batches[0].GetEntries()[0].ItemTypeIndicator())
}