forked from moov-io/ach
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreturnAddenda.go
66 lines (57 loc) · 1.67 KB
/
returnAddenda.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package ach
// written
import (
"strings"
"time"
)
const (
timeFormat = "060102" // for date of death
)
// ReturnAddenda
type ReturnAddenda struct {
// RecordType defines the type of record in the block. entryAddendaPos 7
recordType string
// TypeCode Addenda types code '99'
TypeCode string
ReturnCode string
OriginalTrace int
DateOfDeath *time.Time
OriginalDFI string
AddendaInformation string
Trace int
// validator is composed for data validation
validator
// converters is composed for ACH to GoLang Converters
converters
}
// Parse takes the input record string and parses the ReturnAddenda values
func (returnAddenda *ReturnAddenda) Parse(record string) {
// 1-1 Always "7"
returnAddenda.recordType = "7"
// 2-3 Defines the specific explanation and format for the addenda information contained in the same record
returnAddenda.TypeCode = record[1:3]
// 4-6
returnAddenda.ReturnCode = record[3:6]
// 7-21
returnAddenda.OriginalTrace = returnAddenda.parseNumField(record[6:21])
// 22-27, might be a date or blank
result, err := time.Parse(timeFormat, strings.TrimSpace(record[21:27]))
returnAddenda.DateOfDeath = &result
if err != nil { // honestly it's best to just assume it's a blank date
returnAddenda.DateOfDeath = nil
}
// 28-35
returnAddenda.OriginalDFI = record[27:35]
// 36-79
returnAddenda.AddendaInformation = strings.TrimSpace(record[35:79])
// 80-94
returnAddenda.Trace = returnAddenda.parseNumField(record[79:94])
}
// implement later
func (returnAddenda *ReturnAddenda) Validate() error {
return nil
}
// implement later
func (returnAddenda *ReturnAddenda) convertDateOfDeath() error {
return nil
}