sps_king 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +3 -3
- data/CHANGELOG.md +9 -0
- data/README.md +17 -14
- data/gemfiles/{Gemfile-activemodel-6.1.x → Gemfile-activemodel-7.2.x} +1 -1
- data/gemfiles/{Gemfile-activemodel-7.0.x → Gemfile-activemodel-8.0.x} +1 -1
- data/lib/sps_king/account/address.rb +55 -0
- data/lib/sps_king/account/creditor_account.rb +3 -0
- data/lib/sps_king/account/creditor_address.rb +2 -34
- data/lib/sps_king/account/debtor_account.rb +1 -0
- data/lib/sps_king/account/debtor_address.rb +2 -31
- data/lib/sps_king/account.rb +3 -0
- data/lib/sps_king/converter.rb +14 -10
- data/lib/sps_king/message/credit_transfer.rb +114 -111
- data/lib/sps_king/message/direct_debit.rb +121 -118
- data/lib/sps_king/message.rb +54 -48
- data/lib/sps_king/structured_remittance_information.rb +2 -0
- data/lib/sps_king/transaction/credit_transfer_transaction.rb +3 -0
- data/lib/sps_king/transaction/direct_debit_transaction.rb +9 -6
- data/lib/sps_king/transaction.rb +10 -7
- data/lib/sps_king/validator.rb +9 -0
- data/lib/sps_king/version.rb +3 -1
- data/lib/sps_king.rb +1 -0
- data/spec/lib/sps_king/account/address_spec.rb +85 -0
- data/spec/lib/sps_king/account/creditor_account_spec.rb +14 -13
- data/spec/lib/sps_king/account/debtor_account_spec.rb +1 -0
- data/spec/lib/sps_king/account_spec.rb +12 -2
- data/spec/lib/sps_king/converter_spec.rb +25 -5
- data/spec/lib/sps_king/message/credit_transfer_spec.rb +184 -45
- data/spec/lib/sps_king/message/direct_debit_spec.rb +218 -102
- data/spec/lib/sps_king/message_spec.rb +23 -8
- data/spec/lib/sps_king/structured_remittance_information_spec.rb +7 -2
- data/spec/lib/sps_king/transaction/credit_transfer_transaction_spec.rb +14 -2
- data/spec/lib/sps_king/transaction/direct_debit_transaction_spec.rb +8 -7
- data/spec/lib/sps_king/transaction_spec.rb +62 -27
- data/spec/lib/sps_king/validator_spec.rb +38 -9
- data/spec/spec_helper.rb +8 -4
- data/spec/support/active_model.rb +3 -1
- data/spec/support/factories.rb +11 -10
- data/spec/support/validations.rb +2 -0
- data/sps_king.gemspec +1 -0
- metadata +8 -12
- data/spec/lib/sps_king/account/creditor_address_spec.rb +0 -14
- data/spec/lib/sps_king/account/debtor_address_spec.rb +0 -14
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
describe SPS::DirectDebit do
|
@@ -45,7 +46,12 @@ describe SPS::DirectDebit do
|
|
45
46
|
|
46
47
|
it 'returns the id of the batch where the given transactions belongs to (2 batches)' do
|
47
48
|
direct_debit.add_transaction(direct_debt_transaction(reference: "EXAMPLE REFERENCE 1"))
|
48
|
-
direct_debit.add_transaction(
|
49
|
+
direct_debit.add_transaction(
|
50
|
+
direct_debt_transaction(
|
51
|
+
reference: "EXAMPLE REFERENCE 2",
|
52
|
+
requested_date: Date.today.next.next
|
53
|
+
)
|
54
|
+
)
|
49
55
|
direct_debit.add_transaction(direct_debt_transaction(reference: "EXAMPLE REFERENCE 3"))
|
50
56
|
|
51
57
|
expect(direct_debit.batch_id("EXAMPLE REFERENCE 1")).to match(/#{message_id_regex}\/1/)
|
@@ -57,7 +63,12 @@ describe SPS::DirectDebit do
|
|
57
63
|
describe :batches do
|
58
64
|
it 'returns an array of batch ids in the sepa message' do
|
59
65
|
direct_debit.add_transaction(direct_debt_transaction(reference: "EXAMPLE REFERENCE 1"))
|
60
|
-
direct_debit.add_transaction(
|
66
|
+
direct_debit.add_transaction(
|
67
|
+
direct_debt_transaction(
|
68
|
+
reference: "EXAMPLE REFERENCE 2",
|
69
|
+
requested_date: Date.today.next.next
|
70
|
+
)
|
71
|
+
)
|
61
72
|
direct_debit.add_transaction(direct_debt_transaction(reference: "EXAMPLE REFERENCE 3"))
|
62
73
|
|
63
74
|
expect(direct_debit.batches.size).to eq(2)
|
@@ -78,25 +89,25 @@ describe SPS::DirectDebit do
|
|
78
89
|
context 'setting debtor address with adrline' do
|
79
90
|
subject do
|
80
91
|
sdd = SPS::DirectDebit.new(
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
92
|
+
name: 'Gläubiger GmbH',
|
93
|
+
iban: 'CH7081232000001998736',
|
94
|
+
creditor_identifier: 'ABC1W'
|
95
|
+
)
|
85
96
|
|
86
97
|
sda = SPS::DebtorAddress.new(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
98
|
+
country_code: 'CH',
|
99
|
+
address_line1: 'Mustergasse 123',
|
100
|
+
address_line2: '1234 Musterstadt'
|
101
|
+
)
|
91
102
|
|
92
103
|
sdd.add_transaction(
|
93
|
-
name:
|
94
|
-
iban:
|
95
|
-
amount:
|
96
|
-
instruction:
|
97
|
-
reference:
|
98
|
-
remittance_information:
|
99
|
-
debtor_address:
|
104
|
+
name: 'Zahlemann & Söhne GbR',
|
105
|
+
iban: 'CH9804835011062385295',
|
106
|
+
amount: 39.99,
|
107
|
+
instruction: '12',
|
108
|
+
reference: 'XYZ/2013-08-ABO/12345',
|
109
|
+
remittance_information: 'Unsere Rechnung vom 10.08.2013',
|
110
|
+
debtor_address: sda,
|
100
111
|
structured_remittance_information: structured_remittance_information
|
101
112
|
)
|
102
113
|
|
@@ -112,26 +123,26 @@ describe SPS::DirectDebit do
|
|
112
123
|
context 'setting debtor address with structured fields' do
|
113
124
|
subject do
|
114
125
|
sdd = SPS::DirectDebit.new(
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
126
|
+
name: 'Gläubiger GmbH',
|
127
|
+
iban: 'CH7081232000001998736',
|
128
|
+
creditor_identifier: 'ABC1W'
|
129
|
+
)
|
119
130
|
|
120
131
|
sda = SPS::DebtorAddress.new(
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
132
|
+
country_code: 'CH',
|
133
|
+
street_name: 'Mustergasse 123',
|
134
|
+
post_code: '1234',
|
135
|
+
town_name: 'Musterstadt'
|
136
|
+
)
|
126
137
|
|
127
138
|
sdd.add_transaction(
|
128
|
-
name:
|
129
|
-
iban:
|
130
|
-
amount:
|
131
|
-
instruction:
|
132
|
-
reference:
|
133
|
-
remittance_information:
|
134
|
-
debtor_address:
|
139
|
+
name: 'Zahlemann & Söhne GbR',
|
140
|
+
iban: 'CH9804835011062385295',
|
141
|
+
amount: 39.99,
|
142
|
+
instruction: '12',
|
143
|
+
reference: 'XYZ/2013-08-ABO/12345',
|
144
|
+
remittance_information: 'Unsere Rechnung vom 10.08.2013',
|
145
|
+
debtor_address: sda,
|
135
146
|
structured_remittance_information: structured_remittance_information
|
136
147
|
)
|
137
148
|
|
@@ -151,35 +162,35 @@ describe SPS::DirectDebit do
|
|
151
162
|
|
152
163
|
let(:direct_debit) do
|
153
164
|
sdd = SPS::DirectDebit.new(
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
165
|
+
name: 'Muster AG',
|
166
|
+
isr_participant_number: '010001456',
|
167
|
+
iban: creditor_iban,
|
168
|
+
creditor_identifier: 'ABC1W'
|
169
|
+
)
|
159
170
|
|
160
171
|
sda = SPS::DebtorAddress.new(
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
172
|
+
country_code: 'CH',
|
173
|
+
address_line1: 'Mustergasse 123',
|
174
|
+
address_line2: '1234 Musterstadt'
|
175
|
+
)
|
165
176
|
|
166
177
|
sdd.add_transaction(
|
167
178
|
{
|
168
|
-
name:
|
169
|
-
iban:
|
170
|
-
currency:
|
171
|
-
amount:
|
172
|
-
remittance_information:
|
173
|
-
reference:
|
174
|
-
service_level:
|
175
|
-
local_instrument:
|
176
|
-
requested_date:
|
177
|
-
instruction:
|
178
|
-
debtor_address:
|
179
|
+
name: 'HANS TESTER',
|
180
|
+
iban: debtior_iban,
|
181
|
+
currency: 'CHF',
|
182
|
+
amount: '100.0',
|
183
|
+
remittance_information: 'According to invoice 4712',
|
184
|
+
reference: 'XYZ/2013-08-ABO/12345',
|
185
|
+
service_level: service_level,
|
186
|
+
local_instrument: local_instrument,
|
187
|
+
requested_date: requested_date,
|
188
|
+
instruction: 23,
|
189
|
+
debtor_address: sda,
|
179
190
|
structured_remittance_information: SPS::StructuredRemittanceInformation.new(
|
180
|
-
|
181
|
-
|
182
|
-
|
191
|
+
proprietary: 'ESR',
|
192
|
+
reference: '185744810000000000200800628'
|
193
|
+
)
|
183
194
|
}.merge(additional_fields)
|
184
195
|
)
|
185
196
|
|
@@ -199,15 +210,23 @@ describe SPS::DirectDebit do
|
|
199
210
|
end
|
200
211
|
|
201
212
|
it 'should have creditor identifier' do
|
202
|
-
expect(subject).to have_xml(
|
213
|
+
expect(subject).to have_xml(
|
214
|
+
'//Document/CstmrDrctDbtInitn/GrpHdr/InitgPty/Id/OrgId/Othr/Id', direct_debit.account.creditor_identifier
|
215
|
+
)
|
203
216
|
end
|
204
217
|
|
205
218
|
it 'should contain <PmtInfId>' do
|
206
|
-
expect(subject).to have_xml(
|
219
|
+
expect(subject).to have_xml(
|
220
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/PmtInfId',
|
221
|
+
/#{message_id_regex}\/1/
|
222
|
+
)
|
207
223
|
end
|
208
224
|
|
209
225
|
it 'should contain <ReqdColltnDt>' do
|
210
|
-
expect(subject).to have_xml(
|
226
|
+
expect(subject).to have_xml(
|
227
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/ReqdColltnDt',
|
228
|
+
requested_date.iso8601
|
229
|
+
)
|
211
230
|
end
|
212
231
|
|
213
232
|
it 'should contain <PmtMtd>' do
|
@@ -231,12 +250,19 @@ describe SPS::DirectDebit do
|
|
231
250
|
end
|
232
251
|
|
233
252
|
it 'should contain <CdtrAcct>' do
|
234
|
-
expect(subject).to have_xml(
|
253
|
+
expect(subject).to have_xml(
|
254
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/CdtrAcct/Id/IBAN',
|
255
|
+
'CH7081232000001998736'
|
256
|
+
)
|
235
257
|
end
|
236
258
|
|
237
259
|
it 'should contain <CdtrAgt>' do
|
238
|
-
expect(subject).to have_xml(
|
239
|
-
|
260
|
+
expect(subject).to have_xml(
|
261
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/CdtrAgt/FinInstnId/ClrSysMmbId/MmbId', '81232'
|
262
|
+
)
|
263
|
+
expect(subject).to have_xml(
|
264
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/CdtrAgt/FinInstnId/Othr/Id', '010001456'
|
265
|
+
)
|
240
266
|
end
|
241
267
|
|
242
268
|
it 'should not contain <ChrgBr>' do
|
@@ -245,8 +271,12 @@ describe SPS::DirectDebit do
|
|
245
271
|
|
246
272
|
context 'when service_level is CHTA' do
|
247
273
|
it 'should contain <CdtrSchmeId>' do
|
248
|
-
expect(subject).to have_xml(
|
249
|
-
|
274
|
+
expect(subject).to have_xml(
|
275
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/CdtrSchmeId/Id/PrvtId/Othr/Id', direct_debit.account.creditor_identifier
|
276
|
+
)
|
277
|
+
expect(subject).to have_xml(
|
278
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/CdtrSchmeId/Id/PrvtId/Othr/SchmeNm/Prtry', 'CHLS'
|
279
|
+
)
|
250
280
|
end
|
251
281
|
end
|
252
282
|
|
@@ -255,43 +285,63 @@ describe SPS::DirectDebit do
|
|
255
285
|
let(:local_instrument) { 'DDCOR1' }
|
256
286
|
|
257
287
|
it 'should contain <CdtrSchmeId>' do
|
258
|
-
expect(subject).to have_xml(
|
259
|
-
|
288
|
+
expect(subject).to have_xml(
|
289
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/CdtrSchmeId/Id/PrvtId/Othr/Id', direct_debit.account.creditor_identifier
|
290
|
+
)
|
291
|
+
expect(subject).to have_xml(
|
292
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/CdtrSchmeId/Id/PrvtId/Othr/SchmeNm/Prtry', 'CHDD'
|
293
|
+
)
|
260
294
|
end
|
261
295
|
end
|
262
296
|
|
263
297
|
it 'should contain <EndToEndId>' do
|
264
|
-
expect(subject).to have_xml(
|
298
|
+
expect(subject).to have_xml(
|
299
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/PmtId/EndToEndId', 'XYZ/2013-08-ABO/12345'
|
300
|
+
)
|
265
301
|
end
|
266
302
|
|
267
303
|
it 'should contain <InstdAmt>' do
|
268
|
-
expect(subject).to have_xml(
|
304
|
+
expect(subject).to have_xml(
|
305
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/InstdAmt', '100.00'
|
306
|
+
)
|
269
307
|
end
|
270
308
|
|
271
309
|
it 'should contain <DbtrAgt>' do
|
272
|
-
expect(subject).to have_xml(
|
310
|
+
expect(subject).to have_xml(
|
311
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAgt/FinInstnId/ClrSysMmbId/MmbId', '4835'
|
312
|
+
)
|
273
313
|
end
|
274
314
|
|
275
315
|
it 'should contain <Dbtr>' do
|
276
|
-
expect(subject).to have_xml(
|
316
|
+
expect(subject).to have_xml(
|
317
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/Dbtr/Nm', 'HANS TESTER'
|
318
|
+
)
|
277
319
|
end
|
278
320
|
|
279
321
|
it 'should contain <DbtrAcct>' do
|
280
|
-
expect(subject).to have_xml(
|
322
|
+
expect(subject).to have_xml(
|
323
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/DbtrAcct/Id/IBAN', 'CH9804835011062385295'
|
324
|
+
)
|
281
325
|
end
|
282
326
|
|
283
327
|
it 'should contain <Ustrd>' do
|
284
|
-
expect(subject).to have_xml(
|
328
|
+
expect(subject).to have_xml(
|
329
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/RmtInf/Ustrd', 'According to invoice 4712'
|
330
|
+
)
|
285
331
|
end
|
286
332
|
|
287
333
|
it 'should contain <Strd>' do
|
288
|
-
expect(subject).to have_xml(
|
289
|
-
|
334
|
+
expect(subject).to have_xml(
|
335
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/RmtInf/Strd/CdtrRefInf/Tp/CdOrPrtry/Prtry', 'ESR'
|
336
|
+
)
|
337
|
+
expect(subject).to have_xml(
|
338
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/DrctDbtTxInf[1]/RmtInf/Strd/CdtrRefInf/Ref', '185744810000000000200800628'
|
339
|
+
)
|
290
340
|
end
|
291
341
|
end
|
292
342
|
|
293
343
|
context 'with service_level CHDD' do
|
294
|
-
let(:service_level)
|
344
|
+
let(:service_level) { 'CHDD' }
|
295
345
|
|
296
346
|
context 'with local_instrument DDCOR1' do
|
297
347
|
let(:local_instrument) { 'DDCOR1' }
|
@@ -346,22 +396,22 @@ describe SPS::DirectDebit do
|
|
346
396
|
sdd = direct_debit
|
347
397
|
|
348
398
|
sdd.add_transaction(
|
349
|
-
name:
|
350
|
-
iban:
|
351
|
-
amount:
|
352
|
-
instruction:
|
353
|
-
reference:
|
354
|
-
remittance_information:
|
399
|
+
name: 'Zahlemann & Söhne GbR',
|
400
|
+
iban: 'CH9804835011062385295',
|
401
|
+
amount: 39.99,
|
402
|
+
instruction: '12',
|
403
|
+
reference: 'XYZ/2013-08-ABO/12345',
|
404
|
+
remittance_information: 'Unsere Rechnung vom 10.08.2013',
|
355
405
|
structured_remittance_information: structured_remittance_information
|
356
406
|
)
|
357
407
|
|
358
408
|
sdd.add_transaction(
|
359
|
-
name:
|
360
|
-
iban:
|
361
|
-
amount:
|
362
|
-
instruction:
|
363
|
-
reference:
|
364
|
-
remittance_information:
|
409
|
+
name: 'Meier & Schulze oHG',
|
410
|
+
iban: 'CH7081232000001998736',
|
411
|
+
amount: 750.00,
|
412
|
+
instruction: '34',
|
413
|
+
reference: 'XYZ/2013-08-ABO/6789',
|
414
|
+
remittance_information: 'Vielen Dank für Ihren Einkauf!',
|
365
415
|
structured_remittance_information: structured_remittance_information
|
366
416
|
)
|
367
417
|
|
@@ -373,7 +423,10 @@ describe SPS::DirectDebit do
|
|
373
423
|
end
|
374
424
|
|
375
425
|
it 'should contain <ReqdColltnDt>' do
|
376
|
-
expect(subject).to have_xml(
|
426
|
+
expect(subject).to have_xml(
|
427
|
+
'//Document/CstmrDrctDbtInitn/PmtInf/ReqdColltnDt',
|
428
|
+
Date.new(1999, 1, 1).iso8601
|
429
|
+
)
|
377
430
|
end
|
378
431
|
end
|
379
432
|
|
@@ -389,15 +442,27 @@ describe SPS::DirectDebit do
|
|
389
442
|
end
|
390
443
|
|
391
444
|
it 'should contain two payment_informations with <ReqdColltnDt>' do
|
392
|
-
expect(subject).to have_xml(
|
393
|
-
|
445
|
+
expect(subject).to have_xml(
|
446
|
+
'//Document/CstmrDrctDbtInitn/PmtInf[1]/ReqdColltnDt',
|
447
|
+
(Date.today + 1).iso8601
|
448
|
+
)
|
449
|
+
expect(subject).to have_xml(
|
450
|
+
'//Document/CstmrDrctDbtInitn/PmtInf[2]/ReqdColltnDt',
|
451
|
+
(Date.today + 2).iso8601
|
452
|
+
)
|
394
453
|
|
395
454
|
expect(subject).not_to have_xml('//Document/CstmrDrctDbtInitn/PmtInf[3]')
|
396
455
|
end
|
397
456
|
|
398
457
|
it 'should contain two payment_informations with different <PmtInfId>' do
|
399
|
-
expect(subject).to have_xml(
|
400
|
-
|
458
|
+
expect(subject).to have_xml(
|
459
|
+
'//Document/CstmrDrctDbtInitn/PmtInf[1]/PmtInfId',
|
460
|
+
/#{message_id_regex}\/1/
|
461
|
+
)
|
462
|
+
expect(subject).to have_xml(
|
463
|
+
'//Document/CstmrDrctDbtInitn/PmtInf[2]/PmtInfId',
|
464
|
+
/#{message_id_regex}\/2/
|
465
|
+
)
|
401
466
|
end
|
402
467
|
end
|
403
468
|
|
@@ -426,7 +491,6 @@ describe SPS::DirectDebit do
|
|
426
491
|
subject do
|
427
492
|
sdd = direct_debit
|
428
493
|
|
429
|
-
|
430
494
|
sdd.add_transaction(direct_debt_transaction.merge(local_instrument: 'DDCOR1'))
|
431
495
|
|
432
496
|
sdd
|
@@ -436,9 +500,9 @@ describe SPS::DirectDebit do
|
|
436
500
|
expect {
|
437
501
|
subject.add_transaction(direct_debt_transaction.merge(local_instrument: 'DDB2B'))
|
438
502
|
}.to raise_error(
|
439
|
-
|
440
|
-
|
441
|
-
|
503
|
+
ArgumentError,
|
504
|
+
'Local instrument is not correct. Must be one of LSV+, BDD'
|
505
|
+
)
|
442
506
|
end
|
443
507
|
end
|
444
508
|
|
@@ -450,10 +514,10 @@ describe SPS::DirectDebit do
|
|
450
514
|
sdd.add_transaction(
|
451
515
|
direct_debt_transaction.merge(
|
452
516
|
creditor_account: SPS::CreditorAccount.new(
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
517
|
+
name: 'Creditor Inc.',
|
518
|
+
iban: 'CH5604835012345678009',
|
519
|
+
creditor_identifier: 'ABC1W'
|
520
|
+
)
|
457
521
|
)
|
458
522
|
)
|
459
523
|
|
@@ -461,8 +525,14 @@ describe SPS::DirectDebit do
|
|
461
525
|
end
|
462
526
|
|
463
527
|
it 'should contain two payment_informations with <Cdtr>' do
|
464
|
-
expect(subject).to have_xml(
|
465
|
-
|
528
|
+
expect(subject).to have_xml(
|
529
|
+
'//Document/CstmrDrctDbtInitn/PmtInf[1]/Cdtr/Nm',
|
530
|
+
'Gläubiger GmbH'
|
531
|
+
)
|
532
|
+
expect(subject).to have_xml(
|
533
|
+
'//Document/CstmrDrctDbtInitn/PmtInf[2]/Cdtr/Nm',
|
534
|
+
'Creditor Inc.'
|
535
|
+
)
|
466
536
|
end
|
467
537
|
end
|
468
538
|
|
@@ -479,5 +549,51 @@ describe SPS::DirectDebit do
|
|
479
549
|
end
|
480
550
|
end
|
481
551
|
end
|
552
|
+
|
553
|
+
context 'with no encoding specified' do
|
554
|
+
subject do
|
555
|
+
sdd = direct_debit
|
556
|
+
|
557
|
+
sdd.add_transaction(
|
558
|
+
name: 'Zahlemann & Söhne GbR',
|
559
|
+
iban: 'CH9804835011062385295',
|
560
|
+
amount: 39.99,
|
561
|
+
instruction: '12',
|
562
|
+
reference: 'XYZ/2013-08-ABO/12345',
|
563
|
+
remittance_information: 'Unsere Rechnung vom 10.08.2013',
|
564
|
+
structured_remittance_information: structured_remittance_information
|
565
|
+
)
|
566
|
+
|
567
|
+
sdd.to_xml(SPS::PAIN_008_001_02_CH_03)
|
568
|
+
end
|
569
|
+
|
570
|
+
it 'should include encoding in the xml string' do
|
571
|
+
expect(subject).to include('encoding')
|
572
|
+
expect(subject).to include('UTF-8')
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
context 'with encoding specified' do
|
577
|
+
subject do
|
578
|
+
sdd = direct_debit
|
579
|
+
|
580
|
+
sdd.add_transaction(
|
581
|
+
name: 'Zahlemann & Söhne GbR',
|
582
|
+
iban: 'CH9804835011062385295',
|
583
|
+
amount: 39.99,
|
584
|
+
instruction: '12',
|
585
|
+
reference: 'XYZ/2013-08-ABO/12345',
|
586
|
+
remittance_information: 'Unsere Rechnung vom 10.08.2013',
|
587
|
+
structured_remittance_information: structured_remittance_information
|
588
|
+
)
|
589
|
+
|
590
|
+
sdd.to_xml(SPS::PAIN_008_001_02_CH_03, 'ISO-8859-8')
|
591
|
+
end
|
592
|
+
|
593
|
+
it 'should include encoding in the xml string' do
|
594
|
+
expect(subject).to include('encoding')
|
595
|
+
expect(subject).to include('ISO-8859-8')
|
596
|
+
end
|
597
|
+
end
|
482
598
|
end
|
483
599
|
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
class DummyTransaction < SPS::Transaction
|
6
|
+
|
5
7
|
def valid?; true end
|
8
|
+
|
6
9
|
end
|
7
10
|
|
8
11
|
class DummyMessage < SPS::Message
|
12
|
+
|
9
13
|
self.account_class = SPS::Account
|
10
14
|
self.transaction_class = DummyTransaction
|
15
|
+
|
11
16
|
end
|
12
17
|
|
13
18
|
describe SPS::Message do
|
@@ -53,8 +58,9 @@ describe SPS::Message do
|
|
53
58
|
|
54
59
|
describe 'setter' do
|
55
60
|
it 'should accept valid ID' do
|
56
|
-
[
|
57
|
-
|
61
|
+
[
|
62
|
+
'gid://myMoneyApp/Payment/15108', # for example, Rails Global ID could be a candidate
|
63
|
+
Time.now.to_f.to_s # or a time based string
|
58
64
|
].each do |valid_msgid|
|
59
65
|
subject.message_identification = valid_msgid
|
60
66
|
expect(subject.message_identification).to eq(valid_msgid)
|
@@ -62,7 +68,8 @@ describe SPS::Message do
|
|
62
68
|
end
|
63
69
|
|
64
70
|
it 'should deny invalid string' do
|
65
|
-
[
|
71
|
+
[
|
72
|
+
'my_MESSAGE_ID/123', # contains underscore
|
66
73
|
'', # blank string
|
67
74
|
'üöäß', # non-ASCII chars
|
68
75
|
'1' * 36 # too long
|
@@ -74,7 +81,8 @@ describe SPS::Message do
|
|
74
81
|
end
|
75
82
|
|
76
83
|
it 'should deny argument other than String' do
|
77
|
-
[
|
84
|
+
[
|
85
|
+
123,
|
78
86
|
nil,
|
79
87
|
:foo
|
80
88
|
].each do |arg|
|
@@ -86,7 +94,7 @@ describe SPS::Message do
|
|
86
94
|
end
|
87
95
|
end
|
88
96
|
|
89
|
-
describe :creation_date_time do
|
97
|
+
describe :creation_date_time do
|
90
98
|
subject { DummyMessage.new }
|
91
99
|
|
92
100
|
describe 'getter' do
|
@@ -97,14 +105,20 @@ describe :creation_date_time do
|
|
97
105
|
|
98
106
|
describe 'setter' do
|
99
107
|
it 'should accept date time strings' do
|
100
|
-
[
|
108
|
+
[
|
109
|
+
'2017-01-05T12:28:52',
|
110
|
+
'2017-01-05T12:28:52Z',
|
111
|
+
'2017-01-05 12:28:52',
|
112
|
+
'2017-01-05T12:28:52+01:00'
|
113
|
+
].each do |valid_dt|
|
101
114
|
subject.creation_date_time = valid_dt
|
102
115
|
expect(subject.creation_date_time).to eq(valid_dt)
|
103
116
|
end
|
104
117
|
end
|
105
118
|
|
106
119
|
it 'should deny invalid string' do
|
107
|
-
[
|
120
|
+
[
|
121
|
+
'an arbitrary string',
|
108
122
|
''
|
109
123
|
].each do |arg|
|
110
124
|
expect {
|
@@ -114,7 +128,8 @@ describe :creation_date_time do
|
|
114
128
|
end
|
115
129
|
|
116
130
|
it 'should deny argument other than String' do
|
117
|
-
[
|
131
|
+
[
|
132
|
+
123,
|
118
133
|
nil,
|
119
134
|
:foo
|
120
135
|
].each do |arg|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
describe SPS::StructuredRemittanceInformation do
|
@@ -16,13 +17,17 @@ describe SPS::StructuredRemittanceInformation do
|
|
16
17
|
end
|
17
18
|
|
18
19
|
it 'should not accept invalid value' do
|
19
|
-
expect(SPS::StructuredRemittanceInformation).not_to accept(
|
20
|
+
expect(SPS::StructuredRemittanceInformation).not_to accept(
|
21
|
+
nil,
|
22
|
+
'something_else',
|
23
|
+
for: :proprietary
|
24
|
+
)
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
describe :reference do
|
24
29
|
it 'should accept valid value' do
|
25
|
-
expect(SPS::StructuredRemittanceInformation).to accept('a' * 35
|
30
|
+
expect(SPS::StructuredRemittanceInformation).to accept('a' * 35, for: :reference)
|
26
31
|
end
|
27
32
|
|
28
33
|
it 'should not accept invalid value' do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
describe SPS::CreditTransferTransaction do
|
@@ -33,11 +34,22 @@ describe SPS::CreditTransferTransaction do
|
|
33
34
|
|
34
35
|
context 'Requested date' do
|
35
36
|
it 'should allow valid value' do
|
36
|
-
expect(SPS::CreditTransferTransaction).to accept(
|
37
|
+
expect(SPS::CreditTransferTransaction).to accept(
|
38
|
+
nil,
|
39
|
+
Date.new(1999, 1, 1),
|
40
|
+
Date.today,
|
41
|
+
Date.today.next,
|
42
|
+
Date.today + 2,
|
43
|
+
for: :requested_date
|
44
|
+
)
|
37
45
|
end
|
38
46
|
|
39
47
|
it 'should not allow invalid value' do
|
40
|
-
expect(SPS::CreditTransferTransaction).not_to accept(
|
48
|
+
expect(SPS::CreditTransferTransaction).not_to accept(
|
49
|
+
Date.new(1995, 12, 21),
|
50
|
+
Date.today - 1,
|
51
|
+
for: :requested_date
|
52
|
+
)
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|