sps_king 0.4.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 +46 -23
- data/README.md +29 -13
- data/cliff.toml +3 -3
- 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 +120 -102
- 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 +3 -1
- 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 +205 -37
- 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 +8 -3
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd8f010271911b78bed9955509277ed10a1a9da20c11ac9cc6c52847cffaf810
|
4
|
+
data.tar.gz: 44a38096598ff27e120797c59b43d0505c184db77eb08556982f39ce0823fff4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b88d4094b57f6b40db6ebc5e83b90238bafb99521d38b0c59b5d7b13b317917bf54184fb5b654c810c0cd19394a5915fd6940bc7752fb1a9b9519e9ff0034f3
|
7
|
+
data.tar.gz: 99cbcd8f475d7310ecf302a5d6786594d883d8a9464a670baabbaf0207a17227c80dcf46bb277a501649c84c9c957ba126128a58d0cc2047ec4465fc82885e4f
|
data/.github/workflows/test.yml
CHANGED
@@ -13,11 +13,11 @@ jobs:
|
|
13
13
|
strategy:
|
14
14
|
fail-fast: false
|
15
15
|
matrix:
|
16
|
-
ruby: ['3.
|
16
|
+
ruby: ['3.2', '3.3', '3.4']
|
17
17
|
gemfile:
|
18
|
-
- gemfiles/Gemfile-activemodel-6.1.x
|
19
|
-
- gemfiles/Gemfile-activemodel-7.0.x
|
20
18
|
- gemfiles/Gemfile-activemodel-7.1.x
|
19
|
+
- gemfiles/Gemfile-activemodel-7.2.x
|
20
|
+
- gemfiles/Gemfile-activemodel-8.0.x
|
21
21
|
|
22
22
|
name: Ruby ${{ matrix.ruby }} / Gemfile {{ matrix.gemfile }}
|
23
23
|
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,29 @@
|
|
1
|
-
## What's Changed
|
1
|
+
## What's Changed in v0.5.0
|
2
|
+
* Update covered ruby and activemodel versions for testing
|
3
|
+
* Improvement of the convert_decimal function by @casaper in [#14](https://github.com/viafintech/sps_king/pull/14)
|
4
|
+
* Standardized creditor and debitor addresses and added stricter validation by @casapar in [#16](https://github.com/viafintech/sps_king/pull/16)
|
5
|
+
|
6
|
+
**Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.5.0...v0.6.0
|
7
|
+
|
8
|
+
## What's Changed in v0.5.0
|
9
|
+
* Add support for QRR type in structured remittance information by @tobischo in [#10](https://github.com/viafintech/sps_king/pull/10)
|
10
|
+
* Allow structured remittance information optionally for credits
|
11
|
+
* Bump version to 0.5.0
|
12
|
+
* Add support for QRR as value for proprietary
|
13
|
+
* Fix changelog links
|
14
|
+
|
15
|
+
**Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.4.0...v0.5.0
|
16
|
+
|
17
|
+
## What's Changed in v0.4.0
|
18
|
+
* Bump version to 0.4.0
|
19
|
+
* Make charge bearer optional instead of constant set to `SLEV` by @tobischo in [#7](https://github.com/viafintech/sps_king/pull/7)
|
2
20
|
* Make charge bearer optional instead of constant set to `SLEV`
|
3
21
|
|
22
|
+
**Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.3.1...v0.4.0
|
23
|
+
|
4
24
|
## What's Changed in v0.3.1
|
5
25
|
* Bump version to 0.3.1
|
6
|
-
*
|
26
|
+
* Fix default currency on transactions by @tobischo in [#5](https://github.com/viafintech/sps_king/pull/5)
|
7
27
|
* Revert to old gemfile definition
|
8
28
|
* Re-add bundle install step
|
9
29
|
* Fix indentation
|
@@ -11,36 +31,39 @@
|
|
11
31
|
* Add newer ruby versions to test matrix
|
12
32
|
* Fix default currency on transactions
|
13
33
|
|
14
|
-
**Full Changelog**: https://github.com
|
34
|
+
**Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.3.0...v0.3.1
|
15
35
|
|
16
36
|
## What's Changed in v0.3.0
|
17
37
|
* Bump gem version
|
18
38
|
* Update tested activemodel versions
|
19
39
|
* Update test ruby version to 3.0
|
20
40
|
|
21
|
-
**Full Changelog**: https://github.com
|
41
|
+
**Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.2.0...v0.3.0
|
22
42
|
|
23
43
|
## What's Changed in v0.2.0
|
24
|
-
*
|
25
|
-
* Stick to ruby 2.7 support for now
|
26
|
-
* Fix CI setup
|
27
|
-
* Bump required ruby version to 2.7
|
28
|
-
*
|
29
|
-
* Update version to 0.1.1
|
30
|
-
* Add missing gemfiles for testing
|
31
|
-
* Remove coveralls dependency
|
32
|
-
*
|
33
|
-
* Update copyright notice and author mail address
|
34
|
-
* Add comment pointing to sepa_king for sepa files
|
35
|
-
* Fix gem description for next release
|
36
|
-
|
37
|
-
|
44
|
+
* Bump required ruby version to 2.7 by @martinseener in [#3](https://github.com/viafintech/sps_king/pull/3)
|
45
|
+
* Stick to ruby 2.7 support for now by @tobischo
|
46
|
+
* Fix CI setup by @tobischo
|
47
|
+
* Bump required ruby version to 2.7 by @tobischo
|
48
|
+
* Remove coveralls dependency by @martinseener in [#2](https://github.com/viafintech/sps_king/pull/2)
|
49
|
+
* Update version to 0.1.1 by @tobischo
|
50
|
+
* Add missing gemfiles for testing by @tobischo
|
51
|
+
* Remove coveralls dependency by @tobischo
|
52
|
+
* Update copyright notice and author mail address by @martinseener in [#1](https://github.com/viafintech/sps_king/pull/1)
|
53
|
+
* Update copyright notice and author mail address by @tobischo
|
54
|
+
* Add comment pointing to sepa_king for sepa files by @tobischo
|
55
|
+
* Fix gem description for next release by @tobischo
|
56
|
+
|
57
|
+
## New Contributors
|
58
|
+
* @martinseener made their first contribution in [#3](https://github.com/viafintech/sps_king/pull/3)
|
59
|
+
|
60
|
+
**Full Changelog**: https://github.com/viafintech/sps_king/compare/v0.1.0...v0.2.0
|
38
61
|
|
39
62
|
## What's Changed in v0.1.0
|
40
|
-
* Add .gem to gitignore
|
41
|
-
* Adapt example account holder
|
42
|
-
* Fix status badges
|
43
|
-
* Fix copyright notice
|
44
|
-
* Initial implementation after fork from sepa_king gem
|
63
|
+
* Add .gem to gitignore by @tobischo
|
64
|
+
* Adapt example account holder by @tobischo
|
65
|
+
* Fix status badges by @tobischo
|
66
|
+
* Fix copyright notice by @tobischo
|
67
|
+
* Initial implementation after fork from sepa_king gem by @tobischo
|
45
68
|
|
46
69
|
<!-- generated by git-cliff -->
|
data/README.md
CHANGED
@@ -22,6 +22,8 @@ This gem is forked of `sepa_king` and therefore heavily inspired by the structur
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
## Direct Debit Initiation
|
26
|
+
|
25
27
|
How to create the XML for **Direct Debit Initiation** (in German: "Lastschriften")
|
26
28
|
|
27
29
|
```ruby
|
@@ -41,7 +43,7 @@ sdd = SPS::DirectDebit.new(
|
|
41
43
|
|
42
44
|
# Creditor Identifier, in German: Gläubiger-Identifikationsnummer
|
43
45
|
# String, max. 35 chars
|
44
|
-
creditor_identifier: 'ABC1W'
|
46
|
+
creditor_identifier: 'ABC1W',
|
45
47
|
)
|
46
48
|
|
47
49
|
# Second: Add transactions
|
@@ -84,7 +86,7 @@ sdd.add_transaction(
|
|
84
86
|
proprietary: 'ESR',
|
85
87
|
# if proprietary is 'ESR': 27 character ISR reference number
|
86
88
|
# if proprietary is 'IPI': 20 character IPI remittance
|
87
|
-
reference: '609323234234234353453423423'
|
89
|
+
reference: '609323234234234353453423423',
|
88
90
|
),
|
89
91
|
|
90
92
|
# Service Level
|
@@ -103,14 +105,14 @@ sdd.add_transaction(
|
|
103
105
|
|
104
106
|
# OPTIONAL: Requested collection date, in German "Fälligkeitsdatum der Lastschrift"
|
105
107
|
# Date
|
106
|
-
requested_date: Date.new(2013,9,5),
|
108
|
+
requested_date: Date.new(2013, 9, 5),
|
107
109
|
|
108
110
|
# OPTIONAL: Use a different creditor account
|
109
111
|
# CreditorAccount
|
110
112
|
creditor_account: SPS::CreditorAccount.new(
|
111
113
|
name: 'Creditor Inc.',
|
112
114
|
iban: 'CH7081232000001998736',
|
113
|
-
creditor_identifier: '12312'
|
115
|
+
creditor_identifier: '12312',
|
114
116
|
)
|
115
117
|
|
116
118
|
# Specify the country & address of the debtor (The individually required fields depend on the local legal requirements)
|
@@ -118,11 +120,11 @@ sdd.add_transaction(
|
|
118
120
|
country_code: 'CH',
|
119
121
|
# Not required if individual fields are used
|
120
122
|
address_line1: 'Mustergasse 123a',
|
121
|
-
address_line2: '1234 Musterstadt'
|
123
|
+
address_line2: '1234 Musterstadt',
|
122
124
|
# Not required if address_line1 and address_line2 are used
|
123
125
|
street_name: 'Mustergasse',
|
124
126
|
post_code: '1234',
|
125
|
-
town_name: 'Musterstadt'
|
127
|
+
town_name: 'Musterstadt',
|
126
128
|
)
|
127
129
|
)
|
128
130
|
sdd.add_transaction ...
|
@@ -131,6 +133,7 @@ sdd.add_transaction ...
|
|
131
133
|
xml_string = sdd.to_xml # Use latest schema pain.008.001.02.ch.03
|
132
134
|
```
|
133
135
|
|
136
|
+
### Credit Transfer Initiation
|
134
137
|
|
135
138
|
How to create the XML for **Credit Transfer Initiation** (in German: "Überweisungen")
|
136
139
|
|
@@ -147,7 +150,7 @@ sct = SPS::CreditTransfer.new(
|
|
147
150
|
|
148
151
|
# International Bank Account Number of the debtor
|
149
152
|
# String, max. 34 chars
|
150
|
-
iban: 'CH5481230000001998736'
|
153
|
+
iban: 'CH5481230000001998736',
|
151
154
|
)
|
152
155
|
|
153
156
|
# Second: Add transactions
|
@@ -184,6 +187,19 @@ sct.add_transaction(
|
|
184
187
|
# String, max. 140 char
|
185
188
|
remittance_information: 'Rechnung vom 22.08.2013',
|
186
189
|
|
190
|
+
# OPTIONAL: Structured remittance information, in German "Strukturierter Verwendungszweck". Required for e.g. Swiss QR transfers
|
191
|
+
# StructuredRemittanceInformation
|
192
|
+
structured_remittance_information: SPS::StructuredRemittanceInformation.new(
|
193
|
+
# Defines how the reference field should be interpreted for Swiss Direct Debits
|
194
|
+
# One of these strings:
|
195
|
+
# 'IPI' ("IPI-Verwendungszweck")
|
196
|
+
# 'QRR' ("QR-Referenz")
|
197
|
+
proprietary: 'QRR',
|
198
|
+
# if proprietary is 'IPI': 20 character IPI remittance
|
199
|
+
# if proprietary is 'QRR': 27 character QR reference
|
200
|
+
reference: '000008207791225857421286694',
|
201
|
+
),
|
202
|
+
|
187
203
|
# OPTIONAL: Requested execution date, in German "Ausführungstermin"
|
188
204
|
# Date
|
189
205
|
requested_date: Date.new(2013,9,5),
|
@@ -196,7 +212,7 @@ sct.add_transaction(
|
|
196
212
|
# One of these strings:
|
197
213
|
# 'SEPA' ("SEPA-Zahlung")
|
198
214
|
# 'URGP' ("Taggleiche Eilüberweisung")
|
199
|
-
service_level: 'URGP'
|
215
|
+
service_level: 'URGP',
|
200
216
|
|
201
217
|
# OPTIONAL: Charge Bearer
|
202
218
|
# One of these strings:
|
@@ -215,12 +231,12 @@ sct.add_transaction(
|
|
215
231
|
country_code: 'CH',
|
216
232
|
# Not required if individual fields are used
|
217
233
|
address_line1: 'Mustergasse 123a',
|
218
|
-
address_line2: '1234 Musterstadt'
|
234
|
+
address_line2: '1234 Musterstadt',
|
219
235
|
# Not required if address_line1 and address_line2 are used
|
220
236
|
street_name: 'Mustergasse',
|
221
237
|
building_number: '123a',
|
222
238
|
post_code: '1234',
|
223
|
-
town_name: 'Musterstadt'
|
239
|
+
town_name: 'Musterstadt',
|
224
240
|
)
|
225
241
|
)
|
226
242
|
sct.add_transaction ...
|
@@ -231,12 +247,12 @@ xml_string = sct.to_xml # Use latest schema pain.001.001.03.ch.02
|
|
231
247
|
|
232
248
|
## Changelog
|
233
249
|
|
234
|
-
https://github.com/
|
250
|
+
https://github.com/viafintech/sps_king/releases
|
235
251
|
|
236
252
|
|
237
253
|
## Contributors
|
238
254
|
|
239
|
-
https://github.com/
|
255
|
+
https://github.com/viafintech/sps_king/graphs/contributors
|
240
256
|
|
241
257
|
|
242
258
|
## Resources
|
@@ -249,6 +265,6 @@ https://github.com/Barzahlen/sps_king/graphs/contributors
|
|
249
265
|
|
250
266
|
Released under the MIT license
|
251
267
|
|
252
|
-
Copyright (c) 2018-
|
268
|
+
Copyright (c) 2018-2025 Tobias Schoknecht
|
253
269
|
|
254
270
|
Copyright (c) 2013-2017 Georg Leciejewski (Sales King GmbH) & Georg Ledermann for portions of this project copied from sepa_king
|
data/cliff.toml
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module SPS
|
4
|
+
class Address
|
5
|
+
|
6
|
+
include ActiveModel::Validations
|
7
|
+
extend Converter
|
8
|
+
|
9
|
+
attr_accessor :street_name,
|
10
|
+
:building_number,
|
11
|
+
:post_code,
|
12
|
+
:town_name,
|
13
|
+
:country_code,
|
14
|
+
:address_line1,
|
15
|
+
:address_line2
|
16
|
+
|
17
|
+
convert :street_name, to: :text
|
18
|
+
convert :building_number, to: :text
|
19
|
+
convert :post_code, to: :text
|
20
|
+
convert :town_name, to: :text
|
21
|
+
convert :country_code, to: :text
|
22
|
+
convert :address_line1, to: :text
|
23
|
+
convert :address_line2, to: :text
|
24
|
+
|
25
|
+
validates :street_name, length: { maximum: 70 }
|
26
|
+
validates :building_number, length: { maximum: 16 }
|
27
|
+
validates :post_code, length: { maximum: 16 }
|
28
|
+
validates :town_name, length: { maximum: 35 }
|
29
|
+
validates :address_line1, length: { maximum: 70 }
|
30
|
+
validates :address_line2, length: { maximum: 70 }
|
31
|
+
validates :country_code,
|
32
|
+
presence: true,
|
33
|
+
format: { with: /\A[A-Z]{2}\z/ }
|
34
|
+
# either town_name or address_line2 must be present
|
35
|
+
validates :address_line2, presence: true, if: :town_name_blank?
|
36
|
+
validates :town_name, presence: true, if: :address_line2_blank?
|
37
|
+
|
38
|
+
def initialize(attributes = {})
|
39
|
+
attributes.each do |name, value|
|
40
|
+
public_send("#{name}=", value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def town_name_blank?
|
47
|
+
town_name.blank?
|
48
|
+
end
|
49
|
+
|
50
|
+
def address_line2_blank?
|
51
|
+
address_line2.blank?
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
module SPS
|
3
4
|
class CreditorAccount < Account
|
5
|
+
|
4
6
|
attr_accessor :creditor_identifier,
|
5
7
|
:isr_participant_number
|
6
8
|
|
7
9
|
validates_with CreditorIdentifierValidator,
|
8
10
|
message: "%{value} is invalid"
|
9
11
|
validates_format_of :isr_participant_number, with: /\A\d{9}\z/, allow_nil: true
|
12
|
+
|
10
13
|
end
|
11
14
|
end
|
@@ -1,37 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
module SPS
|
3
|
-
class CreditorAddress
|
4
|
-
include ActiveModel::Validations
|
5
|
-
extend Converter
|
6
|
-
|
7
|
-
attr_accessor :street_name,
|
8
|
-
:building_number,
|
9
|
-
:post_code,
|
10
|
-
:town_name,
|
11
|
-
:country_code,
|
12
|
-
:address_line1,
|
13
|
-
:address_line2
|
14
|
-
|
15
|
-
convert :street_name, to: :text
|
16
|
-
convert :building_number, to: :text
|
17
|
-
convert :post_code, to: :text
|
18
|
-
convert :town_name, to: :text
|
19
|
-
convert :country_code, to: :text
|
20
|
-
convert :address_line1, to: :text
|
21
|
-
convert :address_line2, to: :text
|
22
2
|
|
23
|
-
|
24
|
-
|
25
|
-
validates_length_of :post_code, maximum: 16
|
26
|
-
validates_length_of :town_name, maximum: 35
|
27
|
-
validates_length_of :country_code, is: 2
|
28
|
-
validates_length_of :address_line1, maximum: 70
|
29
|
-
validates_length_of :address_line2, maximum: 70
|
30
|
-
|
31
|
-
def initialize(attributes = {})
|
32
|
-
attributes.each do |name, value|
|
33
|
-
public_send("#{name}=", value)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
3
|
+
module SPS
|
4
|
+
class CreditorAddress < Address; end
|
37
5
|
end
|
@@ -1,34 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
module SPS
|
3
|
-
class DebtorAddress
|
4
|
-
include ActiveModel::Validations
|
5
|
-
extend Converter
|
6
|
-
|
7
|
-
attr_accessor :street_name,
|
8
|
-
:post_code,
|
9
|
-
:town_name,
|
10
|
-
:country_code,
|
11
|
-
:address_line1,
|
12
|
-
:address_line2
|
13
|
-
|
14
|
-
convert :street_name, to: :text
|
15
|
-
convert :post_code, to: :text
|
16
|
-
convert :town_name, to: :text
|
17
|
-
convert :country_code, to: :text
|
18
|
-
convert :address_line1, to: :text
|
19
|
-
convert :address_line2, to: :text
|
20
2
|
|
21
|
-
|
22
|
-
|
23
|
-
validates_length_of :town_name, maximum: 35
|
24
|
-
validates_length_of :country_code, is: 2
|
25
|
-
validates_length_of :address_line1, maximum: 70
|
26
|
-
validates_length_of :address_line2, maximum: 70
|
27
|
-
|
28
|
-
def initialize(attributes = {})
|
29
|
-
attributes.each do |name, value|
|
30
|
-
public_send("#{name}=", value)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
3
|
+
module SPS
|
4
|
+
class DebtorAddress < Address; end
|
34
5
|
end
|
data/lib/sps_king/account.rb
CHANGED
data/lib/sps_king/converter.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
module SPS
|
3
4
|
module Converter
|
5
|
+
|
4
6
|
def convert(*attributes, options)
|
5
7
|
include InstanceMethods
|
6
8
|
|
@@ -17,18 +19,19 @@ module SPS
|
|
17
19
|
end
|
18
20
|
|
19
21
|
module InstanceMethods
|
22
|
+
|
20
23
|
def convert_text(value)
|
21
24
|
return unless value
|
22
25
|
|
23
26
|
value.to_s.
|
24
27
|
# Replace some special characters described as "Best practices" in Chapter 6.2 of this document:
|
25
28
|
# http://www.europeanpaymentscouncil.eu/index.cfm/knowledge-bank/epc-documents/sepa-requirements-for-an-extended-character-set-unicode-subset-best-practices/
|
26
|
-
gsub('€','E')
|
27
|
-
gsub('@','(at)')
|
28
|
-
gsub('_','-').
|
29
|
+
gsub('€', 'E')
|
30
|
+
.gsub('@', '(at)')
|
31
|
+
.gsub('_', '-').
|
29
32
|
|
30
33
|
# Replace linebreaks by spaces
|
31
|
-
gsub(/\n+/,' ').
|
34
|
+
gsub(/\n+/, ' ').
|
32
35
|
|
33
36
|
# Remove all invalid characters
|
34
37
|
gsub(/[^a-zA-Z0-9ÄÖÜäöüß&*$%\ \'\:\?\,\-\(\+\.\)\/]/, '').
|
@@ -37,17 +40,18 @@ module SPS
|
|
37
40
|
strip
|
38
41
|
end
|
39
42
|
|
43
|
+
# @param [BigDecimal|Integer|Float|String|nil] value the value to convert
|
44
|
+
# @return [BigDecimal|nil] the converted value or nil if the conversion failed
|
40
45
|
def convert_decimal(value)
|
41
|
-
|
42
|
-
value = begin
|
46
|
+
val = begin
|
43
47
|
BigDecimal(value.to_s)
|
44
48
|
rescue ArgumentError
|
49
|
+
nil
|
45
50
|
end
|
46
|
-
|
47
|
-
if value && value.finite? && value > 0
|
48
|
-
value.round(2)
|
49
|
-
end
|
51
|
+
val.round(2) if val&.finite? && val > 0
|
50
52
|
end
|
53
|
+
|
51
54
|
end
|
55
|
+
|
52
56
|
end
|
53
57
|
end
|