camt 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,102 @@
1
+ module Camt
2
+ class Transaction
3
+
4
+ attr_reader :node, :country_code
5
+
6
+ def initialize(xml_node, country_code)
7
+ @node = xml_node
8
+ @country_code = country_code
9
+ end
10
+
11
+ def execution_date
12
+ @execution_date ||= Date.parse(node.at('./BookgDt/Dt | ./BookgDt/DtTm').text)
13
+ end
14
+
15
+ def effective_date
16
+ @effective_date ||= Date.parse(node.at('./ValDt/Dt | ./ValDt/DtTm').text)
17
+ end
18
+
19
+ def transfer_type
20
+ @transfer_type ||= get_transfer_type(node.at('./BkTxCd/Prtry'))
21
+ end
22
+
23
+ alias_method :type, :transfer_type
24
+
25
+ def transferred_amount
26
+ @transferred_amount ||= Amount.new(node).value
27
+ end
28
+
29
+ alias_method :amount, :transferred_amount
30
+
31
+ def transaction_details
32
+ @transaction_details ||= node.xpath('.//NtryDtls//TxDtls').map { |node| parse_TxDtls(node) }
33
+ end
34
+
35
+ alias_method :details, :transaction_details
36
+
37
+ def purpose
38
+ @purpose ||= node.at('./AddtlNtryInf').try(:text) ||
39
+ details.map { |detail| detail[:references] }.flatten.join(" ")
40
+ end
41
+
42
+ private
43
+
44
+ def get_transfer_type(node)
45
+ # Map properietary codes from BkTxCd/Prtry/Cd.
46
+ # :param node: BkTxCd/Prtry node
47
+ { proprietary_code: node.at('./Cd').text, proprietary_issuer: node.at('./Issr').text } if node
48
+ end
49
+
50
+ def get_party_values(node)
51
+ # Determine to get either the debtor or creditor party node
52
+ # and extract the available data from it
53
+ values = {}
54
+
55
+ party_type = node.at('../../CdtDbtInd').text == 'CRDT' ? 'Dbtr' : 'Cdtr'
56
+
57
+ party_node = node.at("./RltdPties/#{party_type}")
58
+ account_node = node.at("./RltdPties/#{party_type}Acct/Id")
59
+ bic_node = node.at("./RltdAgts/#{party_type}Agt/FinInstnId/BIC")
60
+
61
+ if party_node
62
+ values[:remote_owner] = party_node.at('./Nm').try(:text)
63
+ values[:remote_owner_country] = party_node.at('./PstlAdr/Ctry').try(:text)
64
+ values[:remote_owner_address] = party_node.at('./PstlAdr/AdrLine').try(:text)
65
+ end
66
+
67
+ if account_node
68
+ values[:remote_account] = account_node.at('./IBAN').try(:text)
69
+ values[:remote_account] ||= account_node.at('./Othr/Id').try(:text)
70
+ values[:remote_bank_bic] = bic_node.text if bic_node
71
+ end
72
+
73
+ values
74
+ end
75
+
76
+ def parse_TxDtls(node)
77
+ # Parse a single TxDtls node
78
+ transaction_details = {}
79
+
80
+ if (unstructured = node.xpath('./RmtInf/Ustrd')).any?
81
+ transaction_details[:messages] = unstructured.map(&:text)
82
+ end
83
+
84
+ if (structured = node.xpath('./RmtInf/Strd/CdtrRefInf/Ref | ./Refs/EndToEndId')).any?
85
+ transaction_details[:references] = structured.map(&:text)
86
+ end
87
+
88
+ if mandate_identifier = node.at('./Refs/MndtId').try(:text)
89
+ transaction_details[:mandate_identifier] = mandate_identifier
90
+ end
91
+
92
+ if reason = node.at('./RtrInf/Rsn/Cd').try(:text)
93
+ reason_language = Camt::Reasons.keys.include?(country_code) ? country_code : 'EN'
94
+ transaction_details[:reason] = { code: reason, description: Camt::Reasons[reason_language][reason] }
95
+ end
96
+
97
+ transaction_details[:party] = get_party_values node
98
+
99
+ transaction_details
100
+ end
101
+ end
102
+ end
@@ -1,3 +1,3 @@
1
1
  module Camt
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,43 @@
1
+ RSpec.describe Camt::Amount do
2
+
3
+ let(:value) { 1337.23 }
4
+ let(:currency) { "GBP" }
5
+ let(:credit_debit_type) { "CRDT"}
6
+
7
+ let :xml_node do
8
+ Nokogiri::XML::Builder.new { |xml|
9
+ xml.root do
10
+ xml.Amt(value, :Ccy => currency)
11
+ xml.CdtDbtInd(credit_debit_type)
12
+ end
13
+ }.doc.at("./root")
14
+ end
15
+
16
+ subject { described_class.new(xml_node) }
17
+
18
+ describe "#value" do
19
+ context "when amount is positive" do
20
+ it "returns the correct value" do
21
+ expect(subject.value).to eq value
22
+ end
23
+ end
24
+
25
+ context "when amount is negative" do
26
+ let(:credit_debit_type) { "DBIT"}
27
+
28
+ it "returns the correct value" do
29
+ expect(subject.value).to eq(0 - value)
30
+ end
31
+ end
32
+
33
+ it "is returned as a BigDecimal" do
34
+ expect(subject.value).to be_a BigDecimal
35
+ end
36
+ end
37
+
38
+ describe "#currency" do
39
+ it "returns the currency" do
40
+ expect(subject.currency).to eq currency
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,91 @@
1
+ RSpec.describe Camt::File do
2
+
3
+ let(:filename) { "camt.xml" }
4
+
5
+ subject { Camt::File.parse(::File.expand_path("../sample_files/" << filename, __FILE__)) }
6
+
7
+ it "has any messages" do
8
+ expect(subject.messages).to be_any
9
+ end
10
+
11
+ it "has any statements" do
12
+ expect(subject.statements).to be_any
13
+ end
14
+
15
+ it "has any transactions" do
16
+ expect(subject.transactions).to be_any
17
+ end
18
+
19
+ describe "valid?" do
20
+ context "when document has no error" do
21
+ it "returns true" do
22
+ expect(subject.valid?).to be true
23
+ end
24
+ end
25
+
26
+ context "when document has an error" do
27
+ let(:filename) { "camt_error.xml" }
28
+
29
+ it "returns false" do
30
+ expect(subject.valid?).to be false
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "errors" do
36
+ context "when document has no error" do
37
+ it "returns an empty array" do
38
+ expect(subject.errors).to eq []
39
+ end
40
+ end
41
+
42
+ context "when document has an error" do
43
+ let(:filename) { "camt_error.xml" }
44
+
45
+ it "returns the XML errors" do
46
+ expect(subject.errors.size).to eq 9
47
+ end
48
+ end
49
+
50
+ context "when document isn't even XML" do
51
+ let(:filename) { "../spec_helper.rb" }
52
+
53
+ it "returns the XML errors" do
54
+ expect(subject.errors.size).to eq 1
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "configuration" do
60
+ context "when a default country code is set" do
61
+ it "uses the default country code" do
62
+ expect(subject.country_code).to eq "XY"
63
+ end
64
+
65
+ it "does not raise an error" do
66
+ expect { subject }.not_to raise_error
67
+ end
68
+ end
69
+
70
+ context "when no default country code is set" do
71
+ around do |example|
72
+ current_country_code = nil
73
+
74
+ Camt.configure do |config|
75
+ current_country_code = config.default_country_code
76
+ config.default_country_code = nil
77
+ end
78
+
79
+ example.run
80
+
81
+ Camt.configure do |config|
82
+ config.default_country_code = current_country_code
83
+ end
84
+ end
85
+
86
+ it "raises an ArgumentError" do
87
+ expect { subject }.to raise_error(ArgumentError)
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,441 @@
1
+ require_relative "../support/camt.053_integration"
2
+
3
+ RSpec.describe "camt.xml" do
4
+
5
+ let(:expected_id) { "0574908765.2013-04-02" }
6
+ let(:expected_electronic_sequence_number) { "0070" }
7
+ let(:expected_creation_time) { "2013-04-12T10:55:08.66+02:00" }
8
+ let(:expected_iban) { "NL77ABNA0574908765" }
9
+ let(:expected_currency) { "EUR" }
10
+ let(:expected_date) { "2013-04-02" }
11
+ let(:expected_start_balance) { 1000.01 }
12
+ let(:expected_end_balance) { 100.01 }
13
+
14
+ let :expected_transactions do
15
+ [
16
+ {
17
+ ex_date: "2013-04-02",
18
+ eff_date: "2013-04-02",
19
+ type: {proprietary_code: "N196", proprietary_issuer: "ABNAMRO"},
20
+ amount: 1.0,
21
+ details: [],
22
+ purpose: "11.11.111.111 Naam Adres 7 2960 Dorp"
23
+ },
24
+ {
25
+ ex_date: "2013-04-02",
26
+ eff_date: "2013-04-02",
27
+ type: {proprietary_code: "N654", proprietary_issuer: "ABNAMRO"},
28
+ amount: 1.0,
29
+ details: [
30
+ {
31
+ messages: ["OMSCHRIJVING"],
32
+ references: ["NOTPROVIDED"],
33
+ party: {
34
+ remote_owner: "NAAM",
35
+ remote_owner_country: nil,
36
+ remote_owner_address: nil,
37
+ remote_account: "NL46ABNA0499998748",
38
+ remote_bank_bic: "ABNANL2A"
39
+ }
40
+ }
41
+ ],
42
+ purpose: "/TRTP/SEPA OVERBOEKING/IBAN/NL46ABNA0499998748/BIC/" \
43
+ "ABNANL2A/NAME/NAAM/REMI/OMSCHRIJVING/EREF/NOTPROVIDED"
44
+ },
45
+ {
46
+ ex_date: "2013-04-02",
47
+ eff_date: "2013-04-02",
48
+ type: {proprietary_code: "N946", proprietary_issuer: "ABNAMRO"},
49
+ amount: 1.0,
50
+ details: [
51
+ {
52
+ references: ["NOTPROVIDED", "1234567812345678"],
53
+ party: {
54
+ remote_owner: "NAAM",
55
+ remote_owner_country: nil,
56
+ remote_owner_address: nil,
57
+ remote_account: "NL46ABNA0499998748",
58
+ remote_bank_bic: "ABNANL2A"
59
+ }
60
+ }
61
+ ],
62
+ purpose: "/TRTP/SEPA ACCEPTGIRO/IBAN/NL46ABNA0499998748/BIC/" \
63
+ "ABNANL2A/NAME/NAAM/REMI//REMI/Issuer: CUR Ref: 1234567812345678/EREF/NOTPROVIDED"
64
+ },
65
+ {
66
+ ex_date: "2013-04-02",
67
+ eff_date: "2013-04-02",
68
+ type: {proprietary_code: "N946", proprietary_issuer: "ABNAMRO"},
69
+ amount: 10.0,
70
+ details: [
71
+ {
72
+ references: ["NOTPROVIDED", "1234567812345678"],
73
+ party: {
74
+ remote_owner: "NAAM",
75
+ remote_owner_country: nil,
76
+ remote_owner_address: nil,
77
+ remote_account: "NL46ABNA0499998748",
78
+ remote_bank_bic: "ABNANL2A"}
79
+ },
80
+ {
81
+ references: ["NOTPROVIDED", "1234567812345678"],
82
+ party: {
83
+ remote_owner: "NAAM",
84
+ remote_owner_country: nil,
85
+ remote_owner_address: nil,
86
+ remote_account: "NL46ABNA0499998748",
87
+ remote_bank_bic: "ABNANL2A"
88
+ }
89
+ },
90
+ {
91
+ references: ["NOTPROVIDED", "1234567812345678"],
92
+ party: {
93
+ remote_owner: "NAAM",
94
+ remote_owner_country: nil,
95
+ remote_owner_address: nil,
96
+ remote_account: "NL46ABNA0401378749",
97
+ remote_bank_bic: "ABNANL2A"
98
+ }
99
+ },
100
+ {
101
+ references: ["NOTPROVIDED", "1234567812345678"],
102
+ party: {
103
+ remote_owner: "NAAM",
104
+ remote_owner_country: nil,
105
+ remote_owner_address: nil,
106
+ remote_account: "NL46ABNA0401378749",
107
+ remote_bank_bic: "ABNANL2A"
108
+ }
109
+ },
110
+ {
111
+ references: ["NOTPROVIDED", "1234567812345678"],
112
+ party: {
113
+ remote_owner: "NAAM",
114
+ remote_owner_country: nil,
115
+ remote_owner_address: nil,
116
+ remote_account: "NL46ABNA0401378749",
117
+ remote_bank_bic: "ABNANL2A"
118
+ }
119
+ },
120
+ {
121
+ references: ["NOTPROVIDED", "1234567812345678"],
122
+ party: {
123
+ remote_owner: "NAAM",
124
+ remote_owner_country: nil,
125
+ remote_owner_address: nil,
126
+ remote_account: "NL46ABNA0401378749",
127
+ remote_bank_bic: "ABNANL2A"
128
+ }
129
+ },
130
+ {
131
+ references: ["NOTPROVIDED", "1234567812345678"],
132
+ party: {
133
+ remote_owner: "NAAM",
134
+ remote_owner_country: nil,
135
+ remote_owner_address: nil,
136
+ remote_account: "NL46ABNA0401378749",
137
+ remote_bank_bic: "ABNANL2A"
138
+ }
139
+ },
140
+ {
141
+ references: ["NOTPROVIDED", "1234567812345678"],
142
+ party: {
143
+ remote_owner: "NAAM",
144
+ remote_owner_country: nil,
145
+ remote_owner_address: nil,
146
+ remote_account: "NL46ABNA0401378749",
147
+ remote_bank_bic: "ABNANL2A"
148
+ }
149
+ },
150
+ {
151
+ references: ["NOTPROVIDED", "1234567812345678"],
152
+ party: {
153
+ remote_owner: "NAAM",
154
+ remote_owner_country: nil,
155
+ remote_owner_address: nil,
156
+ remote_account: "NL46ABNA0401378749",
157
+ remote_bank_bic: "ABNANL2A"
158
+ }
159
+ },
160
+ {
161
+ references: ["NOTPROVIDED", "1234567812345678"],
162
+ party: {
163
+ remote_owner: "NAAM",
164
+ remote_owner_country: nil,
165
+ remote_owner_address: nil,
166
+ remote_account: "NL46ABNA0401378749",
167
+ remote_bank_bic: "ABNANL2A"
168
+ }
169
+ }
170
+ ],
171
+ purpose: "/TRTP/SEPA ACCEPTGIRO BATCH/PREF/3095D4322561460S0PS/NRTX/10"
172
+ },
173
+ {
174
+ ex_date: "2013-04-02",
175
+ eff_date: "2013-04-02",
176
+ type: {proprietary_code: "N944", proprietary_issuer: "ABNAMRO"},
177
+ amount: 1.0,
178
+ details: [
179
+ {
180
+ messages: ["2305271368 0050001248302363 pid2305271368t Mud Masters Mud Masters"],
181
+ references: ["01-04-2013 21:01 0050001248302363"],
182
+ party: {
183
+ remote_owner: "ING Bank",
184
+ remote_owner_country: nil,
185
+ remote_owner_address: nil,
186
+ remote_account: "NL21INGB0000773837",
187
+ remote_bank_bic: "INGBNL2A"
188
+ }
189
+ }
190
+ ],
191
+ purpose: "/TRTP/SEPA OVERBOEKING/IBAN/NL21INGB0000773837/BIC/INGBNL2A/NAME/ING Bank/" \
192
+ "REMI/2305271368 0050001248302363 pid2305271368t/EREF/01-04-2013 21:01 0050001248302363"
193
+ },
194
+ {
195
+ ex_date: "2013-04-02",
196
+ eff_date: "2013-04-02",
197
+ type: {proprietary_code: "N658", proprietary_issuer: "ABNAMRO"},
198
+ amount: -1.0,
199
+ details: [
200
+ {
201
+ messages: ["2013-33"],
202
+ references: ["NOTPROVIDED"],
203
+ party: {
204
+ remote_owner: "Naam",
205
+ remote_owner_country: "NL",
206
+ remote_owner_address: nil,
207
+ remote_account: "NL87SNSB0941352955",
208
+ remote_bank_bic: "SNSBNL2A"
209
+ }
210
+ }
211
+ ],
212
+ purpose: "/TRTP/SEPA OVERBOEKING/IBAN/NL87SNSB0941352955/BIC/" \
213
+ "SNSBNL2A/NAME/Naam/REMI/2013-33/EREF/NOTPROVIDED"
214
+ },
215
+ {
216
+ ex_date: "2013-04-02",
217
+ eff_date: "2013-04-02",
218
+ type: {proprietary_code: "N655", proprietary_issuer: "ABNAMRO"},
219
+ amount: -2.0,
220
+ details: [
221
+ {
222
+ messages: ["2013-33"],
223
+ references: ["NOTPROVIDED"],
224
+ party: {
225
+ remote_owner: "Naam",
226
+ remote_owner_country: "NL",
227
+ remote_owner_address: nil,
228
+ remote_account: "NL87SNSB0941352955",
229
+ remote_bank_bic: "SNSBNL2A"
230
+ }
231
+ },
232
+ {
233
+ messages: ["2013-33"],
234
+ references: ["NOTPROVIDED"],
235
+ party: {
236
+ remote_owner: "Naam",
237
+ remote_owner_country: "NL",
238
+ remote_owner_address: nil,
239
+ remote_account: "NL87SNSB0941352955",
240
+ remote_bank_bic: "SNSBNL2A"
241
+ }
242
+ }
243
+ ],
244
+ purpose: "/TRTP/SEPA BATCH/PREF/1202P5518750499B0AO/NRTX/2"
245
+ },
246
+ {
247
+ ex_date: "2013-04-02",
248
+ eff_date: "2013-04-02",
249
+ type: {proprietary_code: "N652", proprietary_issuer: "ABNAMRO"},
250
+ amount: -2.0,
251
+ details: [],
252
+ purpose: "/TRTP/SEPA BATCH SALARIS/PREF/1302P5518750499B0AO/NRTX/2"
253
+ },
254
+ {
255
+ ex_date: "2013-04-02",
256
+ eff_date: "2013-04-02",
257
+ type: {proprietary_code: "N248", proprietary_issuer: "ABNAMRO"},
258
+ amount: -1.0,
259
+ details: [
260
+ {
261
+ messages: ["REF 2202389041/ 708723862112/ 5401939189"],
262
+ references: ["540193918971"],
263
+ mandate_identifier: "N000001861650",
264
+ party: {
265
+ remote_owner: "Naam/SA",
266
+ remote_owner_country: "BE",
267
+ remote_owner_address: "Straat 34",
268
+ remote_account: "BE21319980275903",
269
+ remote_bank_bic: "BBRUBEBB"
270
+ }
271
+ }
272
+ ],
273
+ purpose: "/TRTP/SEPA Incasso algemeen doorlopend/CSID/BE57XC00476306127/NAME/Naam/SA/MARF/N000001861650/" \
274
+ "REMI/REF 2202389041/ 708723862112/ 5401939189/IBAN/BE21319980275903/BIC/BBRUBEBB/EREF/540193918971"
275
+ },
276
+ {
277
+ ex_date: "2012-04-02",
278
+ eff_date: "2012-04-02",
279
+ type: {proprietary_code: "N247", proprietary_issuer: "ABNAMRO"},
280
+ amount: 7.0,
281
+ details: [
282
+ {
283
+ messages: ["SIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI " \
284
+ "NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSIT"],
285
+ references: ["SDD SIT 024-1"],
286
+ mandate_identifier: "mandateref24-1",
287
+ party: {
288
+ remote_owner: "R12 SDD SIT2",
289
+ remote_owner_country: "NL",
290
+ remote_owner_address: "R12 SDD SIT2",
291
+ remote_account: "NL27ABNA0562326340",
292
+ remote_bank_bic: "ABNANL2A"
293
+ }
294
+ },
295
+ {
296
+ messages: ["SIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI " \
297
+ "NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSIT"],
298
+ references: ["SDD SIT 024-2"],
299
+ mandate_identifier: "mandateref24-2",
300
+ party: {
301
+ remote_owner: "R12 SDD SIT2",
302
+ remote_owner_country: "NL",
303
+ remote_owner_address: "R12 SDD SIT2",
304
+ remote_account: "NL27ABNA0562326340",
305
+ remote_bank_bic: "ABNANL2A"
306
+ }
307
+ },
308
+ {
309
+ messages: ["SIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI " \
310
+ "NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSIT"],
311
+ references: ["SDD SIT 024-3"],
312
+ mandate_identifier: "mandateref24-3",
313
+ party: {
314
+ remote_owner: "R12 SDD SIT2",
315
+ remote_owner_country: "NL",
316
+ remote_owner_address: "R12 SDD SIT2",
317
+ remote_account: "NL27ABNA0562326340",
318
+ remote_bank_bic: "ABNANL2A"
319
+ }
320
+ },
321
+ {
322
+ messages: ["SIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI " \
323
+ "NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSIT"],
324
+ references: ["SDD SIT 024-4"],
325
+ mandate_identifier: "mandateref24-4",
326
+ party: {
327
+ remote_owner: "R12 SDD SIT2",
328
+ remote_owner_country: "NL",
329
+ remote_owner_address: "R12 SDD SIT2",
330
+ remote_account: "NL27ABNA0562326340",
331
+ remote_bank_bic: "ABNANL2A"
332
+ }
333
+ },
334
+ {
335
+ messages: ["SIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI " \
336
+ "NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSIT"],
337
+ references: ["SDD SIT 024-5"],
338
+ mandate_identifier: "mandateref24-5",
339
+ party: {
340
+ remote_owner: "R12 SDD SIT2",
341
+ remote_owner_country: "NL",
342
+ remote_owner_address: "R12 SDD SIT2",
343
+ remote_account: "NL27ABNA0562326340",
344
+ remote_bank_bic: "ABNANL2A"
345
+ }
346
+ },
347
+ {
348
+ messages: ["SIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI " \
349
+ "NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSIT"],
350
+ references: ["SDD SIT 024-6"],
351
+ mandate_identifier: "mandateref24-6",
352
+ party: {
353
+ remote_owner: "R12 SDD SIT2",
354
+ remote_owner_country: "NL",
355
+ remote_owner_address: "R12 SDD SIT2",
356
+ remote_account: "NL27ABNA0562326340",
357
+ remote_bank_bic: "ABNANL2A"
358
+ }
359
+ },
360
+ {
361
+ messages: ["SIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSITSIT DRIVER LI " \
362
+ "NOSIT DRIVER LI NOSITSIT DRIVER LI NOSIT DRIVER LI NOSIT"],
363
+ references: ["SDD SIT 024-7"],
364
+ mandate_identifier: "mandateref24-7",
365
+ party: {
366
+ remote_owner: "R12 SDD SIT2",
367
+ remote_owner_country: "NL",
368
+ remote_owner_address: "R12 SDD SIT2",
369
+ remote_account: "NL27ABNA0562326340",
370
+ remote_bank_bic: "ABNANL2A"
371
+ }
372
+ }
373
+ ],
374
+ purpose: "/TRTP/SEPA Incasso batch/PREF/BATCHID/NRTX/7/PIND/BRUTO"
375
+ },
376
+ {
377
+ ex_date: "2012-04-02",
378
+ eff_date: "2012-04-02",
379
+ type: {proprietary_code: "N247", proprietary_issuer: "ABNAMRO"},
380
+ amount: 7.0,
381
+ details: [],
382
+ purpose: "/TRTP/SEPA Incasso batch/PREF/BATCHID/NRTX/7/PIND/BRUTO"
383
+ },
384
+ {
385
+ ex_date: "2012-04-02",
386
+ eff_date: "2012-04-02",
387
+ type: {proprietary_code: "N246", proprietary_issuer: "ABNAMRO"},
388
+ amount: -1.0,
389
+ details: [
390
+ {
391
+ messages: ["Levering maand mei, zie nota 1234556. Uw klantnummer 123455666"],
392
+ references: ["1234567X908303803"],
393
+ mandate_identifier: "123456789XXmandaat",
394
+ reason: {
395
+ code: "MS03",
396
+ description: "Reason not specified"
397
+ },
398
+ party: {
399
+ remote_owner: "Debtor",
400
+ remote_owner_country: "NL",
401
+ remote_owner_address: "R12 SDD SIT2",
402
+ remote_account: "NL27ABNA0562326340",
403
+ remote_bank_bic: "ABNANL2A"
404
+ }
405
+ }
406
+ ],
407
+ purpose: "/RTYP/SEPA Incasso niet uitgevoerd/MARF/123456789XXmandaat/RTRN/MS03/IBAN/NL27ABNA0562399340/" \
408
+ "NAME/Debtor/REMI/Levering maand mei, zie nota 1234556. Uw klantnummer 123455666/EREF/1234567X908303803"
409
+ },
410
+ {
411
+ ex_date: "2012-04-02",
412
+ eff_date: "2012-04-02",
413
+ type: {proprietary_code: "N245", proprietary_issuer: "ABNAMRO"},
414
+ amount: -921.0,
415
+ details: [
416
+ {
417
+ messages: ["Levering maand mei, zie nota 1234557. Uw klantnummer 123455666"],
418
+ references: ["1234567X908303804"],
419
+ mandate_identifier: "123456788XXmandaat",
420
+ reason: {
421
+ code: "MS03",
422
+ description: "Reason not specified"
423
+ },
424
+ party: {
425
+ remote_owner: "Debtor",
426
+ remote_owner_country: "NL",
427
+ remote_owner_address: "R12 SDD SIT2",
428
+ remote_account: "NL27ABNA0592326340",
429
+ remote_bank_bic: "ABNANL2A"
430
+ }
431
+ }
432
+ ],
433
+ purpose: "/RTYP/SEPA Incasso terugboeking bank/MARF/123456788XXmandaat/RTRN/MS03/IBAN/NL27ABNA0592326340/" \
434
+ "NAME/Debtor/REMI/Levering maand mei, zie nota 1234557. Uw klantnummer 123455666/EREF/1234567X908303804"
435
+ }
436
+ ]
437
+ end
438
+
439
+ it_behaves_like "any CAMT.053 file"
440
+
441
+ end