ibandit 1.21.0 → 1.27.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/.gitignore +1 -0
- data/.rubocop.yml +2 -48
- data/.rubocop_todo.yml +35 -36
- data/.ruby-version +1 -1
- data/CHANGELOG.md +31 -0
- data/Gemfile +10 -0
- data/bin/build_german_iban_rules.rb +26 -24
- data/data/german_iban_rules.yml +56 -161
- data/data/raw/BLZ2.xml +1 -0
- data/data/raw/IBANSTRUCTURE.xml +105 -9
- data/data/raw/IBAN_Registry.txt +52 -51
- data/data/raw/structure_additions.yml +18 -11
- data/data/raw/swedish_bank_lookup.yml +4 -1
- data/data/structures.yml +92 -9
- data/ibandit.gemspec +1 -8
- data/lib/ibandit/iban.rb +11 -12
- data/lib/ibandit/sweden/bank_lookup.rb +1 -1
- data/lib/ibandit/sweden/validator.rb +1 -1
- data/lib/ibandit/version.rb +1 -1
- data/lib/ibandit.rb +2 -4
- data/spec/ibandit/german_details_converter_spec.rb +2 -2
- data/spec/ibandit/iban_assembler_spec.rb +26 -22
- data/spec/ibandit/iban_spec.rb +235 -16
- metadata +4 -105
- data/data/raw/BLZ2.txt +0 -14692
data/data/structures.yml
CHANGED
@@ -273,7 +273,7 @@ EE:
|
|
273
273
|
:iban_example: EE382200221020145685
|
274
274
|
:bban_example: '2200221020145685'
|
275
275
|
:domestic_account_number_example: '221020145685'
|
276
|
-
:bban_format: "\\d{2}\\d{
|
276
|
+
:bban_format: "\\d{2}\\d{14}"
|
277
277
|
:bank_code_format: "[1-9][0-9]"
|
278
278
|
:account_number_format: "\\d{2}\\d{11}\\d{1}"
|
279
279
|
:local_check_digit_position: 20
|
@@ -286,7 +286,7 @@ ES:
|
|
286
286
|
:account_number_position: 13
|
287
287
|
:account_number_length: 12
|
288
288
|
:total_length: 24
|
289
|
-
:national_id_length:
|
289
|
+
:national_id_length: 8
|
290
290
|
:iban_example: ES9121000418450200051332
|
291
291
|
:bban_example: '21000418450200051332'
|
292
292
|
:domestic_account_number_example: 2100 0418 45 0200051332
|
@@ -841,8 +841,8 @@ PT:
|
|
841
841
|
:domestic_account_number_example: 0002.0123.12345678901.54
|
842
842
|
:bban_format: "\\d{4}\\d{4}\\d{11}\\d{2}"
|
843
843
|
:bank_code_format: "\\d{4}"
|
844
|
-
:account_number_format: "\\d{11}\\d{2}"
|
845
844
|
:branch_code_format: "\\d{4}"
|
845
|
+
:account_number_format: "\\d{11}\\d{2}"
|
846
846
|
:local_check_digit_position: 24
|
847
847
|
:local_check_digit_length: 2
|
848
848
|
RO:
|
@@ -1103,10 +1103,10 @@ ST:
|
|
1103
1103
|
:account_number_length: 13
|
1104
1104
|
:total_length: 25
|
1105
1105
|
:national_id_length: 8
|
1106
|
-
:iban_example:
|
1107
|
-
:bban_example: '
|
1108
|
-
:domestic_account_number_example: '
|
1109
|
-
:bban_format: "\\d{
|
1106
|
+
:iban_example: ST23000100010051845310146
|
1107
|
+
:bban_example: '000100010051845310146'
|
1108
|
+
:domestic_account_number_example: '0051845310146'
|
1109
|
+
:bban_format: "\\d{8}\\d{11}\\d{2}"
|
1110
1110
|
:bank_code_format: "\\d{4}"
|
1111
1111
|
:branch_code_format: "\\d{4}"
|
1112
1112
|
:account_number_format: "\\d{11}\\d{2}"
|
@@ -1137,9 +1137,9 @@ IQ:
|
|
1137
1137
|
:iban_example: IQ98NBIQ850123456789012
|
1138
1138
|
:bban_example: NBIQ850123456789012
|
1139
1139
|
:domestic_account_number_example: '123456789012'
|
1140
|
-
:bban_format: "[A-Z]{4}\\d{3}\\d{12}"
|
1141
1140
|
:bank_code_format: "[A-Z]{4}"
|
1142
1141
|
:branch_code_format: "\\d{3}"
|
1142
|
+
:bban_format: "[A-Z]{4}\\d{3}\\d{12}"
|
1143
1143
|
:account_number_format: "\\d{12}"
|
1144
1144
|
SV:
|
1145
1145
|
:bank_code_position: 5
|
@@ -1357,6 +1357,12 @@ MN:
|
|
1357
1357
|
:account_number_length: 12
|
1358
1358
|
:total_length: 20
|
1359
1359
|
:national_id_length: 4
|
1360
|
+
:iban_example: MN121234123456789123
|
1361
|
+
:bban_example: '1234123456789123'
|
1362
|
+
:domestic_account_number_example: 1234 5678 9123
|
1363
|
+
:bban_format: "\\d{4}\\d{12}"
|
1364
|
+
:bank_code_format: "\\d{4}"
|
1365
|
+
:account_number_format: "\\d{12}"
|
1360
1366
|
DZ:
|
1361
1367
|
:bank_code_position: 5
|
1362
1368
|
:bank_code_length: 3
|
@@ -1472,13 +1478,90 @@ RU:
|
|
1472
1478
|
:account_number_length: 15
|
1473
1479
|
:total_length: 33
|
1474
1480
|
:national_id_length: 14
|
1475
|
-
:iban_example:
|
1481
|
+
:iban_example: RU0304452522540817810538091310419
|
1476
1482
|
:bban_example: 044525225 40817 810 5 3809 1310419
|
1477
1483
|
:domestic_account_number_example: 40817 810 5 3809 1310419
|
1478
1484
|
:bban_format: "\\d{9}\\d{5}[A-Z0-9]{15}"
|
1479
1485
|
:bank_code_format: "\\d{9}"
|
1480
1486
|
:branch_code_format: "\\d{5}"
|
1481
1487
|
:account_number_format: "[A-Z0-9]{15}"
|
1488
|
+
SO:
|
1489
|
+
:bank_code_position: 5
|
1490
|
+
:bank_code_length: 4
|
1491
|
+
:branch_code_position: 9
|
1492
|
+
:branch_code_length: 3
|
1493
|
+
:account_number_position: 12
|
1494
|
+
:account_number_length: 12
|
1495
|
+
:total_length: 23
|
1496
|
+
:national_id_length: 7
|
1497
|
+
:iban_example: SO211000001001000100141
|
1498
|
+
:bban_example: '1000001001000100141'
|
1499
|
+
:domestic_account_number_example: '001000100141'
|
1500
|
+
:bban_format: "\\d{4}\\d{3}\\d{12}"
|
1501
|
+
:bank_code_format: "\\d{4}"
|
1502
|
+
:branch_code_format: "\\d{3}"
|
1503
|
+
:account_number_format: "\\d{12}"
|
1504
|
+
NI:
|
1505
|
+
:bank_code_position: 5
|
1506
|
+
:bank_code_length: 4
|
1507
|
+
:branch_code_position: 0
|
1508
|
+
:branch_code_length: 0
|
1509
|
+
:account_number_position: 9
|
1510
|
+
:account_number_length: 20
|
1511
|
+
:total_length: 28
|
1512
|
+
:national_id_length: 4
|
1513
|
+
:iban_example: NI45BAPR00000013000003558124
|
1514
|
+
:bban_example: BAPR00000013000003558124
|
1515
|
+
:domestic_account_number_example: '00000013000003558124'
|
1516
|
+
:bban_format: "[A-Z]{4}\\d{20}"
|
1517
|
+
:bank_code_format: "[A-Z]{4}"
|
1518
|
+
:account_number_format: "\\d{20}"
|
1519
|
+
FK:
|
1520
|
+
:bank_code_position: 5
|
1521
|
+
:bank_code_length: 2
|
1522
|
+
:branch_code_position: 0
|
1523
|
+
:branch_code_length: 0
|
1524
|
+
:account_number_position: 7
|
1525
|
+
:account_number_length: 12
|
1526
|
+
:total_length: 18
|
1527
|
+
:national_id_length: 2
|
1528
|
+
:iban_example: FK88SC123456789012
|
1529
|
+
:bban_example: SC123456789012
|
1530
|
+
:domestic_account_number_example: '123456789012'
|
1531
|
+
:bban_format: "[A-Z]{2}\\d{12}"
|
1532
|
+
:bank_code_format: "[A-Z]{2}"
|
1533
|
+
:account_number_format: "\\d{12}"
|
1534
|
+
OM:
|
1535
|
+
:bank_code_position: 5
|
1536
|
+
:bank_code_length: 3
|
1537
|
+
:branch_code_position: 0
|
1538
|
+
:branch_code_length: 0
|
1539
|
+
:account_number_position: 8
|
1540
|
+
:account_number_length: 16
|
1541
|
+
:total_length: 23
|
1542
|
+
:national_id_length: 3
|
1543
|
+
:iban_example: OM810180000001299123456
|
1544
|
+
:bban_example: '0180000001299123456'
|
1545
|
+
:domestic_account_number_example: '0000001299123456'
|
1546
|
+
:bban_format: "\\d{3}[A-Z0-9]{16}"
|
1547
|
+
:bank_code_format: "\\d{3}"
|
1548
|
+
:account_number_format: "[A-Z0-9]{16}"
|
1549
|
+
YE:
|
1550
|
+
:bank_code_position: 5
|
1551
|
+
:bank_code_length: 4
|
1552
|
+
:branch_code_position: 9
|
1553
|
+
:branch_code_length: 4
|
1554
|
+
:account_number_position: 13
|
1555
|
+
:account_number_length: 18
|
1556
|
+
:total_length: 30
|
1557
|
+
:national_id_length: 8
|
1558
|
+
:iban_example: YE15CBYE0001018861234567891234
|
1559
|
+
:bban_example: CBYE0001018861234567891234
|
1560
|
+
:domestic_account_number_example: '018861234567891234'
|
1561
|
+
:bban_format: "[A-Z]{4}\\d{4}[A-Z0-9]{18}"
|
1562
|
+
:bank_code_format: "[A-Z]{4}"
|
1563
|
+
:branch_code_format: "\\d{4}"
|
1564
|
+
:account_number_format: "[A-Z0-9]{18}"
|
1482
1565
|
AU:
|
1483
1566
|
:bank_code_length: 0
|
1484
1567
|
:branch_code_length: 6
|
data/ibandit.gemspec
CHANGED
@@ -27,13 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
spec.required_ruby_version = ">= 2.7.0"
|
30
|
-
spec.add_development_dependency "gc_ruboconfig", "~> 5.0"
|
31
|
-
spec.add_development_dependency "nokogiri", "~> 1.6"
|
32
|
-
spec.add_development_dependency "pry", "~> 0.13"
|
33
|
-
spec.add_development_dependency "pry-byebug", "~> 3.10"
|
34
|
-
spec.add_development_dependency "rspec", "~> 3.12"
|
35
|
-
spec.add_development_dependency "rspec-its", "~> 1.2"
|
36
|
-
spec.add_development_dependency "sax-machine", "~> 1.3"
|
37
30
|
|
38
|
-
spec.
|
31
|
+
spec.add_dependency "i18n"
|
39
32
|
end
|
data/lib/ibandit/iban.rb
CHANGED
@@ -56,12 +56,14 @@ module Ibandit
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def account_number
|
59
|
+
return nil if @account_number.nil?
|
59
60
|
return @account_number unless country_code == "NZ"
|
60
61
|
|
61
62
|
@account_number[0..6]
|
62
63
|
end
|
63
64
|
|
64
65
|
def account_number_suffix
|
66
|
+
return nil if @account_number.nil?
|
65
67
|
return nil unless country_code == "NZ"
|
66
68
|
|
67
69
|
@account_number[7..]
|
@@ -128,6 +130,7 @@ module Ibandit
|
|
128
130
|
end
|
129
131
|
|
130
132
|
def valid_check_digits?
|
133
|
+
return true if source == :pseudo_iban && check_digits == Constants::PSEUDO_IBAN_CHECK_DIGITS
|
131
134
|
return unless decomposable? && valid_characters?
|
132
135
|
|
133
136
|
expected_check_digits = CheckDigit.iban(country_code, bban)
|
@@ -179,16 +182,15 @@ module Ibandit
|
|
179
182
|
return unless valid_country_code?
|
180
183
|
return true if swift_branch_code.to_s.length == structure[:branch_code_length]
|
181
184
|
|
182
|
-
if structure[:branch_code_length]&.zero?
|
183
|
-
|
185
|
+
@errors[:branch_code] = if structure[:branch_code_length]&.zero?
|
186
|
+
Ibandit.translate(:not_used_in_country,
|
184
187
|
country_code: country_code)
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
end
|
188
|
+
elsif swift_branch_code.nil? || swift_branch_code.empty?
|
189
|
+
Ibandit.translate(:is_required)
|
190
|
+
else
|
191
|
+
Ibandit.translate(:wrong_length,
|
192
|
+
expected: structure[:branch_code_length])
|
193
|
+
end
|
192
194
|
false
|
193
195
|
end
|
194
196
|
|
@@ -390,7 +392,6 @@ module Ibandit
|
|
390
392
|
valid_modulus_check_branch_code?
|
391
393
|
end
|
392
394
|
|
393
|
-
# rubocop:disable Metrics/AbcSize
|
394
395
|
def bank_code_passes_checksum_test?
|
395
396
|
return false unless swift_bank_code
|
396
397
|
return false if swift_bank_code.length != 9
|
@@ -407,8 +408,6 @@ module Ibandit
|
|
407
408
|
|
408
409
|
mod.zero?
|
409
410
|
end
|
410
|
-
# rubocop:enable Metrics/AbcSize
|
411
|
-
|
412
411
|
###################
|
413
412
|
# Private methods #
|
414
413
|
###################
|
@@ -64,7 +64,7 @@ module Ibandit
|
|
64
64
|
length += bank[:clearing_code_length] if bank[:include_clearing_code]
|
65
65
|
|
66
66
|
cleaned_account_number = account_number.gsub(/\A0+/, "")
|
67
|
-
if
|
67
|
+
if !bank[:include_clearing_code]
|
68
68
|
cleaned_account_number =
|
69
69
|
cleaned_account_number.
|
70
70
|
rjust(bank.fetch(:serial_number_length), "0")
|
data/lib/ibandit/version.rb
CHANGED
data/lib/ibandit.rb
CHANGED
@@ -30,10 +30,8 @@ module Ibandit
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def structures
|
33
|
-
@structures ||= YAML.
|
34
|
-
|
35
|
-
permitted_classes: [Range, Symbol],
|
36
|
-
)
|
33
|
+
@structures ||= YAML.safe_load_file(File.expand_path("../data/structures.yml", __dir__),
|
34
|
+
permitted_classes: [Range, Symbol])
|
37
35
|
end
|
38
36
|
|
39
37
|
def translate(key, options = {})
|
@@ -59,7 +59,7 @@ describe Ibandit::GermanDetailsConverter do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe "integration tests" do
|
62
|
-
|
62
|
+
it_behaves_like "json based fixture", "germany_integration_test_cases" do
|
63
63
|
let(:test_subject) do
|
64
64
|
described_class.
|
65
65
|
convert(bank_code: bank_code, account_number: account_number)
|
@@ -68,7 +68,7 @@ describe Ibandit::GermanDetailsConverter do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "unit tests" do
|
71
|
-
|
71
|
+
it_behaves_like "json based fixture", "germany_unit_test_cases" do
|
72
72
|
let(:test_subject) do
|
73
73
|
klass.new(bank_code, account_number).converted_details
|
74
74
|
end
|
@@ -293,11 +293,11 @@ describe Ibandit::IBANAssembler do
|
|
293
293
|
it_behaves_like "allows round trips", "ES80 2310 0001 1800 0001 2345"
|
294
294
|
|
295
295
|
context "without a bank_code or branch code" do
|
296
|
-
before
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
296
|
+
before do
|
297
|
+
args.delete(:bank_code)
|
298
|
+
args.delete(:branch_code)
|
299
|
+
args[:account_number] = "23100001180000012345"
|
300
|
+
end
|
301
301
|
|
302
302
|
it { is_expected.to be_nil }
|
303
303
|
end
|
@@ -487,27 +487,29 @@ describe Ibandit::IBANAssembler do
|
|
487
487
|
it_behaves_like "allows round trips", "HU42 1177 3016 1111 1018 0000 0000"
|
488
488
|
|
489
489
|
context "without a bank_code or branch_code" do
|
490
|
-
before
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
490
|
+
before do
|
491
|
+
args.delete(:bank_code)
|
492
|
+
args.delete(:branch_code)
|
493
|
+
args[:account_number] = "11773016-11111018-00000000"
|
494
|
+
end
|
495
495
|
|
496
496
|
it { is_expected.to be_nil }
|
497
497
|
end
|
498
498
|
|
499
499
|
context "without a bank_code" do
|
500
|
-
before
|
501
|
-
|
502
|
-
|
500
|
+
before do
|
501
|
+
args.delete(:bank_code)
|
502
|
+
args[:account_number] = "11773016-11111018-00000000"
|
503
|
+
end
|
503
504
|
|
504
505
|
it { is_expected.to be_nil }
|
505
506
|
end
|
506
507
|
|
507
508
|
context "without a branch_code" do
|
508
|
-
before
|
509
|
-
|
510
|
-
|
509
|
+
before do
|
510
|
+
args.delete(:branch_code)
|
511
|
+
args[:account_number] = "11773016-11111018-00000000"
|
512
|
+
end
|
511
513
|
|
512
514
|
it { is_expected.to be_nil }
|
513
515
|
end
|
@@ -826,9 +828,10 @@ describe Ibandit::IBANAssembler do
|
|
826
828
|
it_behaves_like "allows round trips", "NO93 8601 1117 947"
|
827
829
|
|
828
830
|
context "without a bank_code" do
|
829
|
-
before
|
830
|
-
|
831
|
-
|
831
|
+
before do
|
832
|
+
args.delete(:bank_code)
|
833
|
+
args[:account_number] = "86011117947"
|
834
|
+
end
|
832
835
|
|
833
836
|
it { is_expected.to be_nil }
|
834
837
|
end
|
@@ -854,9 +857,10 @@ describe Ibandit::IBANAssembler do
|
|
854
857
|
it_behaves_like "allows round trips", "PL60 1020 1026 0000 0422 7020 1111"
|
855
858
|
|
856
859
|
context "without a bank_code" do
|
857
|
-
before
|
858
|
-
|
859
|
-
|
860
|
+
before do
|
861
|
+
args.delete(:bank_code)
|
862
|
+
args[:account_number] = "60102010260000042270201111"
|
863
|
+
end
|
860
864
|
|
861
865
|
it { is_expected.to be_nil }
|
862
866
|
end
|