blob: f30b8fb27b7c193f01cb3aaf7e0810e8a0efb29e (
plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
package main
import (
"strings"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
type Camt053 struct {
Document string `xml:"Document"`
XmlNs string `xml:"xmlns,attr"`
BkToCstmrStmt Camt053BkToCstmrStmt `xml:"BkToCstmrStmt"`
}
type Camt053Acct struct {
Id Camt053Id `xml:"Id"`
}
type Camt053Amt struct {
Ccy string `xml:"Ccy,attr"`
Value float64 `xml:",chardata"`
}
type Camt053BookgDt struct {
Dt string `xml:"Dt"`
}
type Camt053BkToCstmrStmt struct {
Stmt Camt053Stmt `xml:"Stmt"`
}
type Camt053BkTxCd struct {
Domn Camt053Domn `xml:"Domn"`
Prtry Camt053Prtry `xml:"Prtry"`
}
type Camt053Cdtr struct {
Nm string `xml:"Nm"`
}
type Camt053CdtrAcct struct {
Id Camt053Id `xml:"Id"`
}
type Camt053Dbtr struct {
Nm string `xml:"Nm"`
}
type Camt053DbtrAcct struct {
Id Camt053Id `xml:"Id"`
}
type Camt053Domn struct {
Cd string `xml:"Cd"`
Fmly Camt053Fmly `xml:"Fmly"`
}
type Camt053Fmly struct {
Cd string `xml:"Cd"`
SubFmlyCd string `xml:"SubFmlyCd"`
}
type Camt053Id struct {
IBAN string `xml:"IBAN"`
}
type Camt053Ntry struct {
NtryRef string `xml:"NtryRef"`
Amt Camt053Amt `xml:"Amt"`
CdtDbtInd string `xml:"CdtDbtInd"`
BookgDt Camt053BookgDt `xml:"BookgDt"`
NtryDtls Camt053NtryDtls `xml:"NtryDtls"`
BkTxCd Camt053BkTxCd `xml:"BkTxCd"`
AddtlNtryInf string `xml:"AddtlNtryInf"`
}
type Camt053NtryDtls struct {
TxDtls Camt053TxDtls `xml:"TxDtls"`
}
type Camt053Prtry struct {
Cd string `xml:"Cd"`
Issr string `xml:"Issr"`
}
type Camt053Refs struct {
EndToEndId string `xml:"EndToEndId"`
TxId string `xml:"TxId"`
}
type Camt053RltdPties struct {
Cdtr Camt053Cdtr `xml:"Cdtr"`
CdtrAcct Camt053CdtrAcct `xml:"CdtrAcct"`
Dbtr Camt053Dbtr `xml:"Dbtr"`
DbtrAcct Camt053DbtrAcct `xml:"DbtrAcct"`
}
type Camt053Stmt struct {
Ntry []Camt053Ntry `xml:"Ntry"`
Acct Camt053Acct `xml:"Acct"`
}
type Camt053TxDtls struct {
Refs Camt053Refs `xml:"Refs"`
RltdPties Camt053RltdPties `xml:"RltdPties"`
}
// Retrieve a usable string for the description of an Ntry node
func (this *Camt053Ntry) Description(doc Camt053) string {
if this.AddtlNtryInf != "" {
return this.AddtlNtryInf
}
return "Transfer from " + this.SourceName(doc) + " to " + this.DestinationName(doc)
}
// Get the destination's IBAN if it exists, otherwise return an empty string.
func (this *Camt053Ntry) DestinationIban(doc Camt053) string {
switch this.CdtDbtInd {
case "CRDT":
switch this.BkTxCd.Domn.Fmly.Cd {
case "RCDT":
return doc.BkToCstmrStmt.Stmt.Acct.Id.IBAN
}
case "DBIT":
switch this.BkTxCd.Domn.Cd {
case "PMNT":
switch this.BkTxCd.Domn.Fmly.Cd {
case "ICDT":
return this.NtryDtls.TxDtls.RltdPties.CdtrAcct.Id.IBAN
}
}
}
return ""
}
// Get the destination's name if it exists, otherwise return an empty string.
func (this *Camt053Ntry) DestinationName(doc Camt053) string {
switch this.CdtDbtInd {
case "DBIT":
switch this.BkTxCd.Domn.Cd {
case "ACMT":
return cases.Title(language.Und).String(this.BkTxCd.Prtry.Issr)
case "PMNT":
switch this.BkTxCd.Domn.Fmly.Cd {
case "CCRD":
split := strings.SplitN(this.AddtlNtryInf, ">", 2)
tag := strings.TrimSpace(split[0])
return tag
case "ICDT":
return this.NtryDtls.TxDtls.RltdPties.Cdtr.Nm
case "RDDT":
return this.NtryDtls.TxDtls.RltdPties.Cdtr.Nm
}
}
}
return ""
}
// Get the source's IBAN if it exists, otherwise return an empty string.
func (this *Camt053Ntry) SourceIban(doc Camt053) string {
switch this.CdtDbtInd {
case "CRDT":
switch this.BkTxCd.Domn.Fmly.Cd {
case "RCDT":
return this.NtryDtls.TxDtls.RltdPties.DbtrAcct.Id.IBAN
}
case "DBIT":
return doc.BkToCstmrStmt.Stmt.Acct.Id.IBAN
}
return ""
}
// Get the source's name if it exists, otherwise return an empty string.
func (this *Camt053Ntry) SourceName(doc Camt053) string {
switch this.CdtDbtInd {
case "CRDT":
switch this.BkTxCd.Domn.Fmly.Cd {
case "RCDT":
return this.NtryDtls.TxDtls.RltdPties.Dbtr.Nm
}
}
return ""
}
func (this *Camt053Ntry) Type(doc Camt053) string {
if this.CdtDbtInd == "CRDT" {
return "deposit"
}
return "withdrawal"
}
|