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::CreditTransfer do
|
@@ -171,11 +172,17 @@ describe SPS::CreditTransfer do
|
|
171
172
|
end
|
172
173
|
|
173
174
|
it 'should contain <PmtInfId>' do
|
174
|
-
expect(subject).to have_xml(
|
175
|
+
expect(subject).to have_xml(
|
176
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/PmtInfId',
|
177
|
+
/#{message_id_regex}\/1/
|
178
|
+
)
|
175
179
|
end
|
176
180
|
|
177
181
|
it 'should contain <ReqdExctnDt>' do
|
178
|
-
expect(subject).to have_xml(
|
182
|
+
expect(subject).to have_xml(
|
183
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/ReqdExctnDt',
|
184
|
+
Date.new(1999, 1, 1).iso8601
|
185
|
+
)
|
179
186
|
end
|
180
187
|
|
181
188
|
it 'should contain <PmtMtd>' do
|
@@ -195,45 +202,80 @@ describe SPS::CreditTransfer do
|
|
195
202
|
end
|
196
203
|
|
197
204
|
it 'should contain <Dbtr>' do
|
198
|
-
expect(subject).to have_xml(
|
205
|
+
expect(subject).to have_xml(
|
206
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/Dbtr/Nm',
|
207
|
+
'Schuldner GmbH'
|
208
|
+
)
|
199
209
|
end
|
200
210
|
|
201
211
|
it 'should contain <DbtrAcct>' do
|
202
|
-
expect(subject).to have_xml(
|
212
|
+
expect(subject).to have_xml(
|
213
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/DbtrAcct/Id/IBAN',
|
214
|
+
'CH5481230000001998736'
|
215
|
+
)
|
203
216
|
end
|
204
217
|
|
205
218
|
it 'should contain <DbtrAgt>' do
|
206
|
-
expect(subject).to have_xml(
|
219
|
+
expect(subject).to have_xml(
|
220
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/DbtrAgt/FinInstnId/BIC',
|
221
|
+
'RAIFCH22'
|
222
|
+
)
|
207
223
|
end
|
208
224
|
|
209
225
|
it 'should contain <EndToEndId>' do
|
210
|
-
expect(subject).to have_xml(
|
211
|
-
|
226
|
+
expect(subject).to have_xml(
|
227
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/PmtId/EndToEndId', 'XYZ-1234/123'
|
228
|
+
)
|
229
|
+
expect(subject).to have_xml(
|
230
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/PmtId/EndToEndId', 'XYZ-5678/456'
|
231
|
+
)
|
212
232
|
end
|
213
233
|
|
214
234
|
it 'should contain <Amt>' do
|
215
|
-
expect(subject).to have_xml(
|
216
|
-
|
235
|
+
expect(subject).to have_xml(
|
236
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/Amt/InstdAmt', '102.50'
|
237
|
+
)
|
238
|
+
expect(subject).to have_xml(
|
239
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/Amt/InstdAmt', '59.00'
|
240
|
+
)
|
217
241
|
end
|
218
242
|
|
219
243
|
it 'should contain <CdtrAgt> for every BIC given' do
|
220
|
-
expect(subject).to have_xml(
|
221
|
-
|
244
|
+
expect(subject).to have_xml(
|
245
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/CdtrAgt/FinInstnId/BIC', 'CRESCHZZ80A'
|
246
|
+
)
|
247
|
+
expect(subject).to have_xml(
|
248
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/CdtrAgt/FinInstnId/BIC', 'RAIFCH22C32'
|
249
|
+
)
|
222
250
|
end
|
223
251
|
|
224
252
|
it 'should contain <Cdtr>' do
|
225
|
-
expect(subject).to have_xml(
|
226
|
-
|
253
|
+
expect(subject).to have_xml(
|
254
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/Cdtr/Nm',
|
255
|
+
'Contoso AG'
|
256
|
+
)
|
257
|
+
expect(subject).to have_xml(
|
258
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/Cdtr/Nm',
|
259
|
+
'Amazonas GmbH'
|
260
|
+
)
|
227
261
|
end
|
228
262
|
|
229
263
|
it 'should contain <CdtrAcct>' do
|
230
|
-
expect(subject).to have_xml(
|
231
|
-
|
264
|
+
expect(subject).to have_xml(
|
265
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/CdtrAcct/Id/IBAN', 'CH9300762011623852957'
|
266
|
+
)
|
267
|
+
expect(subject).to have_xml(
|
268
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/CdtrAcct/Id/IBAN', 'CH7081232000001998736'
|
269
|
+
)
|
232
270
|
end
|
233
271
|
|
234
272
|
it 'should contain <RmtInf>' do
|
235
|
-
expect(subject).to have_xml(
|
236
|
-
|
273
|
+
expect(subject).to have_xml(
|
274
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/RmtInf/Ustrd', 'Rechnung vom 22.08.2013'
|
275
|
+
)
|
276
|
+
expect(subject).to have_xml(
|
277
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[2]/RmtInf/Ustrd', 'Rechnung vom 21.08.2013'
|
278
|
+
)
|
237
279
|
end
|
238
280
|
end
|
239
281
|
|
@@ -249,15 +291,27 @@ describe SPS::CreditTransfer do
|
|
249
291
|
end
|
250
292
|
|
251
293
|
it 'should contain two payment_informations with <ReqdExctnDt>' do
|
252
|
-
expect(subject).to have_xml(
|
253
|
-
|
294
|
+
expect(subject).to have_xml(
|
295
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[1]/ReqdExctnDt',
|
296
|
+
(Date.today + 1).iso8601
|
297
|
+
)
|
298
|
+
expect(subject).to have_xml(
|
299
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[2]/ReqdExctnDt',
|
300
|
+
(Date.today + 2).iso8601
|
301
|
+
)
|
254
302
|
|
255
303
|
expect(subject).not_to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]')
|
256
304
|
end
|
257
305
|
|
258
306
|
it 'should contain two payment_informations with different <PmtInfId>' do
|
259
|
-
expect(subject).to have_xml(
|
260
|
-
|
307
|
+
expect(subject).to have_xml(
|
308
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[1]/PmtInfId',
|
309
|
+
/#{message_id_regex}\/1/
|
310
|
+
)
|
311
|
+
expect(subject).to have_xml(
|
312
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[2]/PmtInfId',
|
313
|
+
/#{message_id_regex}\/2/
|
314
|
+
)
|
261
315
|
end
|
262
316
|
end
|
263
317
|
|
@@ -303,30 +357,69 @@ describe SPS::CreditTransfer do
|
|
303
357
|
subject do
|
304
358
|
sct = credit_transfer
|
305
359
|
|
306
|
-
sct.add_transaction(
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
360
|
+
sct.add_transaction(
|
361
|
+
credit_transfer_transaction.merge requested_date: Date.today + 1,
|
362
|
+
batch_booking: false,
|
363
|
+
amount: 1
|
364
|
+
)
|
365
|
+
sct.add_transaction(
|
366
|
+
credit_transfer_transaction.merge requested_date: Date.today + 1,
|
367
|
+
batch_booking: true,
|
368
|
+
amount: 2
|
369
|
+
)
|
370
|
+
sct.add_transaction(
|
371
|
+
credit_transfer_transaction.merge requested_date: Date.today + 2,
|
372
|
+
batch_booking: false,
|
373
|
+
amount: 4
|
374
|
+
)
|
375
|
+
sct.add_transaction(
|
376
|
+
credit_transfer_transaction.merge requested_date: Date.today + 2,
|
377
|
+
batch_booking: true,
|
378
|
+
amount: 8
|
379
|
+
)
|
380
|
+
sct.add_transaction(
|
381
|
+
credit_transfer_transaction.merge requested_date: Date.today + 2,
|
382
|
+
batch_booking: true,
|
383
|
+
category_purpose: 'SALA',
|
384
|
+
amount: 6
|
385
|
+
)
|
311
386
|
|
312
387
|
sct.to_xml
|
313
388
|
end
|
314
389
|
|
315
390
|
it 'should contain multiple payment_informations' do
|
316
|
-
expect(subject).to have_xml(
|
391
|
+
expect(subject).to have_xml(
|
392
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[1]/ReqdExctnDt',
|
393
|
+
(Date.today + 1).iso8601
|
394
|
+
)
|
317
395
|
expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[1]/BtchBookg', 'false')
|
318
396
|
|
319
|
-
expect(subject).to have_xml(
|
397
|
+
expect(subject).to have_xml(
|
398
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[2]/ReqdExctnDt',
|
399
|
+
(Date.today + 1).iso8601
|
400
|
+
)
|
320
401
|
expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[2]/BtchBookg', 'true')
|
321
402
|
|
322
|
-
expect(subject).to have_xml(
|
403
|
+
expect(subject).to have_xml(
|
404
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[3]/ReqdExctnDt',
|
405
|
+
(Date.today + 2).iso8601
|
406
|
+
)
|
323
407
|
expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[3]/BtchBookg', 'false')
|
324
408
|
|
325
|
-
expect(subject).to have_xml(
|
409
|
+
expect(subject).to have_xml(
|
410
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[4]/ReqdExctnDt',
|
411
|
+
(Date.today + 2).iso8601
|
412
|
+
)
|
326
413
|
expect(subject).to have_xml('//Document/CstmrCdtTrfInitn/PmtInf[4]/BtchBookg', 'true')
|
327
414
|
|
328
|
-
expect(subject).to have_xml(
|
329
|
-
|
415
|
+
expect(subject).to have_xml(
|
416
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[5]/ReqdExctnDt',
|
417
|
+
(Date.today + 2).iso8601
|
418
|
+
)
|
419
|
+
expect(subject).to have_xml(
|
420
|
+
'//Document/CstmrCdtTrfInitn/PmtInf[5]/PmtTpInf/CtgyPurp/Cd',
|
421
|
+
'SALA'
|
422
|
+
)
|
330
423
|
end
|
331
424
|
|
332
425
|
it 'should have multiple control sums' do
|
@@ -359,9 +452,9 @@ describe SPS::CreditTransfer do
|
|
359
452
|
it 'should contain <InstrId>' do
|
360
453
|
expect(subject)
|
361
454
|
.to have_xml(
|
362
|
-
|
363
|
-
|
364
|
-
|
455
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/PmtId/InstrId',
|
456
|
+
'1234/ABC'
|
457
|
+
)
|
365
458
|
end
|
366
459
|
end
|
367
460
|
|
@@ -370,14 +463,14 @@ describe SPS::CreditTransfer do
|
|
370
463
|
sct = credit_transfer
|
371
464
|
|
372
465
|
sct.add_transaction(
|
373
|
-
name:
|
374
|
-
iban:
|
375
|
-
bic:
|
376
|
-
amount:
|
466
|
+
name: 'Contoso AG',
|
467
|
+
iban: 'CH5481230000001998736',
|
468
|
+
bic: 'RAIFCH22',
|
469
|
+
amount: 102.50,
|
377
470
|
structured_remittance_information: SPS::StructuredRemittanceInformation.new(
|
378
|
-
|
379
|
-
|
380
|
-
|
471
|
+
proprietary: 'QRR',
|
472
|
+
reference: '185744810000000000200800628'
|
473
|
+
)
|
381
474
|
)
|
382
475
|
|
383
476
|
sct.to_xml
|
@@ -390,11 +483,57 @@ describe SPS::CreditTransfer do
|
|
390
483
|
it 'should contain <Prtry>' do
|
391
484
|
expect(subject)
|
392
485
|
.to have_xml(
|
393
|
-
|
394
|
-
|
395
|
-
|
486
|
+
'//Document/CstmrCdtTrfInitn/PmtInf/CdtTrfTxInf[1]/RmtInf/Strd/CdtrRefInf/Tp/CdOrPrtry/Prtry',
|
487
|
+
'QRR'
|
488
|
+
)
|
396
489
|
end
|
397
490
|
end
|
398
491
|
end
|
492
|
+
|
493
|
+
context 'with no encoding specified' do
|
494
|
+
subject do
|
495
|
+
sct = credit_transfer
|
496
|
+
|
497
|
+
sct.add_transaction(
|
498
|
+
name: 'Contoso AG',
|
499
|
+
bic: 'CRESCHZZ80A',
|
500
|
+
iban: 'CH9300762011623852957',
|
501
|
+
service_level: 'SEPA',
|
502
|
+
amount: 102.50,
|
503
|
+
reference: 'XYZ-1234/123',
|
504
|
+
remittance_information: 'Rechnung vom 22.08.2013'
|
505
|
+
)
|
506
|
+
|
507
|
+
sct.to_xml(SPS::PAIN_001_001_03_CH_02)
|
508
|
+
end
|
509
|
+
|
510
|
+
it 'should include encoding in the xml string' do
|
511
|
+
expect(subject).to include('encoding')
|
512
|
+
expect(subject).to include('UTF-8')
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
context 'with encoding specified' do
|
517
|
+
subject do
|
518
|
+
sct = credit_transfer
|
519
|
+
|
520
|
+
sct.add_transaction(
|
521
|
+
name: 'Contoso AG',
|
522
|
+
bic: 'CRESCHZZ80A',
|
523
|
+
iban: 'CH9300762011623852957',
|
524
|
+
service_level: 'SEPA',
|
525
|
+
amount: 102.50,
|
526
|
+
reference: 'XYZ-1234/123',
|
527
|
+
remittance_information: 'Rechnung vom 22.08.2013'
|
528
|
+
)
|
529
|
+
|
530
|
+
sct.to_xml(SPS::PAIN_001_001_03_CH_02, 'ISO-8859-8')
|
531
|
+
end
|
532
|
+
|
533
|
+
it 'should include encoding in the xml string' do
|
534
|
+
expect(subject).to include('encoding')
|
535
|
+
expect(subject).to include('ISO-8859-8')
|
536
|
+
end
|
537
|
+
end
|
399
538
|
end
|
400
539
|
end
|