ibandit 1.0.2 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +12 -11
- data/CHANGELOG.md +23 -0
- data/README.md +1 -1
- data/Rakefile +8 -0
- data/data/raw/BLZ2.txt +0 -0
- data/data/raw/swedish_bank_lookup.yml +12 -2
- data/data/structures.yml +2 -2
- data/ibandit.gemspec +1 -1
- data/lib/ibandit/check_digit.rb +1 -1
- data/lib/ibandit/german_details_converter.rb +4 -4
- data/lib/ibandit/iban.rb +15 -6
- data/lib/ibandit/local_details_cleaner.rb +5 -3
- data/lib/ibandit/version.rb +1 -1
- data/spec/fixtures/germany_integration_test_cases.json +6 -0
- data/spec/fixtures/germany_unit_test_cases.json +11 -0
- data/spec/ibandit/iban_spec.rb +27 -4
- data/spec/ibandit/local_details_cleaner_spec.rb +6 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcfb5a1bd08fe566b25940dd4c44367bedfb375769c415e76fc58ad96e293106
|
4
|
+
data.tar.gz: d6be88d6d4ec124ec1b43e9379652b64c4a589b61bcce85ce6bdc128174d4bd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0036c8fe0d5607c75af4fc2aad7849f7df8f1b0e08c6fd85ec5ff376b3eef3e7f80139e76b4c67f80bc6cd05f156f4219d1cb11fea84b15bc23a3ee9c000a82b
|
7
|
+
data.tar.gz: 920e2b189dbf5d20e668226e0226ebe3cbee051077d66a136d691d8e5a42c1bc24448aae9eca7d2a12dac9026ee06dc9e7b6c2b194312c22aa24e9209523b9c7
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2020-08-25 10:15:35 UTC using RuboCop version 0.89.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 8
|
10
|
+
# Configuration parameters: IgnoredMethods.
|
10
11
|
Metrics/AbcSize:
|
11
12
|
Max: 25
|
12
13
|
|
13
|
-
# Offense count:
|
14
|
+
# Offense count: 2
|
15
|
+
# Configuration parameters: IgnoredMethods.
|
14
16
|
Metrics/CyclomaticComplexity:
|
15
17
|
Max: 8
|
16
18
|
|
@@ -23,7 +25,7 @@ Naming/MemoizedInstanceVariableName:
|
|
23
25
|
|
24
26
|
# Offense count: 1
|
25
27
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
26
|
-
# AllowedNames:
|
28
|
+
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
|
27
29
|
Naming/MethodParameterName:
|
28
30
|
Exclude:
|
29
31
|
- 'lib/ibandit/german_details_converter.rb'
|
@@ -45,25 +47,24 @@ RSpec/ExpectInHook:
|
|
45
47
|
- 'spec/ibandit/german_details_converter_spec.rb'
|
46
48
|
|
47
49
|
# Offense count: 12
|
48
|
-
# Configuration parameters: AggregateFailuresByDefault.
|
49
50
|
RSpec/MultipleExpectations:
|
50
51
|
Max: 2
|
51
52
|
|
53
|
+
# Offense count: 182
|
54
|
+
# Configuration parameters: AllowSubject.
|
55
|
+
RSpec/MultipleMemoizedHelpers:
|
56
|
+
Max: 7
|
57
|
+
|
52
58
|
# Offense count: 20
|
53
59
|
# Configuration parameters: IgnoreSharedExamples.
|
54
60
|
RSpec/NamedSubject:
|
55
61
|
Exclude:
|
56
62
|
- 'spec/ibandit/iban_spec.rb'
|
57
63
|
|
58
|
-
# Offense count:
|
64
|
+
# Offense count: 368
|
59
65
|
RSpec/NestedGroups:
|
60
66
|
Max: 6
|
61
67
|
|
62
|
-
# Offense count: 3
|
63
|
-
RSpec/ScatteredLet:
|
64
|
-
Exclude:
|
65
|
-
- 'spec/ibandit/iban_spec.rb'
|
66
|
-
|
67
68
|
# Offense count: 18
|
68
69
|
RSpec/ScatteredSetup:
|
69
70
|
Exclude:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
## 1.2.2 - October 30, 2020
|
2
|
+
|
3
|
+
- Update Swedish Bank data
|
4
|
+
|
5
|
+
## 1.2.1 - September 1, 2020
|
6
|
+
|
7
|
+
- Update BLZ data - BLZ_20200907
|
8
|
+
|
9
|
+
## 1.2.0 - August 25, 2020
|
10
|
+
|
11
|
+
- Improve validation for iban lengths
|
12
|
+
- Strip unwanted hyphen chars for Canadian IBANs
|
13
|
+
- Update rubocop and related gems
|
14
|
+
|
15
|
+
## 1.1.0.1 - June 17, 2020
|
16
|
+
|
17
|
+
- Fix Rule4901
|
18
|
+
|
19
|
+
## 1.1.0 - June 15, 2020
|
20
|
+
|
21
|
+
- Update BLZ data
|
22
|
+
- Fix Rule4901
|
23
|
+
|
1
24
|
## 1.0.2 - May 12, 2020
|
2
25
|
|
3
26
|
- Update BLZ data
|
data/README.md
CHANGED
data/Rakefile
ADDED
data/data/raw/BLZ2.txt
CHANGED
File without changes
|
@@ -1,8 +1,10 @@
|
|
1
1
|
---
|
2
2
|
# Sources:
|
3
3
|
# - https://sv.wikipedia.org/wiki/Lista_%C3%B6ver_clearingnummer_till_svenska_banker
|
4
|
-
# - http://www.bgc.se/globalassets/dokument/tekniska-manualer/bankernaskontonummeruppbyggnad_tekniskmanual_sv.pdf
|
5
|
-
# -
|
4
|
+
# - Source before October 2020 (link now broken): http://www.bgc.se/globalassets/dokument/tekniska-manualer/bankernaskontonummeruppbyggnad_tekniskmanual_sv.pdf
|
5
|
+
# - As of 30/10/2020: https://www.bankgirot.se/globalassets/dokument/anvandarmanualer/bankernaskontonummeruppbyggnad_anvandarmanual_sv.pdf
|
6
|
+
# - Swedish Bankers' Association clearing numbers: https://www.swedishbankers.se/media/4245/1906_clearingnummer-institut.pdf
|
7
|
+
# - https://transferwise.com/gb/iban/sweden
|
6
8
|
#
|
7
9
|
# Fields:
|
8
10
|
# - Range: The range of clearing codes for this bank. Used to
|
@@ -400,6 +402,14 @@
|
|
400
402
|
:zerofill_serial_number: false
|
401
403
|
:include_clearing_code: true
|
402
404
|
:validation_scheme: '1.2'
|
405
|
+
- :range: [9770, 9779]
|
406
|
+
:bank: INTERGIRO INTL AB (PUBL)
|
407
|
+
:bank_code: 977
|
408
|
+
:clearing_code_length: 4
|
409
|
+
:serial_number_length: 17
|
410
|
+
:zerofill_serial_number: true
|
411
|
+
:include_clearing_code: false
|
412
|
+
:validation_scheme: '1.1'
|
403
413
|
- :range: [9880, 9889]
|
404
414
|
:bank: Riksgälden
|
405
415
|
:bank_code: 988
|
data/data/structures.yml
CHANGED
@@ -95,7 +95,7 @@ BE:
|
|
95
95
|
:national_id_length: 3
|
96
96
|
:bban_format: "\\d{3}\\d{7}\\d{2}"
|
97
97
|
:bank_code_format: "\\d{3}"
|
98
|
-
:account_number_format: "\\d{7}\\d{2}"
|
98
|
+
:account_number_format: "\\d{7}\\d{2}\\d{3}"
|
99
99
|
:local_check_digit_position: 15
|
100
100
|
:local_check_digit_length: 2
|
101
101
|
BG:
|
@@ -902,7 +902,7 @@ US:
|
|
902
902
|
:branch_code_length: 0
|
903
903
|
:account_number_length: 17
|
904
904
|
:bank_code_format: "\\d{9}"
|
905
|
-
:account_number_format: "
|
905
|
+
:account_number_format: "_*\\d{1,17}"
|
906
906
|
:national_id_length: 9
|
907
907
|
:pseudo_iban_bank_code_length: 9
|
908
908
|
:pseudo_iban_branch_code_length: 0
|
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", "~> 2.
|
6
|
+
gem.add_development_dependency "gc_ruboconfig", "~> 2.20.0"
|
7
7
|
gem.add_development_dependency "nokogiri", "~> 1.6"
|
8
8
|
gem.add_development_dependency "pry", "~> 0.10"
|
9
9
|
gem.add_development_dependency "pry-nav", "~> 0.2"
|
data/lib/ibandit/check_digit.rb
CHANGED
@@ -307,7 +307,7 @@ module Ibandit
|
|
307
307
|
end
|
308
308
|
|
309
309
|
def sum_of_weighted_values
|
310
|
-
weighted_values.
|
310
|
+
weighted_values.sum
|
311
311
|
end
|
312
312
|
|
313
313
|
def weighted_values
|
@@ -550,7 +550,7 @@ module Ibandit
|
|
550
550
|
end
|
551
551
|
|
552
552
|
def sum_of_weighted_digits
|
553
|
-
weighted_digits.
|
553
|
+
weighted_digits.sum
|
554
554
|
end
|
555
555
|
|
556
556
|
def weighted_digits
|
@@ -1045,8 +1045,8 @@ module Ibandit
|
|
1045
1045
|
end
|
1046
1046
|
end
|
1047
1047
|
|
1048
|
-
class
|
1049
|
-
# Rule 0049
|
1048
|
+
class Rule004901 < Rule000000
|
1049
|
+
# Rule 0049 01 is actually about modulus checking, not IBAN construction
|
1050
1050
|
end
|
1051
1051
|
|
1052
1052
|
class Rule005000 < BaseRule
|
data/lib/ibandit/iban.rb
CHANGED
@@ -9,7 +9,8 @@ module Ibandit
|
|
9
9
|
:swift_account_number, :source
|
10
10
|
|
11
11
|
def initialize(argument)
|
12
|
-
|
12
|
+
case argument
|
13
|
+
when String
|
13
14
|
input = argument.to_s.gsub(/\s+/, "").upcase
|
14
15
|
|
15
16
|
pseudo_iban_splitter = PseudoIBANSplitter.new(input)
|
@@ -24,7 +25,7 @@ module Ibandit
|
|
24
25
|
@iban = input
|
25
26
|
extract_swift_details_from_iban!
|
26
27
|
end
|
27
|
-
|
28
|
+
when Hash
|
28
29
|
@source = :local_details
|
29
30
|
build_iban_from_local_details(argument)
|
30
31
|
else
|
@@ -225,7 +226,7 @@ module Ibandit
|
|
225
226
|
return unless valid_country_code?
|
226
227
|
return unless structure[:bban_format]
|
227
228
|
|
228
|
-
if bban&.match?(
|
229
|
+
if bban&.match?(entire_string_regex(structure[:bban_format]))
|
229
230
|
true
|
230
231
|
else
|
231
232
|
@errors[:format] = Ibandit.translate(:invalid_format,
|
@@ -238,7 +239,9 @@ module Ibandit
|
|
238
239
|
return unless valid_bank_code_length?
|
239
240
|
return true if structure[:bank_code_length]&.zero?
|
240
241
|
|
241
|
-
if swift_bank_code&.match?(
|
242
|
+
if swift_bank_code&.match?(
|
243
|
+
entire_string_regex(structure[:bank_code_format]),
|
244
|
+
)
|
242
245
|
true
|
243
246
|
else
|
244
247
|
@errors[:bank_code] = Ibandit.translate(:is_invalid)
|
@@ -250,7 +253,9 @@ module Ibandit
|
|
250
253
|
return unless valid_branch_code_length?
|
251
254
|
return true unless structure[:branch_code_format]
|
252
255
|
|
253
|
-
if swift_branch_code&.match?(
|
256
|
+
if swift_branch_code&.match?(
|
257
|
+
entire_string_regex(structure[:branch_code_format]),
|
258
|
+
)
|
254
259
|
true
|
255
260
|
else
|
256
261
|
@errors[:branch_code] = Ibandit.translate(:is_invalid)
|
@@ -262,7 +267,7 @@ module Ibandit
|
|
262
267
|
return unless valid_account_number_length?
|
263
268
|
|
264
269
|
if swift_account_number&.match?(
|
265
|
-
|
270
|
+
entire_string_regex(structure[:account_number_format]),
|
266
271
|
)
|
267
272
|
true
|
268
273
|
else
|
@@ -499,6 +504,10 @@ module Ibandit
|
|
499
504
|
Ibandit.structures[country_code]
|
500
505
|
end
|
501
506
|
|
507
|
+
def entire_string_regex(pattern)
|
508
|
+
Regexp.new("\\A#{pattern}\\z")
|
509
|
+
end
|
510
|
+
|
502
511
|
def formatted
|
503
512
|
iban.to_s.gsub(/(.{4})/, '\1 ').strip
|
504
513
|
end
|
@@ -89,7 +89,9 @@ module Ibandit
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.clean_ca_details(local_details)
|
92
|
-
|
92
|
+
account_number = local_details[:account_number].tr("-", "")
|
93
|
+
|
94
|
+
return {} if account_number.length < 7 # minimum length
|
93
95
|
|
94
96
|
bank_code = if local_details[:bank_code].length == 3
|
95
97
|
local_details[:bank_code].rjust(4, "0")
|
@@ -98,7 +100,7 @@ module Ibandit
|
|
98
100
|
end
|
99
101
|
|
100
102
|
{
|
101
|
-
account_number:
|
103
|
+
account_number: account_number.rjust(12, "0"),
|
102
104
|
bank_code: bank_code,
|
103
105
|
}
|
104
106
|
end
|
@@ -512,7 +514,7 @@ module Ibandit
|
|
512
514
|
bank_code = local_details[:bank_code]
|
513
515
|
account_number = local_details[:account_number]
|
514
516
|
else
|
515
|
-
cleaned_acct_number = local_details[:account_number].gsub(
|
517
|
+
cleaned_acct_number = local_details[:account_number].gsub(/\s/, "")
|
516
518
|
|
517
519
|
bank_code = cleaned_acct_number.slice(2, 8)
|
518
520
|
account_number = cleaned_acct_number[10..-1]
|
data/lib/ibandit/version.rb
CHANGED
@@ -160,6 +160,12 @@
|
|
160
160
|
"valid": [
|
161
161
|
{ "bank_code": "39060180", "account_number": "556", "converted_account_number": "0120440110" }
|
162
162
|
]
|
163
|
+
},
|
164
|
+
{
|
165
|
+
"convertor": "004901",
|
166
|
+
"valid": [
|
167
|
+
{ "bank_code": "30060010", "account_number": "12345678", "converted_account_number": "12345678" }
|
168
|
+
]
|
163
169
|
}
|
164
170
|
// {
|
165
171
|
// "convertor": "001900",
|
@@ -435,5 +435,16 @@
|
|
435
435
|
"valid": [
|
436
436
|
{ "bank_code": "10010010", "account_number" : "1234567890", "converted_bank_code": "66010200" }
|
437
437
|
]
|
438
|
+
},
|
439
|
+
{
|
440
|
+
"convertor": "004901",
|
441
|
+
"valid": [
|
442
|
+
{
|
443
|
+
"bank_code": "30060010",
|
444
|
+
"account_number": "1234567890",
|
445
|
+
"converted_bank_code": "30060010",
|
446
|
+
"converted_account_number": "1234567890"
|
447
|
+
}
|
448
|
+
]
|
438
449
|
}
|
439
450
|
]
|
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -112,6 +112,22 @@ describe Ibandit::IBAN do
|
|
112
112
|
its(:local_check_digits) { is_expected.to be_nil }
|
113
113
|
end
|
114
114
|
|
115
|
+
context "when the IBAN was created from a Belgian IBAN" do
|
116
|
+
let(:iban_code) { "BE62510007547061" }
|
117
|
+
|
118
|
+
its(:country_code) { is_expected.to eq("BE") }
|
119
|
+
its(:bank_code) { is_expected.to eq("510") }
|
120
|
+
its(:branch_code) { is_expected.to be_nil }
|
121
|
+
its(:account_number) { is_expected.to eq("510007547061") }
|
122
|
+
its(:account_number_suffix) { is_expected.to be_nil }
|
123
|
+
its(:swift_bank_code) { is_expected.to eq("510") }
|
124
|
+
its(:swift_branch_code) { is_expected.to be_nil }
|
125
|
+
its(:swift_account_number) { is_expected.to eq("510007547061") }
|
126
|
+
its(:swift_national_id) { is_expected.to eq("510") }
|
127
|
+
its(:local_check_digits) { is_expected.to eq("61") }
|
128
|
+
its(:bban) { is_expected.to eq("510007547061") }
|
129
|
+
end
|
130
|
+
|
115
131
|
context "when the IBAN was created with local details" do
|
116
132
|
let(:arg) do
|
117
133
|
{
|
@@ -452,6 +468,13 @@ describe Ibandit::IBAN do
|
|
452
468
|
its(:to_s) { is_expected.to eq("") }
|
453
469
|
end
|
454
470
|
|
471
|
+
context "and account number has invalid characters in" do
|
472
|
+
let(:account_number) { "123456XX789" }
|
473
|
+
let(:bank_code) { "0036" }
|
474
|
+
|
475
|
+
its(:valid?) { is_expected.to be false }
|
476
|
+
end
|
477
|
+
|
455
478
|
context "and a 12 digit account number" do
|
456
479
|
let(:account_number) { "012345678900" }
|
457
480
|
let(:bank_code) { "0036" }
|
@@ -2247,16 +2270,16 @@ describe Ibandit::IBAN do
|
|
2247
2270
|
|
2248
2271
|
context "with an invalid branch code" do
|
2249
2272
|
let(:iban_code) { "GB60BARC20000055779911" }
|
2273
|
+
let(:valid_bank_code) { true }
|
2274
|
+
let(:valid_branch_code) { false }
|
2275
|
+
let(:valid_account_number) { true }
|
2276
|
+
|
2250
2277
|
before { Ibandit.bic_finder = double(call: "BARCGB22XXX") }
|
2251
2278
|
|
2252
2279
|
after { Ibandit.bic_finder = nil }
|
2253
2280
|
|
2254
2281
|
before { iban.valid_local_modulus_check? }
|
2255
2282
|
|
2256
|
-
let(:valid_bank_code) { true }
|
2257
|
-
let(:valid_branch_code) { false }
|
2258
|
-
let(:valid_account_number) { true }
|
2259
|
-
|
2260
2283
|
it "calls valid_branch_code? with an IBAN object" do
|
2261
2284
|
expect(Ibandit.modulus_checker).
|
2262
2285
|
to receive(:valid_branch_code?).
|
@@ -167,6 +167,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
167
167
|
its([:country_code]) { is_expected.to eq(country_code) }
|
168
168
|
its([:bank_code]) { is_expected.to eq("0036") }
|
169
169
|
its([:branch_code]) { is_expected.to eq("00063") }
|
170
|
+
|
171
|
+
context "with a hyphen" do
|
172
|
+
let(:account_number) { "0123456-789" }
|
173
|
+
|
174
|
+
its([:account_number]) { is_expected.to eq("000123456789") }
|
175
|
+
end
|
170
176
|
end
|
171
177
|
|
172
178
|
context "Cyprus" 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.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-30 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: 2.
|
19
|
+
version: 2.20.0
|
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: 2.
|
26
|
+
version: 2.20.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- Gemfile
|
154
154
|
- LICENSE
|
155
155
|
- README.md
|
156
|
+
- Rakefile
|
156
157
|
- TODO.md
|
157
158
|
- bin/build_german_iban_rules.rb
|
158
159
|
- bin/build_structure_file.rb
|
@@ -223,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
224
|
- !ruby/object:Gem::Version
|
224
225
|
version: '0'
|
225
226
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
227
|
+
rubygems_version: 3.1.4
|
227
228
|
signing_key:
|
228
229
|
specification_version: 4
|
229
230
|
summary: Convert national banking details into IBANs, and vice-versa.
|