sepa_rator 0.16.0 → 1.1.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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +132 -46
  3. data/lib/schema/dk/pain.001.001.03_GBIC_3.xsd +499 -0
  4. data/lib/schema/dk/pain.001.001.09_GBIC_5.xsd +2411 -0
  5. data/lib/schema/dk/pain.008.001.02_GBIC_3.xsd +625 -0
  6. data/lib/schema/dk/pain.008.001.08_GBIC_5.xsd +2690 -0
  7. data/lib/schema/sps/pain.001.001.09.ch.03.xsd +1733 -0
  8. data/lib/schema/sps/pain.008.001.02.chsdd.02.xsd +1056 -0
  9. data/lib/sepa_rator/account/address.rb +11 -0
  10. data/lib/sepa_rator/account/creditor_account.rb +2 -2
  11. data/lib/sepa_rator/account/debtor_account.rb +4 -3
  12. data/lib/sepa_rator/account.rb +11 -10
  13. data/lib/sepa_rator/builders/credit_transfer/group_header.rb +40 -0
  14. data/lib/sepa_rator/builders/credit_transfer/payment_information.rb +85 -0
  15. data/lib/sepa_rator/builders/credit_transfer/transaction/amount.rb +20 -0
  16. data/lib/sepa_rator/builders/credit_transfer/transaction/credit_transfer_mandate.rb +24 -0
  17. data/lib/sepa_rator/builders/credit_transfer/transaction/creditor.rb +19 -0
  18. data/lib/sepa_rator/builders/credit_transfer/transaction/creditor_account.rb +15 -0
  19. data/lib/sepa_rator/builders/credit_transfer/transaction/creditor_agent.rb +22 -0
  20. data/lib/sepa_rator/builders/credit_transfer/transaction/instructions_for_creditor_agent.rb +26 -0
  21. data/lib/sepa_rator/builders/credit_transfer/transaction/payment_id.rb +19 -0
  22. data/lib/sepa_rator/builders/credit_transfer/transaction/purpose.rb +15 -0
  23. data/lib/sepa_rator/builders/credit_transfer/transaction/regulatory_reporting.rb +87 -0
  24. data/lib/sepa_rator/builders/credit_transfer/transaction/remittance_information.rb +15 -0
  25. data/lib/sepa_rator/builders/credit_transfer/transaction/txn_instruction_for_debtor_agent.rb +35 -0
  26. data/lib/sepa_rator/builders/credit_transfer/transaction/ultimate_creditor.rb +19 -0
  27. data/lib/sepa_rator/builders/credit_transfer/transaction/ultimate_debtor.rb +19 -0
  28. data/lib/sepa_rator/builders/direct_debit/group_header.rb +23 -0
  29. data/lib/sepa_rator/builders/direct_debit/payment_information.rb +80 -0
  30. data/lib/sepa_rator/builders/direct_debit/transaction/amount.rb +18 -0
  31. data/lib/sepa_rator/builders/direct_debit/transaction/debtor.rb +19 -0
  32. data/lib/sepa_rator/builders/direct_debit/transaction/debtor_account.rb +15 -0
  33. data/lib/sepa_rator/builders/direct_debit/transaction/debtor_agent.rb +20 -0
  34. data/lib/sepa_rator/builders/direct_debit/transaction/direct_debit_info.rb +61 -0
  35. data/lib/sepa_rator/builders/direct_debit/transaction/payment_id.rb +19 -0
  36. data/lib/sepa_rator/builders/direct_debit/transaction/purpose.rb +15 -0
  37. data/lib/sepa_rator/builders/direct_debit/transaction/remittance_information.rb +15 -0
  38. data/lib/sepa_rator/builders/direct_debit/transaction/ultimate_creditor.rb +19 -0
  39. data/lib/sepa_rator/builders/direct_debit/transaction/ultimate_debtor.rb +19 -0
  40. data/lib/sepa_rator/builders/stage.rb +31 -0
  41. data/lib/sepa_rator/concerns/schema_validation.rb +27 -17
  42. data/lib/sepa_rator/concerns/xml_builder.rb +49 -21
  43. data/lib/sepa_rator/error.rb +36 -0
  44. data/lib/sepa_rator/message/credit_transfer.rb +12 -198
  45. data/lib/sepa_rator/message/direct_debit.rb +12 -126
  46. data/lib/sepa_rator/message.rb +180 -176
  47. data/lib/sepa_rator/profile.rb +269 -0
  48. data/lib/sepa_rator/profiles/cfonb.rb +45 -0
  49. data/lib/sepa_rator/profiles/country_defaults.rb +104 -0
  50. data/lib/sepa_rator/profiles/dk.rb +57 -0
  51. data/lib/sepa_rator/profiles/epc.rb +50 -0
  52. data/lib/sepa_rator/profiles/iso.rb +233 -0
  53. data/lib/sepa_rator/profiles/sps.rb +80 -0
  54. data/lib/sepa_rator/transaction/credit_transfer_transaction.rb +71 -77
  55. data/lib/sepa_rator/transaction/direct_debit_transaction.rb +8 -33
  56. data/lib/sepa_rator/transaction.rb +14 -0
  57. data/lib/sepa_rator/validators/dk/min_amount.rb +27 -0
  58. data/lib/sepa_rator/version.rb +1 -1
  59. data/lib/sepa_rator.rb +47 -0
  60. metadata +53 -12
  61. data/lib/schema/pain.001.001.03.ch.02.xsd +0 -1212
  62. /data/lib/schema/{pain.001.001.03.xsd → iso/pain.001.001.03.xsd} +0 -0
  63. /data/lib/schema/{pain.001.001.09.xsd → iso/pain.001.001.09.xsd} +0 -0
  64. /data/lib/schema/{pain.001.001.13.xsd → iso/pain.001.001.13.xsd} +0 -0
  65. /data/lib/schema/{pain.001.002.03.xsd → iso/pain.001.002.03.xsd} +0 -0
  66. /data/lib/schema/{pain.001.003.03.xsd → iso/pain.001.003.03.xsd} +0 -0
  67. /data/lib/schema/{pain.008.001.02.xsd → iso/pain.008.001.02.xsd} +0 -0
  68. /data/lib/schema/{pain.008.001.08.xsd → iso/pain.008.001.08.xsd} +0 -0
  69. /data/lib/schema/{pain.008.001.12.xsd → iso/pain.008.001.12.xsd} +0 -0
  70. /data/lib/schema/{pain.008.002.02.xsd → iso/pain.008.002.02.xsd} +0 -0
  71. /data/lib/schema/{pain.008.003.02.xsd → iso/pain.008.003.02.xsd} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83ba8734459eaf10832606aa2c4c894cad0fde36f221a88e4664d55ec929d1d6
