ibandit 1.12.0 → 1.14.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/tests.yml +1 -1
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +9 -0
- data/bin/build_structure_file.rb +221 -114
- data/data/german_iban_rules.yml +59 -20
- data/data/raw/BLZ2.txt +322 -362
- data/data/raw/IBANSTRUCTURE.xml +1134 -292
- data/data/raw/IBAN_Registry.txt +51 -48
- data/data/raw/pseudo_ibans.yml +52 -0
- data/data/raw/structure_additions.yml +29 -1
- data/data/structures.yml +524 -25
- data/ibandit.gemspec +1 -1
- data/lib/ibandit/constants.rb +1 -1
- data/lib/ibandit/iban.rb +2 -2
- data/lib/ibandit/iban_assembler.rb +1 -1
- data/lib/ibandit/local_details_cleaner.rb +10 -10
- data/lib/ibandit/sweden/local_details_converter.rb +1 -1
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_assembler_spec.rb +48 -0
- data/spec/ibandit/iban_spec.rb +76 -16
- metadata +6 -5
data/ibandit.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require File.expand_path("lib/ibandit/version", __dir__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
|
-
gem.add_development_dependency "gc_ruboconfig", "~> 3.
|
6
|
+
gem.add_development_dependency "gc_ruboconfig", "~> 3.6.2"
|
7
7
|
gem.add_development_dependency "nokogiri", "~> 1.6"
|
8
8
|
gem.add_development_dependency "pry", "~> 0.13"
|
9
9
|
gem.add_development_dependency "pry-byebug", "~> 3.9"
|
data/lib/ibandit/constants.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Ibandit
|
4
4
|
module Constants
|
5
|
-
CONSTRUCTABLE_IBAN_COUNTRY_CODES = %w[AT BE BG CY CZ DE DK EE ES FI FR GB GR
|
5
|
+
CONSTRUCTABLE_IBAN_COUNTRY_CODES = %w[AT BE BG CY CZ DE DK EE ES FI FO FR GB GL GR
|
6
6
|
HR HU IE IS IT LT LU LV MC MT NL NO PL
|
7
7
|
PT RO SE SI SK SM].freeze
|
8
8
|
|
data/lib/ibandit/iban.rb
CHANGED
@@ -64,7 +64,7 @@ module Ibandit
|
|
64
64
|
def account_number_suffix
|
65
65
|
return nil unless country_code == "NZ"
|
66
66
|
|
67
|
-
@account_number[7
|
67
|
+
@account_number[7..]
|
68
68
|
end
|
69
69
|
|
70
70
|
def local_check_digits
|
@@ -77,7 +77,7 @@ module Ibandit
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def bban
|
80
|
-
iban[4
|
80
|
+
iban[4..] unless iban.nil?
|
81
81
|
end
|
82
82
|
|
83
83
|
def pseudo_iban
|
@@ -89,7 +89,7 @@ module Ibandit
|
|
89
89
|
|
90
90
|
def self.required_fields(country_code)
|
91
91
|
case country_code
|
92
|
-
when "AT", "CY", "CZ", "DE", "DK", "EE", "FI", "HR", "IS", "LT", "LU",
|
92
|
+
when "AT", "CY", "CZ", "DE", "DK", "EE", "FO", "FI", "GL", "HR", "IS", "LT", "LU",
|
93
93
|
"LV", "NL", "NO", "PL", "RO", "SE", "SI", "SK"
|
94
94
|
%i[bank_code account_number]
|
95
95
|
when "BE"
|
@@ -132,7 +132,7 @@ module Ibandit
|
|
132
132
|
if local_details[:branch_code]
|
133
133
|
local_details[:branch_code]
|
134
134
|
elsif cleaned_bank_code.length > 3
|
135
|
-
cleaned_bank_code[3
|
135
|
+
cleaned_bank_code[3..]
|
136
136
|
end
|
137
137
|
account_number =
|
138
138
|
if local_details[:account_number].length >= 7
|
@@ -247,7 +247,7 @@ module Ibandit
|
|
247
247
|
|
248
248
|
bank_code = cleaned_account_number.slice(0, 4)
|
249
249
|
branch_code = cleaned_account_number.slice(4, 4)
|
250
|
-
account_number = cleaned_account_number[8
|
250
|
+
account_number = cleaned_account_number[8..]
|
251
251
|
end
|
252
252
|
|
253
253
|
{
|
@@ -265,7 +265,7 @@ module Ibandit
|
|
265
265
|
if %w[4 5 6].include?(local_details[:bank_code][0])
|
266
266
|
[
|
267
267
|
local_details[:account_number][0],
|
268
|
-
local_details[:account_number][1
|
268
|
+
local_details[:account_number][1..].rjust(7, "0"),
|
269
269
|
].join
|
270
270
|
else
|
271
271
|
local_details[:account_number].rjust(8, "0")
|
@@ -294,7 +294,7 @@ module Ibandit
|
|
294
294
|
bank_code = local_details[:bank_code]
|
295
295
|
else
|
296
296
|
bic = Ibandit.find_bic("GB", branch_code)
|
297
|
-
bank_code = bic
|
297
|
+
bank_code = bic&.slice(0, 4)
|
298
298
|
end
|
299
299
|
|
300
300
|
account_number = local_details[:account_number].gsub(/[-\s]/, "")
|
@@ -359,7 +359,7 @@ module Ibandit
|
|
359
359
|
bank_code = local_details[:bank_code]
|
360
360
|
else
|
361
361
|
bic = Ibandit.find_bic("IE", branch_code)
|
362
|
-
bank_code = bic
|
362
|
+
bank_code = bic&.slice(0, 4)
|
363
363
|
end
|
364
364
|
|
365
365
|
account_number = local_details[:account_number].gsub(/[-\s]/, "")
|
@@ -380,7 +380,7 @@ module Ibandit
|
|
380
380
|
bank_code, *parts = local_details[:account_number].split("-")
|
381
381
|
else
|
382
382
|
bank_code = local_details[:account_number].slice(0, 4)
|
383
|
-
parts = Array(local_details[:account_number][4
|
383
|
+
parts = Array(local_details[:account_number][4..])
|
384
384
|
end
|
385
385
|
|
386
386
|
{
|
@@ -426,7 +426,7 @@ module Ibandit
|
|
426
426
|
bank_code = local_details[:bank_code]
|
427
427
|
else
|
428
428
|
bic = Ibandit.find_bic("MT", branch_code)
|
429
|
-
bank_code = bic
|
429
|
+
bank_code = bic&.slice(0, 4)
|
430
430
|
end
|
431
431
|
|
432
432
|
account_number = local_details[:account_number].gsub(/[-\s]/, "")
|
@@ -457,7 +457,7 @@ module Ibandit
|
|
457
457
|
cleaned_acct_number = local_details[:account_number].gsub(/[-.\s]/, "")
|
458
458
|
|
459
459
|
bank_code = cleaned_acct_number.slice(0, 4)
|
460
|
-
account_number = cleaned_acct_number[4
|
460
|
+
account_number = cleaned_acct_number[4..]
|
461
461
|
end
|
462
462
|
|
463
463
|
{
|
@@ -483,7 +483,7 @@ module Ibandit
|
|
483
483
|
cleaned_account_number = local_details[:account_number].tr("-", "")
|
484
484
|
bank_code = cleaned_account_number.slice(0, 2)
|
485
485
|
branch_code = cleaned_account_number.slice(2, 4)
|
486
|
-
account_number = cleaned_account_number[6
|
486
|
+
account_number = cleaned_account_number[6..]
|
487
487
|
end
|
488
488
|
|
489
489
|
if account_number && account_number.length == 9
|
@@ -515,7 +515,7 @@ module Ibandit
|
|
515
515
|
cleaned_acct_number = local_details[:account_number].gsub(/\s/, "")
|
516
516
|
|
517
517
|
bank_code = cleaned_acct_number.slice(2, 8)
|
518
|
-
account_number = cleaned_acct_number[10
|
518
|
+
account_number = cleaned_acct_number[10..]
|
519
519
|
end
|
520
520
|
|
521
521
|
{
|
data/lib/ibandit/version.rb
CHANGED
@@ -210,6 +210,54 @@ describe Ibandit::IBANAssembler do
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
+
context "with FO as the country_code" do
|
214
|
+
let(:args) do
|
215
|
+
{ country_code: "FO",
|
216
|
+
bank_code: "1199",
|
217
|
+
account_number: "0003179680" }
|
218
|
+
end
|
219
|
+
|
220
|
+
it { is_expected.to eq("FO9111990003179680") }
|
221
|
+
|
222
|
+
it_behaves_like "allows round trips", "FO91 1199 0003 1796 80"
|
223
|
+
|
224
|
+
context "without a bank_code" do
|
225
|
+
before { args.delete(:bank_code) }
|
226
|
+
|
227
|
+
it { is_expected.to be_nil }
|
228
|
+
end
|
229
|
+
|
230
|
+
context "without an account_number" do
|
231
|
+
before { args.delete(:account_number) }
|
232
|
+
|
233
|
+
it { is_expected.to be_nil }
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context "with GL as the country_code" do
|
238
|
+
let(:args) do
|
239
|
+
{ country_code: "GL",
|
240
|
+
bank_code: "1199",
|
241
|
+
account_number: "0003179680" }
|
242
|
+
end
|
243
|
+
|
244
|
+
it { is_expected.to eq("GL9111990003179680") }
|
245
|
+
|
246
|
+
it_behaves_like "allows round trips", "GL91 1199 0003 1796 80"
|
247
|
+
|
248
|
+
context "without a bank_code" do
|
249
|
+
before { args.delete(:bank_code) }
|
250
|
+
|
251
|
+
it { is_expected.to be_nil }
|
252
|
+
end
|
253
|
+
|
254
|
+
context "without an account_number" do
|
255
|
+
before { args.delete(:account_number) }
|
256
|
+
|
257
|
+
it { is_expected.to be_nil }
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
213
261
|
context "with EE as the country_code" do
|
214
262
|
let(:args) do
|
215
263
|
{
|
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -946,8 +946,8 @@ describe Ibandit::IBAN do
|
|
946
946
|
iban.valid_check_digits?
|
947
947
|
expect(iban.errors).
|
948
948
|
to include(check_digits: "Verifique os dígitos. A verificação " \
|
949
|
-
"do módulo falhou. '82' esperados, '12'" \
|
950
|
-
"
|
949
|
+
"do módulo falhou. '82' esperados, '12' " \
|
950
|
+
"recebidos.")
|
951
951
|
end
|
952
952
|
end
|
953
953
|
|
@@ -1070,8 +1070,8 @@ describe Ibandit::IBAN do
|
|
1070
1070
|
iban.valid_length?
|
1071
1071
|
expect(iban.errors).
|
1072
1072
|
to include(length: "La longueur ne correspond pas à la " \
|
1073
|
-
"spécification SWIFT (22 caractères attendus," \
|
1074
|
-
"
|
1073
|
+
"spécification SWIFT (22 caractères attendus, " \
|
1074
|
+
"20 reçus)")
|
1075
1075
|
end
|
1076
1076
|
end
|
1077
1077
|
|
@@ -1089,9 +1089,9 @@ describe Ibandit::IBAN do
|
|
1089
1089
|
it "sets errors on the IBAN" do
|
1090
1090
|
iban.valid_length?
|
1091
1091
|
expect(iban.errors).
|
1092
|
-
to include(length: "O comprimento não corresponde à especificação" \
|
1093
|
-
"
|
1094
|
-
"
|
1092
|
+
to include(length: "O comprimento não corresponde à especificação " \
|
1093
|
+
"do código SWIFT (22 caracteres esperados, 20 " \
|
1094
|
+
"recebidos)")
|
1095
1095
|
end
|
1096
1096
|
end
|
1097
1097
|
|
@@ -1099,8 +1099,8 @@ describe Ibandit::IBAN do
|
|
1099
1099
|
it "sets errors on the IBAN" do
|
1100
1100
|
iban.valid_length?
|
1101
1101
|
expect(iban.errors).
|
1102
|
-
to include(length: "La longitud no coincide con la especificación" \
|
1103
|
-
"
|
1102
|
+
to include(length: "La longitud no coincide con la especificación " \
|
1103
|
+
"SWIFT (se esperaban 22 caracteres, pero se " \
|
1104
1104
|
"han recibido 20)")
|
1105
1105
|
end
|
1106
1106
|
end
|
@@ -1148,8 +1148,8 @@ describe Ibandit::IBAN do
|
|
1148
1148
|
it "sets errors on the IBAN" do
|
1149
1149
|
iban.valid_length?
|
1150
1150
|
expect(iban.errors).
|
1151
|
-
to include(length: "Længden modsvarer ikke SWIFT-specifikation" \
|
1152
|
-
"
|
1151
|
+
to include(length: "Længden modsvarer ikke SWIFT-specifikation " \
|
1152
|
+
"(forventede 22 tegn, modtog 20)")
|
1153
1153
|
end
|
1154
1154
|
end
|
1155
1155
|
|
@@ -1588,8 +1588,8 @@ describe Ibandit::IBAN do
|
|
1588
1588
|
it "sets errors on the IBAN" do
|
1589
1589
|
iban.valid_account_number_length?
|
1590
1590
|
expect(iban.errors).
|
1591
|
-
to include(account_number: "je napačne dolžine (biti mora 8" \
|
1592
|
-
"
|
1591
|
+
to include(account_number: "je napačne dolžine (biti mora 8 " \
|
1592
|
+
"znakov)")
|
1593
1593
|
end
|
1594
1594
|
end
|
1595
1595
|
|
@@ -1597,8 +1597,8 @@ describe Ibandit::IBAN do
|
|
1597
1597
|
it "sets errors on the IBAN" do
|
1598
1598
|
iban.valid_account_number_length?
|
1599
1599
|
expect(iban.errors).
|
1600
|
-
to include(account_number: "har forkert længde (skulle være 8" \
|
1601
|
-
"
|
1600
|
+
to include(account_number: "har forkert længde (skulle være 8 " \
|
1601
|
+
"tegn)")
|
1602
1602
|
end
|
1603
1603
|
end
|
1604
1604
|
|
@@ -3396,7 +3396,7 @@ describe Ibandit::IBAN do
|
|
3396
3396
|
end
|
3397
3397
|
|
3398
3398
|
context "for a valid Italian IBAN" do
|
3399
|
-
let(:iban_code) { "
|
3399
|
+
let(:iban_code) { "IT60 X054 2811 1010 0000 0123 456" }
|
3400
3400
|
|
3401
3401
|
it { is_expected.to be_valid }
|
3402
3402
|
end
|
@@ -3946,6 +3946,66 @@ describe Ibandit::IBAN do
|
|
3946
3946
|
|
3947
3947
|
it { is_expected.to_not be_valid }
|
3948
3948
|
end
|
3949
|
+
|
3950
|
+
context "with a valid LY iban" do
|
3951
|
+
let(:iban_code) { "LY83002048000020100120361" }
|
3952
|
+
|
3953
|
+
it { is_expected.to be_valid }
|
3954
|
+
end
|
3955
|
+
|
3956
|
+
context "with an invalid LY iban" do
|
3957
|
+
let(:iban_code) { "LY830020480000120361" }
|
3958
|
+
|
3959
|
+
it { is_expected.to_not be_valid }
|
3960
|
+
end
|
3961
|
+
|
3962
|
+
context "with a valid SD iban" do
|
3963
|
+
let(:iban_code) { "SD2129010501234001" }
|
3964
|
+
|
3965
|
+
it { is_expected.to be_valid }
|
3966
|
+
end
|
3967
|
+
|
3968
|
+
context "with an invalid SD iban" do
|
3969
|
+
let(:iban_code) { "SD21290104001" }
|
3970
|
+
|
3971
|
+
it { is_expected.to_not be_valid }
|
3972
|
+
end
|
3973
|
+
|
3974
|
+
context "with a valid BI iban" do
|
3975
|
+
let(:iban_code) { "BI4210000100010000332045181" }
|
3976
|
+
|
3977
|
+
it { is_expected.to be_valid }
|
3978
|
+
end
|
3979
|
+
|
3980
|
+
context "with an invalid BI iban" do
|
3981
|
+
let(:iban_code) { "BI4210000100000332045181" }
|
3982
|
+
|
3983
|
+
it { is_expected.to_not be_valid }
|
3984
|
+
end
|
3985
|
+
|
3986
|
+
context "with a valid DJ iban" do
|
3987
|
+
let(:iban_code) { "DJ2100010000000154000100186" }
|
3988
|
+
|
3989
|
+
it { is_expected.to be_valid }
|
3990
|
+
end
|
3991
|
+
|
3992
|
+
context "with an invalid DJ iban" do
|
3993
|
+
let(:iban_code) { "DJ2100010000000000100186" }
|
3994
|
+
|
3995
|
+
it { is_expected.to_not be_valid }
|
3996
|
+
end
|
3997
|
+
|
3998
|
+
context "with a valid RU iban" do
|
3999
|
+
let(:iban_code) { "RU0204452560040702810412345678901" }
|
4000
|
+
|
4001
|
+
it { is_expected.to be_valid }
|
4002
|
+
end
|
4003
|
+
|
4004
|
+
context "with an invalid RU iban" do
|
4005
|
+
let(:iban_code) { "RU1704452522540817810538091310419" }
|
4006
|
+
|
4007
|
+
it { is_expected.to_not be_valid }
|
4008
|
+
end
|
3949
4009
|
end
|
3950
4010
|
|
3951
4011
|
describe "#local_check_digits" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibandit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gc_ruboconfig
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.6.2
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: 3.6.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- data/raw/BLZ2.txt
|
175
175
|
- data/raw/IBANSTRUCTURE.xml
|
176
176
|
- data/raw/IBAN_Registry.txt
|
177
|
+
- data/raw/pseudo_ibans.yml
|
177
178
|
- data/raw/structure_additions.yml
|
178
179
|
- data/raw/swedish_bank_lookup.yml
|
179
180
|
- data/structures.yml
|
@@ -227,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
228
|
- !ruby/object:Gem::Version
|
228
229
|
version: '0'
|
229
230
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
231
|
+
rubygems_version: 3.4.6
|
231
232
|
signing_key:
|
232
233
|
specification_version: 4
|
233
234
|
summary: Convert national banking details into IBANs, and vice-versa.
|