4
- data.tar.gz: 54c0ad9c0f54bcfa88b2912cd1f93b5fd2574d15581574dd5bd2760941adef10
3
+ metadata.gz: dfad7d3d0bdc0746f73ef52cdda9f0963449b3fb8011fc7cbc8517ff7c2ce3af
4
+ data.tar.gz: b6f0ec529bec02449479008d60583873b7d606e027dbb226da95527c2e5eeb3a
5
5
  SHA512:
6
- metadata.gz: 2570e0b6dc02a36accc1d6caeeeb19b064f6da7395f43a1d13af1629de401f67b94d07fcbd45dd82b5e6bc473860ede0c8a6e41f811eca5e66f1fda15398444c
7
- data.tar.gz: eb2e7d4a6b6809f4a4eeec006de9816773407845c3a74a002fe082d7fb4190052389ea007b7357bf65651638d83c9cbafbc15135faba6decf145de16d0f48558
6
+ metadata.gz: 92b5682bc566140730448a99a27e09307fdef78bc1a7241aa29570fc05d66a035d0a11b51f41bebb82ca74cf0e48fbee10535e692f7cca6b4722fa83b0160b50
7
+ data.tar.gz: 7d4015b5109e027a038f772299e4ab97d50d21caf59521559640fae1f49c37d23c9c30e0375c954667abf11b5fe6f051c0a0611d62f130d4b6d8141a8384762a
data/README.md CHANGED
@@ -3,97 +3,181 @@
3
3
  [![Build Status](https://github.com/AdVitam/sepa_rator/workflows/Test/badge.svg?branch=master)](https://github.com/AdVitam/sepa_rator/actions)
4
4
 
5
5
  Successor to [salesking/sepa_king](https://github.com/salesking/sepa_king) (unmaintained since 2022).
6
- Adds support for newer SEPA schemas (`pain.001.001.09`, `pain.001.001.13`,
7
- `pain.008.001.08`, `pain.008.001.12`) with extensive code quality
8
- and security improvements.
6
+ Adds support for newer SEPA schemas and a **profile-based architecture** that makes
7
+ national variants (CFONB for France, DK/DFÜ for Germany, …) first-class.
9
8
 
10
9
  ## Features
11
10
 
12
- * **Credit Transfer** (`pain.001`) — schemas `.001.13`, `.001.09`, `.003.03`, `.002.03`, `.001.03`, `.001.03.ch.02`
13
- * **Direct Debit** (`pain.008`) — schemas `.001.12`, `.001.08`, `.003.02`, `.002.02`, `.001.02`
14
- * Full XSD validation on every generated XML
15
- * Postal addresses, contact details, LEI, regulatory reporting
16
- * Flexible charge bearer (SLEV, DEBT, CRED, SHAR)
17
- * Mandate amendment support (original mandate ID, debtor account, creditor scheme)
11
+ - **Credit Transfer** (`pain.001`) — schemas `.001.13`, `.001.09`, `.003.03`, `.002.03`, `.001.03`
12
+ - **Direct Debit** (`pain.008`) — schemas `.001.12`, `.001.08`, `.003.02`, `.002.02`, `.001.02`
13
+ - **National profiles** `CFONB` (🇫🇷), `DK/DFÜ` (🇩🇪), generic `EPC` SEPA
14
+ - Resolves the right profile from a simple `country: :fr` hint
15
+ - Full XSD validation on every generated XML
16
+ - Postal addresses, contact details, LEI, regulatory reporting
17
+ - Flexible charge bearer (SLEV, DEBT, CRED, SHAR)
18
+ - Mandate amendment support (original mandate ID, debtor account, creditor scheme)
18
19
 
19
20
  **pain** = **Pa**yment **In**itiation (ISO 20022).
20
21
 
21
22
  ## Requirements
22
23
 
23
- * Ruby 3.1+
24
- * ActiveModel 7.0+ (including 8.1)
24
+ - Ruby 3.2+
25
+ - ActiveModel 7.0+ (tested up to 8.1)
25
26
 
26
27
  ## Installation
27
28
 
28
29
  ```ruby
29
- gem 'sepa_rator'
30
+ gem 'sepa_rator', '~> 1.0'
30
31
  ```
31
32
 
32
33
  ## Quick start
33
34
 
34
- ### Credit Transfer
35
+ ### The simplest possible Credit Transfer
36
+
37
+ No profile, no country, no schema name — defaults to the latest EPC SEPA profile:
35
38
 
36
39
  ```ruby
37
40
  sct = SEPA::CreditTransfer.new(
38
- name: 'Debtor Inc.',
39
- bic: 'BANKDEFFXXX',
40
- iban: 'DE87200500001234567890'
41
+ name: 'Acme Ltd',
42
+ bic: 'BNPAFRPPXXX',
43
+ iban: 'FR7612345678901234567890123'
41
44
  )
42
45
 
43
46
  sct.add_transaction(
44
- name: 'Creditor AG',
45
- bic: 'PBNKDEFF370',
46
- iban: 'DE37112589611964645802',
47
+ name: 'Supplier GmbH',
48
+ iban: 'DE21500500009876543210',
47
49
  amount: 102.50,
48
- reference: 'XYZ-1234/123',
50
+ reference: 'INV-123',
49
51
  remittance_information: 'Invoice 123'
50
52
  )
51
53
 
52
- xml = sct.to_xml # pain.001.001.03 (default)
53
- xml = sct.to_xml('pain.001.001.09') # newer schema
54
- xml = sct.to_xml('pain.001.001.13') # latest schema
54
+ xml = sct.to_xml
55
55
  ```
56
56
 
57
- ### Direct Debit
57
+ ### The simplest possible Direct Debit
58
58
 
59
59
  ```ruby
60
60
  sdd = SEPA::DirectDebit.new(
61
- name: 'Creditor Inc.',
62
- bic: 'BANKDEFFXXX',
63
- iban: 'DE87200500001234567890',
64
- creditor_identifier: 'DE98ZZZ09999999999'
61
+ name: 'Acme Ltd',
62
+ bic: 'BNPAFRPPXXX',
63
+ iban: 'FR7612345678901234567890123',
64
+ creditor_identifier: 'FR72ZZZ123456'
65
65
  )
66
66
 
67
67
  sdd.add_transaction(
68
- name: 'Debtor Corp.',
69
- bic: 'SPUEDE2UXXX',
68
+ name: 'Customer SA',
70
69
  iban: 'DE21500500009876543210',
71
70
  amount: 39.99,
72
- reference: 'XYZ/2013-08-ABO/6789',
73
- mandate_id: 'K-02-2011-12345',
74
- mandate_date_of_signature: Date.new(2011, 1, 25),
75
- sequence_type: 'OOFF'
71
+ reference: 'SUB/2025-08/001',
72
+ mandate_id: 'MND-2025-001',
73
+ mandate_date_of_signature: Date.new(2025, 1, 15)
76
74
  )
77
75
 
78
- xml = sdd.to_xml # pain.008.001.02 (default)
79
- xml = sdd.to_xml('pain.008.001.08') # newer schema
80
- xml = sdd.to_xml('pain.008.001.12') # latest schema
76
+ xml = sdd.to_xml
77
+ ```
78
+
79
+ ## The 4-level public API
80
+
81
+ `sepa_rator` exposes a progressive API: the simpler path covers 90 % of use
82
+ cases; the explicit path is there when you need it.
83
+
84
+ ### Level 0 — defaults (generic SEPA)
85
+
86
+ Do nothing special and get the latest EPC SEPA profile
87
+ (`pain.001.001.13` for credit transfer, `pain.008.001.12` for direct debit):
88
+
89
+ ```ruby
90
+ SEPA::CreditTransfer.new(name: ..., iban: ..., bic: ...)
91
+ SEPA::DirectDebit.new(name: ..., iban: ..., bic: ..., creditor_identifier: ...)
92
+ ```
93
+
94
+ ### Level 1 — hint by country
95
+
96
+ The country code is **the country of the bank that will receive and process
97
+ your XML file** — your own bank for credit transfers, the creditor's bank for
98
+ direct debits. It is **not** the country of the beneficiary.
99
+
100
+ > Example: a company with a French bank pays Italian and German suppliers.
101
+ > The file goes to the French bank, so write `country: :fr`. The suppliers'
102
+ > IBANs can be from any SEPA country.
103
+
104
+ ```ruby
105
+ SEPA::CreditTransfer.new(country: :fr, name: ..., iban: ..., bic: ...)
106
+ # → SEPA::Profiles::CFONB::SCT_13
107
+
108
+ SEPA::DirectDebit.new(country: :de, name: ..., iban: ..., bic: ...,
109
+ creditor_identifier: ...)
110
+ # → SEPA::Profiles::DK::SDD_12_GBIC5
111
+ ```
112
+
113
+ Countries without a dedicated profile (e.g. `:it`, `:es`, `:be`) fall back
114
+ to the generic EPC profile automatically.
115
+
116
+ ### Level 2 — country + version
117
+
118
+ If your bank hasn't upgraded to the latest ISO version yet, pin the version:
119
+
120
+ ```ruby
121
+ SEPA::CreditTransfer.new(country: :fr, version: :v09, ...)
122
+ # → SEPA::Profiles::CFONB::SCT_09
81
123
  ```
82
124
 
83
- ### Validators
125
+ Supported version symbols:
126
+
127
+ | Family | Versions |
128
+ |-----------------|-------------------------|
129
+ | `credit_transfer` | `:v09`, `:v13`, `:latest` |
130
+ | `direct_debit` | `:v08`, `:v12`, `:latest` |
131
+
132
+ Requesting an unknown version raises `SEPA::UnsupportedVersionError` with
133
+ the list of available versions.
134
+
135
+ The older EPC AOS schemas (`pain.001.002.03`, `pain.001.003.03`,
136
+ `pain.008.002.02`, `pain.008.003.02`) are not exposed through the
137
+ `country:` / `version:` API — use Level 3 (explicit
138
+ `SEPA::Profiles::ISO::*` constants) if you need them.
139
+
140
+ ### Level 3 — explicit profile (power user)
141
+
142
+ Pass a `SEPA::Profile` constant directly when you need a specific variant:
143
+
144
+ ```ruby
145
+ SEPA::CreditTransfer.new(
146
+ profile: SEPA::Profiles::DK::SCT_09_GBIC5,
147
+ name: ..., iban: ..., bic: ...
148
+ )
149
+ ```
150
+
151
+ `profile:` is mutually exclusive with `country:` / `version:` — passing
152
+ both raises `ArgumentError`.
153
+
154
+ ## Supported profiles
155
+
156
+ | Family | Namespace | Profiles |
157
+ |---------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------|
158
+ | ISO (raw XSD) | `Profiles::ISO` | `SCT_03`, `SCT_09`, `SCT_13`, `SCT_EPC_002_03`, `SCT_EPC_003_03`, `SDD_02`, `SDD_08`, `SDD_12`, `SDD_EPC_002_02`, `SDD_EPC_003_02` |
159
+ | EPC SEPA | `Profiles::EPC` | `SCT_09`, `SCT_13`, `SDD_08`, `SDD_12` |
160
+ | CFONB (France 🇫🇷) | `Profiles::CFONB` | `SCT_09`, `SCT_13`, `SDD_08`, `SDD_12` |
161
+ | DK / DFÜ (Germany 🇩🇪) | `Profiles::DK` | `SCT_09_GBIC5`, `SCT_13_GBIC5`, `SDD_08_GBIC5`, `SDD_12_GBIC5` |
162
+
163
+ Adding a new country is a single file in `lib/sepa_rator/profiles/` plus
164
+ entries in `lib/sepa_rator/profiles/country_defaults.rb`.
84
165
 
85
- Reuse SEPA validators in your own models:
166
+ ## Reusing validators
86
167
 
87
168
  ```ruby
88
169
  class BankAccount < ActiveRecord::Base
89
170
  validates_with SEPA::IBANValidator, field_name: :iban
90
171
  validates_with SEPA::BICValidator, field_name: :bic
172
+ validates_with SEPA::LEIValidator, field_name: :agent_lei
91
173
  end
92
174
  ```
93
175
 
94
176
  ## Documentation
95
177
 
96
- For the full list of options (addresses, charge bearer, amendment info, batch booking, service level, etc.), see [DOCUMENTATION.md](DOCUMENTATION.md).
178
+ For the full list of options (addresses, charge bearer, amendment info,
179
+ regulatory reporting, LEI, contact details, etc.), see
180
+ [DOCUMENTATION.md](DOCUMENTATION.md).
97
181
 
98
182
  ## Changelog
99
183
 
@@ -101,17 +185,19 @@ See [CHANGELOG.md](CHANGELOG.md).
101
185
 
102
186
  ## Contributors
103
187
 
104
- * [Original contributors](https://github.com/salesking/sepa_king/graphs/contributors) (salesking/sepa_king)
105
- * [sepa_rator contributors](https://github.com/AdVitam/sepa_rator/graphs/contributors)
188
+ - [Original contributors](https://github.com/salesking/sepa_king/graphs/contributors) (salesking/sepa_king)
189
+ - [sepa_rator contributors](https://github.com/AdVitam/sepa_rator/graphs/contributors)
106
190
 
107
191
  ## Resources
108
192
 
109
- * [ISO 20022 message definitions](https://www.iso20022.org/iso-20022-message-definitions)
110
- * <https://www.ebics.de/de/datenformate>
193
+ - [ISO 20022 message definitions](https://www.iso20022.org/iso-20022-message-definitions)
194
+ - [EPC rulebooks](https://www.europeanpaymentscouncil.eu/document-library)
195
+ - [CFONB guides](https://www.cfonb.org/espaces-telechargements/documents)
196
+ - [EBICS / DK data formats](https://www.ebics.de/de/datenformate)
111
197
 
112
198
  ## License
113
199
 
114
200
  Released under the [MIT License](LICENSE.txt).
115
201
 
116
- Originally copyright (c) 2013-2022 Georg Leciejewski (SalesKing), Georg Ledermann.
117
- Copyright (c) 2025-2026 AdVitam.
202
+ - Originally copyright (c) 2013-2022 Georg Leciejewski (SalesKing), Georg Ledermann.
203
+ - Copyright (c) 2025-2026 Advitam — fork, maintenance, profile-based architecture.