ibandit 0.7.0 → 0.8.0
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 -1
- data/CHANGELOG.md +4 -0
- data/README.md +48 -6
- data/data/raw/structure_additions.yml +4 -0
- data/data/structures.yml +3 -0
- data/ibandit.gemspec +4 -4
- data/lib/ibandit.rb +3 -0
- data/lib/ibandit/constants.rb +10 -0
- data/lib/ibandit/iban.rb +82 -32
- data/lib/ibandit/iban_assembler.rb +5 -6
- data/lib/ibandit/local_details_cleaner.rb +29 -11
- data/lib/ibandit/pseudo_iban_assembler.rb +77 -0
- data/lib/ibandit/pseudo_iban_splitter.rb +86 -0
- data/lib/ibandit/swedish_details_converter.rb +80 -33
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_assembler_spec.rb +3 -3
- data/spec/ibandit/iban_spec.rb +61 -4
- data/spec/ibandit/local_details_cleaner_spec.rb +118 -106
- data/spec/ibandit/pseudo_iban_assembler_spec.rb +54 -0
- data/spec/ibandit/pseudo_iban_splitter_spec.rb +36 -0
- data/spec/ibandit/swedish_details_converter_spec.rb +112 -37
- metadata +34 -29
@@ -0,0 +1,77 @@
|
|
1
|
+
module Ibandit
|
2
|
+
class PseudoIBANAssembler
|
3
|
+
def initialize(country_code: nil,
|
4
|
+
bank_code: nil,
|
5
|
+
branch_code: nil,
|
6
|
+
account_number: nil)
|
7
|
+
@country_code = country_code
|
8
|
+
@bank_code = bank_code
|
9
|
+
@branch_code = branch_code
|
10
|
+
@account_number = account_number
|
11
|
+
end
|
12
|
+
|
13
|
+
def assemble
|
14
|
+
return unless can_assemble?
|
15
|
+
|
16
|
+
[
|
17
|
+
@country_code,
|
18
|
+
Constants::PSEUDO_IBAN_CHECK_DIGITS,
|
19
|
+
padded_bank_code,
|
20
|
+
padded_branch_code,
|
21
|
+
padded_account_number
|
22
|
+
].join
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def can_assemble?
|
28
|
+
country_code_valid? &&
|
29
|
+
bank_code_valid? &&
|
30
|
+
branch_code_valid? &&
|
31
|
+
account_number_valid?
|
32
|
+
end
|
33
|
+
|
34
|
+
def country_code_valid?
|
35
|
+
Constants::PSEUDO_IBAN_COUNTRY_CODES.include?(@country_code)
|
36
|
+
end
|
37
|
+
|
38
|
+
def bank_code_valid?
|
39
|
+
param_valid?(@bank_code, :pseudo_iban_bank_code_length)
|
40
|
+
end
|
41
|
+
|
42
|
+
def branch_code_valid?
|
43
|
+
param_valid?(@branch_code, :pseudo_iban_branch_code_length)
|
44
|
+
end
|
45
|
+
|
46
|
+
def account_number_valid?
|
47
|
+
param_valid?(@account_number, :pseudo_iban_account_number_length)
|
48
|
+
end
|
49
|
+
|
50
|
+
def param_valid?(value, length_key)
|
51
|
+
return true unless value.nil?
|
52
|
+
return true if structure[length_key] == 0
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
def padded_bank_code
|
57
|
+
pad(@bank_code, :pseudo_iban_bank_code_length)
|
58
|
+
end
|
59
|
+
|
60
|
+
def padded_branch_code
|
61
|
+
pad(@branch_code, :pseudo_iban_branch_code_length)
|
62
|
+
end
|
63
|
+
|
64
|
+
def padded_account_number
|
65
|
+
pad(@account_number, :pseudo_iban_account_number_length)
|
66
|
+
end
|
67
|
+
|
68
|
+
def pad(number, length_key)
|
69
|
+
return if number.nil?
|
70
|
+
number.rjust(structure[length_key], 'X')
|
71
|
+
end
|
72
|
+
|
73
|
+
def structure
|
74
|
+
Ibandit.structures.fetch(@country_code)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Ibandit
|
2
|
+
class PseudoIBANSplitter
|
3
|
+
def initialize(pseudo_iban)
|
4
|
+
@pseudo_iban = pseudo_iban
|
5
|
+
end
|
6
|
+
|
7
|
+
def split
|
8
|
+
return unless decomposable?
|
9
|
+
|
10
|
+
{
|
11
|
+
country_code: country_code,
|
12
|
+
bank_code: bank_code,
|
13
|
+
branch_code: branch_code,
|
14
|
+
account_number: account_number
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def country_code
|
21
|
+
@pseudo_iban.slice(0, 2)
|
22
|
+
end
|
23
|
+
|
24
|
+
def check_digits
|
25
|
+
@pseudo_iban.slice(2, 2)
|
26
|
+
end
|
27
|
+
|
28
|
+
def bank_code
|
29
|
+
pseudo_iban_part(bank_code_start_index, :pseudo_iban_bank_code_length)
|
30
|
+
end
|
31
|
+
|
32
|
+
def branch_code
|
33
|
+
pseudo_iban_part(branch_code_start_index,
|
34
|
+
:pseudo_iban_branch_code_length)
|
35
|
+
end
|
36
|
+
|
37
|
+
def account_number
|
38
|
+
pseudo_iban_part(account_number_start_index,
|
39
|
+
:pseudo_iban_account_number_length)
|
40
|
+
end
|
41
|
+
|
42
|
+
def pseudo_iban_part(start_index, length_key)
|
43
|
+
length = structure.fetch(length_key)
|
44
|
+
return if length == 0
|
45
|
+
|
46
|
+
@pseudo_iban.slice(start_index, length).gsub(/\AX+/, '')
|
47
|
+
end
|
48
|
+
|
49
|
+
def bank_code_start_index
|
50
|
+
4
|
51
|
+
end
|
52
|
+
|
53
|
+
def branch_code_start_index
|
54
|
+
bank_code_start_index + structure.fetch(:pseudo_iban_bank_code_length)
|
55
|
+
end
|
56
|
+
|
57
|
+
def account_number_start_index
|
58
|
+
branch_code_start_index + structure.fetch(:pseudo_iban_branch_code_length)
|
59
|
+
end
|
60
|
+
|
61
|
+
def expected_length
|
62
|
+
account_number_start_index +
|
63
|
+
structure.fetch(:pseudo_iban_account_number_length)
|
64
|
+
end
|
65
|
+
|
66
|
+
def decomposable?
|
67
|
+
country_code_valid? && check_digits_valid? && correct_length?
|
68
|
+
end
|
69
|
+
|
70
|
+
def country_code_valid?
|
71
|
+
Constants::PSEUDO_IBAN_COUNTRY_CODES.include?(country_code)
|
72
|
+
end
|
73
|
+
|
74
|
+
def check_digits_valid?
|
75
|
+
check_digits == Constants::PSEUDO_IBAN_CHECK_DIGITS
|
76
|
+
end
|
77
|
+
|
78
|
+
def correct_length?
|
79
|
+
@pseudo_iban.length == expected_length
|
80
|
+
end
|
81
|
+
|
82
|
+
def structure
|
83
|
+
Ibandit.structures[country_code]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,41 +1,92 @@
|
|
1
1
|
module Ibandit
|
2
|
-
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
bank_info = bank_info_for(cleaned_account_number.slice(0, 4))
|
2
|
+
class SwedishDetailsConverter
|
3
|
+
def initialize(branch_code: nil, account_number: nil)
|
4
|
+
@branch_code = branch_code
|
5
|
+
@account_number = account_number
|
6
|
+
end
|
8
7
|
|
8
|
+
def convert
|
9
9
|
if bank_info.nil?
|
10
|
-
return {
|
11
|
-
|
10
|
+
return { swift_bank_code: nil,
|
11
|
+
swift_account_number: cleaned_account_number.rjust(17, '0') }
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
{
|
15
|
+
account_number: serial_number,
|
16
|
+
branch_code: clearing_code,
|
17
|
+
swift_bank_code: bank_info.fetch(:bank_code).to_s,
|
18
|
+
swift_account_number: swift_account_number
|
19
|
+
}
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
serial_number = cleaned_account_number[clearing_code_length..-1]
|
22
|
+
private
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
24
|
+
def cleaned_account_number
|
25
|
+
# Don't trim leading zeroes if the account number we are given is a
|
26
|
+
# serial number (i.e. if the clearing code is separate).
|
27
|
+
@cleaned_account_number ||= if @branch_code.nil?
|
28
|
+
clean_account_number(@account_number)
|
29
|
+
else
|
30
|
+
remove_bad_chars(@account_number)
|
31
|
+
end
|
32
|
+
end
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
serial_number.rjust(17, '0')
|
29
|
-
end
|
34
|
+
def cleaned_branch_code
|
35
|
+
@cleaned_branch_code ||= remove_bad_chars(@branch_code)
|
36
|
+
end
|
30
37
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
def remove_bad_chars(number)
|
39
|
+
return if number.nil?
|
40
|
+
number.gsub(/[-.\s]/, '')
|
41
|
+
end
|
42
|
+
|
43
|
+
def clean_account_number(number)
|
44
|
+
return if number.nil?
|
45
|
+
remove_bad_chars(number).gsub(/\A0+/, '')
|
46
|
+
end
|
47
|
+
|
48
|
+
def bank_info
|
49
|
+
@bank_info ||= self.class.bank_info_for(bank_info_key)
|
35
50
|
end
|
36
51
|
|
37
|
-
def
|
38
|
-
|
52
|
+
def bank_info_key
|
53
|
+
(cleaned_branch_code || cleaned_account_number).slice(0, 4)
|
54
|
+
end
|
55
|
+
|
56
|
+
def clearing_code_length
|
57
|
+
bank_info.fetch(:clearing_code_length)
|
58
|
+
end
|
59
|
+
|
60
|
+
def serial_number_length
|
61
|
+
bank_info.fetch(:serial_number_length)
|
62
|
+
end
|
63
|
+
|
64
|
+
def clearing_code
|
65
|
+
cleaned_branch_code ||
|
66
|
+
cleaned_account_number.slice(0, clearing_code_length)
|
67
|
+
end
|
68
|
+
|
69
|
+
def serial_number
|
70
|
+
serial_number = if @branch_code.nil?
|
71
|
+
cleaned_account_number[clearing_code_length..-1]
|
72
|
+
else
|
73
|
+
cleaned_account_number
|
74
|
+
end
|
75
|
+
|
76
|
+
return serial_number unless bank_info.fetch(:zerofill_serial_number)
|
77
|
+
|
78
|
+
serial_number.rjust(serial_number_length, '0')
|
79
|
+
end
|
80
|
+
|
81
|
+
def swift_account_number
|
82
|
+
if bank_info.fetch(:include_clearing_code)
|
83
|
+
(clearing_code + serial_number).rjust(17, '0')
|
84
|
+
else
|
85
|
+
serial_number.rjust(17, '0')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.valid_bank_code?(bank_code: nil, account_number: nil)
|
39
90
|
possible_bank_infos = possible_bank_info_for(
|
40
91
|
bank_code: bank_code, account_number: account_number
|
41
92
|
)
|
@@ -43,7 +94,7 @@ module Ibandit
|
|
43
94
|
possible_bank_infos.any?
|
44
95
|
end
|
45
96
|
|
46
|
-
def self.valid_length?(bank_code:
|
97
|
+
def self.valid_length?(bank_code: nil, account_number: nil)
|
47
98
|
return unless valid_bank_code?(
|
48
99
|
bank_code: bank_code, account_number: account_number
|
49
100
|
)
|
@@ -68,15 +119,11 @@ module Ibandit
|
|
68
119
|
end
|
69
120
|
end
|
70
121
|
|
71
|
-
private
|
72
|
-
|
73
122
|
def self.bank_info_for(clearing_code)
|
74
123
|
bank_info_table.find { |bank| bank[:range].include?(clearing_code.to_i) }
|
75
124
|
end
|
76
|
-
private_class_method :bank_info_for
|
77
125
|
|
78
|
-
def self.possible_bank_info_for(bank_code:
|
79
|
-
account_number: account_number)
|
126
|
+
def self.possible_bank_info_for(bank_code: nil, account_number: nil)
|
80
127
|
clearing_number = account_number.gsub(/\A0+/, '').slice(0, 4).to_i
|
81
128
|
|
82
129
|
possible_bank_infos = bank_info_table.select do |bank|
|
data/lib/ibandit/version.rb
CHANGED
@@ -6,9 +6,9 @@ describe Ibandit::IBANAssembler do
|
|
6
6
|
let(:args) do
|
7
7
|
{
|
8
8
|
country_code: iban.country_code,
|
9
|
-
account_number: iban.
|
10
|
-
branch_code: iban.
|
11
|
-
bank_code: iban.
|
9
|
+
account_number: iban.swift_account_number,
|
10
|
+
branch_code: iban.swift_branch_code,
|
11
|
+
bank_code: iban.swift_bank_code
|
12
12
|
}.reject { |_key, value| value.nil? }
|
13
13
|
end
|
14
14
|
|
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -49,6 +49,9 @@ describe Ibandit::IBAN do
|
|
49
49
|
its(:bank_code) { is_expected.to eq('WEST') }
|
50
50
|
its(:branch_code) { is_expected.to eq('123456') }
|
51
51
|
its(:account_number) { is_expected.to eq('98765432') }
|
52
|
+
its(:swift_bank_code) { is_expected.to eq('WEST') }
|
53
|
+
its(:swift_branch_code) { is_expected.to eq('123456') }
|
54
|
+
its(:swift_account_number) { is_expected.to eq('98765432') }
|
52
55
|
its(:iban_national_id) { is_expected.to eq('WEST123456') }
|
53
56
|
its(:local_check_digits) { is_expected.to be_nil }
|
54
57
|
|
@@ -65,6 +68,21 @@ describe Ibandit::IBAN do
|
|
65
68
|
its(:local_check_digits) { is_expected.to be_nil }
|
66
69
|
end
|
67
70
|
|
71
|
+
context 'when local details are not available' do
|
72
|
+
let(:iban_code) { 'SE2680000000075071211203' }
|
73
|
+
|
74
|
+
its(:country_code) { is_expected.to eq('SE') }
|
75
|
+
its(:check_digits) { is_expected.to eq('26') }
|
76
|
+
its(:bank_code) { is_expected.to be_nil }
|
77
|
+
its(:branch_code) { is_expected.to be_nil }
|
78
|
+
its(:account_number) { is_expected.to be_nil }
|
79
|
+
its(:swift_bank_code) { is_expected.to eq('800') }
|
80
|
+
its(:swift_branch_code) { is_expected.to be_nil }
|
81
|
+
its(:swift_account_number) { is_expected.to eq('00000075071211203') }
|
82
|
+
its(:iban_national_id) { is_expected.to eq('800') }
|
83
|
+
its(:local_check_digits) { is_expected.to be_nil }
|
84
|
+
end
|
85
|
+
|
68
86
|
context 'when the IBAN was created with local details' do
|
69
87
|
let(:arg) do
|
70
88
|
{
|
@@ -79,6 +97,43 @@ describe Ibandit::IBAN do
|
|
79
97
|
its(:bank_code) { is_expected.to eq(arg[:bank_code]) }
|
80
98
|
its(:branch_code) { is_expected.to eq(arg[:branch_code]) }
|
81
99
|
its(:account_number) { is_expected.to eq(arg[:account_number]) }
|
100
|
+
its(:swift_bank_code) { is_expected.to eq(arg[:bank_code]) }
|
101
|
+
its(:swift_branch_code) { is_expected.to eq(arg[:branch_code]) }
|
102
|
+
its(:swift_account_number) { is_expected.to eq(arg[:account_number]) }
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when the IBAN was created with local details for Sweden' do
|
106
|
+
let(:arg) do
|
107
|
+
{
|
108
|
+
country_code: 'SE',
|
109
|
+
branch_code: '1281',
|
110
|
+
account_number: '0105723'
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
its(:country_code) { is_expected.to eq(arg[:country_code]) }
|
115
|
+
its(:bank_code) { is_expected.to eq(arg[:bank_code]) }
|
116
|
+
its(:branch_code) { is_expected.to eq(arg[:branch_code]) }
|
117
|
+
its(:account_number) { is_expected.to eq(arg[:account_number]) }
|
118
|
+
its(:swift_bank_code) { is_expected.to eq('120') }
|
119
|
+
its(:swift_branch_code) { is_expected.to be_nil }
|
120
|
+
its(:swift_account_number) { is_expected.to eq('00000012810105723') }
|
121
|
+
its(:iban) { is_expected.to eq('SE5412000000012810105723') }
|
122
|
+
its(:pseudo_iban) { is_expected.to eq('SEZZX1281XXX0105723') }
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when the IBAN was created from a pseudo-IBAN' do
|
126
|
+
let(:arg) { 'SEZZX1281XXX0105723' }
|
127
|
+
|
128
|
+
its(:country_code) { is_expected.to eq('SE') }
|
129
|
+
its(:bank_code) { is_expected.to be_nil }
|
130
|
+
its(:branch_code) { is_expected.to eq('1281') }
|
131
|
+
its(:account_number) { is_expected.to eq('0105723') }
|
132
|
+
its(:swift_bank_code) { is_expected.to eq('120') }
|
133
|
+
its(:swift_branch_code) { is_expected.to be_nil }
|
134
|
+
its(:swift_account_number) { is_expected.to eq('00000012810105723') }
|
135
|
+
its(:iban) { is_expected.to eq('SE5412000000012810105723') }
|
136
|
+
its(:pseudo_iban) { is_expected.to eq('SEZZX1281XXX0105723') }
|
82
137
|
end
|
83
138
|
end
|
84
139
|
|
@@ -358,7 +413,7 @@ describe Ibandit::IBAN do
|
|
358
413
|
end
|
359
414
|
|
360
415
|
context 'with invalid details' do
|
361
|
-
before { allow(iban).to receive(:
|
416
|
+
before { allow(iban).to receive(:swift_bank_code).and_return('WES') }
|
362
417
|
it { is_expected.to eq(false) }
|
363
418
|
|
364
419
|
context 'locale en', locale: :en do
|
@@ -444,7 +499,7 @@ describe Ibandit::IBAN do
|
|
444
499
|
end
|
445
500
|
|
446
501
|
context 'with invalid details' do
|
447
|
-
before { allow(iban).to receive(:
|
502
|
+
before { allow(iban).to receive(:swift_branch_code).and_return('12345') }
|
448
503
|
it { is_expected.to eq(false) }
|
449
504
|
|
450
505
|
context 'locale en', locale: :en do
|
@@ -512,7 +567,7 @@ describe Ibandit::IBAN do
|
|
512
567
|
end
|
513
568
|
|
514
569
|
context 'without a branch code' do
|
515
|
-
before { allow(iban).to receive(:
|
570
|
+
before { allow(iban).to receive(:swift_branch_code).and_return(nil) }
|
516
571
|
it { is_expected.to eq(false) }
|
517
572
|
|
518
573
|
context 'locale en', locale: :en do
|
@@ -584,7 +639,9 @@ describe Ibandit::IBAN do
|
|
584
639
|
end
|
585
640
|
|
586
641
|
context 'with an invalid account_number' do
|
587
|
-
before
|
642
|
+
before do
|
643
|
+
allow(iban).to receive(:swift_account_number).and_return('1234567')
|
644
|
+
end
|
588
645
|
it { is_expected.to eq(false) }
|
589
646
|
|
590
647
|
context 'locale en', locale: :en do
|
@@ -10,18 +10,27 @@ describe Ibandit::LocalDetailsCleaner do
|
|
10
10
|
account_number: account_number
|
11
11
|
}
|
12
12
|
end
|
13
|
+
|
14
|
+
let(:local_details_with_swift) do
|
15
|
+
local_details.merge(
|
16
|
+
swift_bank_code: bank_code,
|
17
|
+
swift_branch_code: branch_code,
|
18
|
+
swift_account_number: account_number
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
13
22
|
let(:country_code) { nil }
|
14
23
|
let(:bank_code) { nil }
|
15
24
|
let(:branch_code) { nil }
|
16
25
|
let(:account_number) { nil }
|
17
26
|
|
18
27
|
context 'without country code' do
|
19
|
-
it { is_expected.to eq(
|
28
|
+
it { is_expected.to eq(local_details_with_swift) }
|
20
29
|
end
|
21
30
|
|
22
31
|
context 'with an unsupported country code' do
|
23
32
|
let(:country_code) { 'FU' }
|
24
|
-
it { is_expected.to eq(
|
33
|
+
it { is_expected.to eq(local_details_with_swift) }
|
25
34
|
end
|
26
35
|
|
27
36
|
context 'Austria' do
|
@@ -29,7 +38,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
29
38
|
let(:bank_code) { '19043' }
|
30
39
|
let(:account_number) { '00234573201' }
|
31
40
|
|
32
|
-
it { is_expected.to eq(
|
41
|
+
it { is_expected.to eq(local_details_with_swift) }
|
33
42
|
|
34
43
|
context 'with an account number which needs zero-padding' do
|
35
44
|
let(:account_number) { '234573201' }
|
@@ -43,27 +52,27 @@ describe Ibandit::LocalDetailsCleaner do
|
|
43
52
|
|
44
53
|
context 'with a long account number' do
|
45
54
|
let(:account_number) { '234573201999' }
|
46
|
-
it { is_expected.to eq(
|
55
|
+
it { is_expected.to eq(local_details_with_swift) }
|
47
56
|
end
|
48
57
|
|
49
58
|
context 'without an account number' do
|
50
59
|
let(:account_number) { nil }
|
51
|
-
it { is_expected.to eq(
|
60
|
+
it { is_expected.to eq(local_details_with_swift) }
|
52
61
|
end
|
53
62
|
|
54
63
|
context 'with a short bank code' do
|
55
64
|
let(:bank_code) { '1904' }
|
56
|
-
it { is_expected.to eq(
|
65
|
+
it { is_expected.to eq(local_details_with_swift) }
|
57
66
|
end
|
58
67
|
|
59
68
|
context 'with a long bank code' do
|
60
69
|
let(:bank_code) { '190430' }
|
61
|
-
it { is_expected.to eq(
|
70
|
+
it { is_expected.to eq(local_details_with_swift) }
|
62
71
|
end
|
63
72
|
|
64
73
|
context 'without a bank code' do
|
65
74
|
let(:bank_code) { nil }
|
66
|
-
it { is_expected.to eq(
|
75
|
+
it { is_expected.to eq(local_details_with_swift) }
|
67
76
|
end
|
68
77
|
end
|
69
78
|
|
@@ -83,7 +92,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
83
92
|
|
84
93
|
context 'without an account number' do
|
85
94
|
let(:account_number) { nil }
|
86
|
-
it { is_expected.to eq(
|
95
|
+
it { is_expected.to eq(local_details_with_swift) }
|
87
96
|
end
|
88
97
|
end
|
89
98
|
|
@@ -93,21 +102,21 @@ describe Ibandit::LocalDetailsCleaner do
|
|
93
102
|
let(:branch_code) { '9661' }
|
94
103
|
let(:account_number) { '1020345678' }
|
95
104
|
|
96
|
-
it { is_expected.to eq(
|
105
|
+
it { is_expected.to eq(local_details_with_swift) }
|
97
106
|
|
98
107
|
context 'without an account number' do
|
99
108
|
let(:account_number) { nil }
|
100
|
-
it { is_expected.to eq(
|
109
|
+
it { is_expected.to eq(local_details_with_swift) }
|
101
110
|
end
|
102
111
|
|
103
112
|
context 'without a branch code' do
|
104
113
|
let(:branch_code) { nil }
|
105
|
-
it { is_expected.to eq(
|
114
|
+
it { is_expected.to eq(local_details_with_swift) }
|
106
115
|
end
|
107
116
|
|
108
117
|
context 'without a bank code' do
|
109
118
|
let(:bank_code) { nil }
|
110
|
-
it { is_expected.to eq(
|
119
|
+
it { is_expected.to eq(local_details_with_swift) }
|
111
120
|
end
|
112
121
|
end
|
113
122
|
|
@@ -117,7 +126,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
117
126
|
let(:bank_code) { '002' }
|
118
127
|
let(:branch_code) { '00128' }
|
119
128
|
|
120
|
-
it { is_expected.to eq(
|
129
|
+
it { is_expected.to eq(local_details_with_swift) }
|
121
130
|
|
122
131
|
context 'with a short account number' do
|
123
132
|
let(:account_number) { '1200527600' }
|
@@ -131,12 +140,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
131
140
|
|
132
141
|
context 'with a long account number' do
|
133
142
|
let(:account_number) { '00000001200527600' }
|
134
|
-
it { is_expected.to eq(
|
143
|
+
it { is_expected.to eq(local_details_with_swift) }
|
135
144
|
end
|
136
145
|
|
137
146
|
context 'without an account number' do
|
138
147
|
let(:account_number) { nil }
|
139
|
-
it { is_expected.to eq(
|
148
|
+
it { is_expected.to eq(local_details_with_swift) }
|
140
149
|
end
|
141
150
|
|
142
151
|
context 'with the branch code in the bank code field' do
|
@@ -148,7 +157,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
148
157
|
|
149
158
|
context 'without a bank code' do
|
150
159
|
let(:bank_code) { nil }
|
151
|
-
it { is_expected.to eq(
|
160
|
+
it { is_expected.to eq(local_details_with_swift) }
|
152
161
|
end
|
153
162
|
end
|
154
163
|
|
@@ -157,7 +166,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
157
166
|
let(:bank_code) { '0800' }
|
158
167
|
let(:account_number) { '0000192000145399' }
|
159
168
|
|
160
|
-
it { is_expected.to eq(
|
169
|
+
it { is_expected.to eq(local_details_with_swift) }
|
161
170
|
|
162
171
|
context 'with an account number prefix' do
|
163
172
|
let(:prefix) { '000019' }
|
@@ -174,12 +183,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
174
183
|
|
175
184
|
context 'without a bank code' do
|
176
185
|
let(:bank_code) { nil }
|
177
|
-
it { is_expected.to eq(
|
186
|
+
it { is_expected.to eq(local_details_with_swift) }
|
178
187
|
end
|
179
188
|
|
180
189
|
context 'without an account number' do
|
181
190
|
let(:account_number) { nil }
|
182
|
-
it { is_expected.to eq(
|
191
|
+
it { is_expected.to eq(local_details_with_swift) }
|
183
192
|
end
|
184
193
|
end
|
185
194
|
|
@@ -188,16 +197,16 @@ describe Ibandit::LocalDetailsCleaner do
|
|
188
197
|
let(:bank_code) { '37040044' }
|
189
198
|
let(:account_number) { '0532013000' }
|
190
199
|
|
191
|
-
it { is_expected.to eq(
|
200
|
+
it { is_expected.to eq(local_details_with_swift) }
|
192
201
|
|
193
202
|
context 'without a bank code' do
|
194
203
|
let(:bank_code) { nil }
|
195
|
-
it { is_expected.to eq(
|
204
|
+
it { is_expected.to eq(local_details_with_swift) }
|
196
205
|
end
|
197
206
|
|
198
207
|
context 'without an account number' do
|
199
208
|
let(:account_number) { nil }
|
200
|
-
it { is_expected.to eq(
|
209
|
+
it { is_expected.to eq(local_details_with_swift) }
|
201
210
|
end
|
202
211
|
|
203
212
|
context 'with an excessively short account number' do
|
@@ -215,7 +224,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
215
224
|
context 'with unsupported account details' do
|
216
225
|
let(:account_number) { '7955791111' }
|
217
226
|
let(:bank_code) { '20000000' }
|
218
|
-
it { is_expected.to eq(
|
227
|
+
it { is_expected.to eq(local_details_with_swift) }
|
219
228
|
end
|
220
229
|
end
|
221
230
|
|
@@ -238,7 +247,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
238
247
|
|
239
248
|
context 'without an account number' do
|
240
249
|
let(:account_number) { nil }
|
241
|
-
it { is_expected.to eq(
|
250
|
+
it { is_expected.to eq(local_details_with_swift) }
|
242
251
|
end
|
243
252
|
end
|
244
253
|
|
@@ -257,7 +266,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
257
266
|
|
258
267
|
context 'without an account number' do
|
259
268
|
let(:account_number) { nil }
|
260
|
-
it { is_expected.to eq(
|
269
|
+
it { is_expected.to eq(local_details_with_swift) }
|
261
270
|
end
|
262
271
|
end
|
263
272
|
|
@@ -267,7 +276,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
267
276
|
let(:branch_code) { '0001' }
|
268
277
|
let(:account_number) { '180000012345' }
|
269
278
|
|
270
|
-
it { is_expected.to eq(
|
279
|
+
it { is_expected.to eq(local_details_with_swift) }
|
271
280
|
|
272
281
|
context 'with bank and branch codes in the account number' do
|
273
282
|
let(:bank_code) { nil }
|
@@ -281,7 +290,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
281
290
|
|
282
291
|
context 'without an account number' do
|
283
292
|
let(:account_number) { nil }
|
284
|
-
it { is_expected.to eq(
|
293
|
+
it { is_expected.to eq(local_details_with_swift) }
|
285
294
|
end
|
286
295
|
end
|
287
296
|
|
@@ -290,7 +299,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
290
299
|
let(:bank_code) { '123456' }
|
291
300
|
let(:account_number) { '00000785' }
|
292
301
|
|
293
|
-
it { is_expected.to eq(
|
302
|
+
it { is_expected.to eq(local_details_with_swift) }
|
294
303
|
|
295
304
|
context 'with a shorter account number' do
|
296
305
|
let(:account_number) { '785' }
|
@@ -307,12 +316,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
307
316
|
|
308
317
|
context 'without an account number' do
|
309
318
|
let(:account_number) { nil }
|
310
|
-
it { is_expected.to eq(
|
319
|
+
it { is_expected.to eq(local_details_with_swift) }
|
311
320
|
end
|
312
321
|
|
313
322
|
context 'without a bank code' do
|
314
323
|
let(:bank_code) { nil }
|
315
|
-
it { is_expected.to eq(
|
324
|
+
it { is_expected.to eq(local_details_with_swift) }
|
316
325
|
end
|
317
326
|
end
|
318
327
|
|
@@ -322,7 +331,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
322
331
|
let(:branch_code) { '01005' }
|
323
332
|
let(:account_number) { '0500013M02606' }
|
324
333
|
|
325
|
-
it { is_expected.to eq(
|
334
|
+
it { is_expected.to eq(local_details_with_swift) }
|
326
335
|
|
327
336
|
context 'with the RIB key spaced in the account number' do
|
328
337
|
let(:account_number) { '0500013M026 06' }
|
@@ -336,22 +345,22 @@ describe Ibandit::LocalDetailsCleaner do
|
|
336
345
|
|
337
346
|
context 'with the RIB key missing' do
|
338
347
|
let(:account_number) { '0500013M026' }
|
339
|
-
it { is_expected.to eq(
|
348
|
+
it { is_expected.to eq(local_details_with_swift) }
|
340
349
|
end
|
341
350
|
|
342
351
|
context 'without a bank code' do
|
343
352
|
let(:bank_code) { nil }
|
344
|
-
it { is_expected.to eq(
|
353
|
+
it { is_expected.to eq(local_details_with_swift) }
|
345
354
|
end
|
346
355
|
|
347
356
|
context 'without a branch code' do
|
348
357
|
let(:branch_code) { nil }
|
349
|
-
it { is_expected.to eq(
|
358
|
+
it { is_expected.to eq(local_details_with_swift) }
|
350
359
|
end
|
351
360
|
|
352
361
|
context 'without an account number' do
|
353
362
|
let(:account_number) { nil }
|
354
|
-
it { is_expected.to eq(
|
363
|
+
it { is_expected.to eq(local_details_with_swift) }
|
355
364
|
end
|
356
365
|
end
|
357
366
|
|
@@ -361,7 +370,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
361
370
|
let(:branch_code) { '200000' }
|
362
371
|
let(:account_number) { '55779911' }
|
363
372
|
|
364
|
-
it { is_expected.to eq(
|
373
|
+
it { is_expected.to eq(local_details_with_swift) }
|
365
374
|
|
366
375
|
context 'with the sort code is hyphenated' do
|
367
376
|
let(:branch_code) { '20-00-00' }
|
@@ -395,12 +404,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
395
404
|
|
396
405
|
context 'without a branch code' do
|
397
406
|
let(:branch_code) { nil }
|
398
|
-
it { is_expected.to eq(
|
407
|
+
it { is_expected.to eq(local_details_with_swift) }
|
399
408
|
end
|
400
409
|
|
401
410
|
context 'without a bank code' do
|
402
411
|
let(:bank_code) { nil }
|
403
|
-
it { is_expected.to eq(
|
412
|
+
it { is_expected.to eq(local_details_with_swift) }
|
404
413
|
|
405
414
|
context 'with a BIC finder set' do
|
406
415
|
let(:bic_finder) { double }
|
@@ -435,21 +444,21 @@ describe Ibandit::LocalDetailsCleaner do
|
|
435
444
|
let(:branch_code) { '0125' }
|
436
445
|
let(:account_number) { '0000000012300695' }
|
437
446
|
|
438
|
-
it { is_expected.to eq(
|
447
|
+
it { is_expected.to eq(local_details_with_swift) }
|
439
448
|
|
440
449
|
context 'without an account number' do
|
441
450
|
let(:account_number) { nil }
|
442
|
-
it { is_expected.to eq(
|
451
|
+
it { is_expected.to eq(local_details_with_swift) }
|
443
452
|
end
|
444
453
|
|
445
454
|
context 'without a bank code' do
|
446
455
|
let(:bank_code) { nil }
|
447
|
-
it { is_expected.to eq(
|
456
|
+
it { is_expected.to eq(local_details_with_swift) }
|
448
457
|
end
|
449
458
|
|
450
459
|
context 'without a branch code' do
|
451
460
|
let(:branch_code) { nil }
|
452
|
-
it { is_expected.to eq(
|
461
|
+
it { is_expected.to eq(local_details_with_swift) }
|
453
462
|
end
|
454
463
|
end
|
455
464
|
|
@@ -458,7 +467,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
458
467
|
let(:bank_code) { '1001005' }
|
459
468
|
let(:account_number) { '1863000160' }
|
460
469
|
|
461
|
-
it { is_expected.to eq(
|
470
|
+
it { is_expected.to eq(local_details_with_swift) }
|
462
471
|
|
463
472
|
context 'with bank code in the account number' do
|
464
473
|
let(:bank_code) { nil }
|
@@ -470,13 +479,13 @@ describe Ibandit::LocalDetailsCleaner do
|
|
470
479
|
|
471
480
|
context 'with a badly formatted account number' do
|
472
481
|
let(:account_number) { '1863000160' }
|
473
|
-
it { is_expected.to eq(
|
482
|
+
it { is_expected.to eq(local_details_with_swift) }
|
474
483
|
end
|
475
484
|
end
|
476
485
|
|
477
486
|
context 'without an account number' do
|
478
487
|
let(:account_number) { nil }
|
479
|
-
it { is_expected.to eq(
|
488
|
+
it { is_expected.to eq(local_details_with_swift) }
|
480
489
|
end
|
481
490
|
end
|
482
491
|
|
@@ -486,7 +495,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
486
495
|
let(:branch_code) { '7301' }
|
487
496
|
let(:account_number) { '61111101800000000' }
|
488
497
|
|
489
|
-
it { is_expected.to eq(
|
498
|
+
it { is_expected.to eq(local_details_with_swift) }
|
490
499
|
|
491
500
|
context 'with bank and branch codes in the account number' do
|
492
501
|
let(:bank_code) { nil }
|
@@ -510,19 +519,19 @@ describe Ibandit::LocalDetailsCleaner do
|
|
510
519
|
|
511
520
|
context 'with an invalid length account number' do
|
512
521
|
let(:account_number) { '11773016-1111101' }
|
513
|
-
it { is_expected.to eq(
|
522
|
+
it { is_expected.to eq(local_details_with_swift) }
|
514
523
|
end
|
515
524
|
|
516
525
|
context 'with a bank code, too' do
|
517
526
|
let(:account_number) { '11773016-11111018' }
|
518
527
|
let(:bank_code) { '117' }
|
519
|
-
it { is_expected.to eq(
|
528
|
+
it { is_expected.to eq(local_details_with_swift) }
|
520
529
|
end
|
521
530
|
end
|
522
531
|
|
523
532
|
context 'without an account number' do
|
524
533
|
let(:account_number) { nil }
|
525
|
-
it { is_expected.to eq(
|
534
|
+
it { is_expected.to eq(local_details_with_swift) }
|
526
535
|
end
|
527
536
|
end
|
528
537
|
|
@@ -532,7 +541,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
532
541
|
let(:branch_code) { '931152' }
|
533
542
|
let(:account_number) { '12345678' }
|
534
543
|
|
535
|
-
it { is_expected.to eq(
|
544
|
+
it { is_expected.to eq(local_details_with_swift) }
|
536
545
|
|
537
546
|
context 'with the sort code is hyphenated' do
|
538
547
|
let(:branch_code) { '93-11-52' }
|
@@ -566,12 +575,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
566
575
|
|
567
576
|
context 'without a branch code' do
|
568
577
|
let(:branch_code) { nil }
|
569
|
-
it { is_expected.to eq(
|
578
|
+
it { is_expected.to eq(local_details_with_swift) }
|
570
579
|
end
|
571
580
|
|
572
581
|
context 'without a bank code' do
|
573
582
|
let(:bank_code) { nil }
|
574
|
-
it { is_expected.to eq(
|
583
|
+
it { is_expected.to eq(local_details_with_swift) }
|
575
584
|
|
576
585
|
context 'with a BIC finder set' do
|
577
586
|
let(:bic_finder) { double }
|
@@ -642,7 +651,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
642
651
|
|
643
652
|
context 'without an account number' do
|
644
653
|
let(:account_number) { nil }
|
645
|
-
it { is_expected.to eq(
|
654
|
+
it { is_expected.to eq(local_details_with_swift) }
|
646
655
|
end
|
647
656
|
end
|
648
657
|
|
@@ -652,11 +661,11 @@ describe Ibandit::LocalDetailsCleaner do
|
|
652
661
|
let(:branch_code) { '11101' }
|
653
662
|
let(:account_number) { '000000123456' }
|
654
663
|
|
655
|
-
it { is_expected.to eq(
|
664
|
+
it { is_expected.to eq(local_details_with_swift) }
|
656
665
|
|
657
666
|
context 'with an explicit check digit' do
|
658
667
|
before { local_details.merge!(check_digit: 'Y') }
|
659
|
-
it { is_expected.to eq(
|
668
|
+
it { is_expected.to eq(local_details_with_swift) }
|
660
669
|
end
|
661
670
|
|
662
671
|
context 'with the account number not zero-padded' do
|
@@ -666,17 +675,17 @@ describe Ibandit::LocalDetailsCleaner do
|
|
666
675
|
|
667
676
|
context 'without a bank code' do
|
668
677
|
let(:bank_code) { nil }
|
669
|
-
it { is_expected.to eq(
|
678
|
+
it { is_expected.to eq(local_details_with_swift) }
|
670
679
|
end
|
671
680
|
|
672
681
|
context 'without a branch code' do
|
673
682
|
let(:branch_code) { nil }
|
674
|
-
it { is_expected.to eq(
|
683
|
+
it { is_expected.to eq(local_details_with_swift) }
|
675
684
|
end
|
676
685
|
|
677
686
|
context 'without an account number' do
|
678
687
|
let(:account_number) { nil }
|
679
|
-
it { is_expected.to eq(
|
688
|
+
it { is_expected.to eq(local_details_with_swift) }
|
680
689
|
end
|
681
690
|
end
|
682
691
|
|
@@ -685,16 +694,16 @@ describe Ibandit::LocalDetailsCleaner do
|
|
685
694
|
let(:bank_code) { '10000' }
|
686
695
|
let(:account_number) { '11101001000' }
|
687
696
|
|
688
|
-
it { is_expected.to eq(
|
697
|
+
it { is_expected.to eq(local_details_with_swift) }
|
689
698
|
|
690
699
|
context 'without an account number' do
|
691
700
|
let(:account_number) { nil }
|
692
|
-
it { is_expected.to eq(
|
701
|
+
it { is_expected.to eq(local_details_with_swift) }
|
693
702
|
end
|
694
703
|
|
695
704
|
context 'without a bank code' do
|
696
705
|
let(:bank_code) { nil }
|
697
|
-
it { is_expected.to eq(
|
706
|
+
it { is_expected.to eq(local_details_with_swift) }
|
698
707
|
end
|
699
708
|
end
|
700
709
|
|
@@ -703,16 +712,16 @@ describe Ibandit::LocalDetailsCleaner do
|
|
703
712
|
let(:bank_code) { '001' }
|
704
713
|
let(:account_number) { '9400644750000' }
|
705
714
|
|
706
|
-
it { is_expected.to eq(
|
715
|
+
it { is_expected.to eq(local_details_with_swift) }
|
707
716
|
|
708
717
|
context 'without an account number' do
|
709
718
|
let(:account_number) { nil }
|
710
|
-
it { is_expected.to eq(
|
719
|
+
it { is_expected.to eq(local_details_with_swift) }
|
711
720
|
end
|
712
721
|
|
713
722
|
context 'without a bank code' do
|
714
723
|
let(:bank_code) { nil }
|
715
|
-
it { is_expected.to eq(
|
724
|
+
it { is_expected.to eq(local_details_with_swift) }
|
716
725
|
end
|
717
726
|
end
|
718
727
|
|
@@ -721,16 +730,16 @@ describe Ibandit::LocalDetailsCleaner do
|
|
721
730
|
let(:bank_code) { 'BANK' }
|
722
731
|
let(:account_number) { '1234567890123' }
|
723
732
|
|
724
|
-
it { is_expected.to eq(
|
733
|
+
it { is_expected.to eq(local_details_with_swift) }
|
725
734
|
|
726
735
|
context 'without an account number' do
|
727
736
|
let(:account_number) { nil }
|
728
|
-
it { is_expected.to eq(
|
737
|
+
it { is_expected.to eq(local_details_with_swift) }
|
729
738
|
end
|
730
739
|
|
731
740
|
context 'without a bank code' do
|
732
741
|
let(:bank_code) { nil }
|
733
|
-
it { is_expected.to eq(
|
742
|
+
it { is_expected.to eq(local_details_with_swift) }
|
734
743
|
end
|
735
744
|
end
|
736
745
|
|
@@ -740,7 +749,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
740
749
|
let(:branch_code) { '01005' }
|
741
750
|
let(:account_number) { '0500013M02606' }
|
742
751
|
|
743
|
-
it { is_expected.to eq(
|
752
|
+
it { is_expected.to eq(local_details_with_swift) }
|
744
753
|
|
745
754
|
context 'with the RIB key spaced in the account number' do
|
746
755
|
let(:account_number) { '0500013M026 06' }
|
@@ -754,22 +763,22 @@ describe Ibandit::LocalDetailsCleaner do
|
|
754
763
|
|
755
764
|
context 'with the RIB key missing' do
|
756
765
|
let(:account_number) { '0500013M026' }
|
757
|
-
it { is_expected.to eq(
|
766
|
+
it { is_expected.to eq(local_details_with_swift) }
|
758
767
|
end
|
759
768
|
|
760
769
|
context 'without a bank code' do
|
761
770
|
let(:bank_code) { nil }
|
762
|
-
it { is_expected.to eq(
|
771
|
+
it { is_expected.to eq(local_details_with_swift) }
|
763
772
|
end
|
764
773
|
|
765
774
|
context 'without a branch code' do
|
766
775
|
let(:branch_code) { nil }
|
767
|
-
it { is_expected.to eq(
|
776
|
+
it { is_expected.to eq(local_details_with_swift) }
|
768
777
|
end
|
769
778
|
|
770
779
|
context 'without an account number' do
|
771
780
|
let(:account_number) { nil }
|
772
|
-
it { is_expected.to eq(
|
781
|
+
it { is_expected.to eq(local_details_with_swift) }
|
773
782
|
end
|
774
783
|
end
|
775
784
|
|
@@ -779,7 +788,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
779
788
|
let(:branch_code) { '44093' }
|
780
789
|
let(:account_number) { '000000009027293051' }
|
781
790
|
|
782
|
-
it { is_expected.to eq(
|
791
|
+
it { is_expected.to eq(local_details_with_swift) }
|
783
792
|
|
784
793
|
context 'with the account number spaced' do
|
785
794
|
let(:account_number) { '9027 2930 51' }
|
@@ -793,12 +802,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
793
802
|
|
794
803
|
context 'without a branch code' do
|
795
804
|
let(:branch_code) { nil }
|
796
|
-
it { is_expected.to eq(
|
805
|
+
it { is_expected.to eq(local_details_with_swift) }
|
797
806
|
end
|
798
807
|
|
799
808
|
context 'without a bank code' do
|
800
809
|
let(:bank_code) { nil }
|
801
|
-
it { is_expected.to eq(
|
810
|
+
it { is_expected.to eq(local_details_with_swift) }
|
802
811
|
|
803
812
|
context 'with a BIC finder set' do
|
804
813
|
let(:bic_finder) { double }
|
@@ -832,21 +841,21 @@ describe Ibandit::LocalDetailsCleaner do
|
|
832
841
|
let(:bank_code) { 'ABNA' }
|
833
842
|
let(:account_number) { '0417164300' }
|
834
843
|
|
835
|
-
it { is_expected.to eq(
|
844
|
+
it { is_expected.to eq(local_details_with_swift) }
|
836
845
|
|
837
846
|
context 'without a bank code' do
|
838
847
|
let(:bank_code) { nil }
|
839
|
-
it { is_expected.to eq(
|
848
|
+
it { is_expected.to eq(local_details_with_swift) }
|
840
849
|
end
|
841
850
|
|
842
851
|
context 'without a branch code' do
|
843
852
|
let(:branch_code) { nil }
|
844
|
-
it { is_expected.to eq(
|
853
|
+
it { is_expected.to eq(local_details_with_swift) }
|
845
854
|
end
|
846
855
|
|
847
856
|
context 'without an account number' do
|
848
857
|
let(:account_number) { nil }
|
849
|
-
it { is_expected.to eq(
|
858
|
+
it { is_expected.to eq(local_details_with_swift) }
|
850
859
|
end
|
851
860
|
|
852
861
|
context 'with an account number that needs zero-padding' do
|
@@ -860,7 +869,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
860
869
|
let(:bank_code) { '8601' }
|
861
870
|
let(:account_number) { '1117947' }
|
862
871
|
|
863
|
-
it { is_expected.to eq(
|
872
|
+
it { is_expected.to eq(local_details_with_swift) }
|
864
873
|
|
865
874
|
context 'with bank and branch codes in the account number' do
|
866
875
|
let(:bank_code) { nil }
|
@@ -873,7 +882,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
873
882
|
|
874
883
|
context 'without an account number' do
|
875
884
|
let(:account_number) { nil }
|
876
|
-
it { is_expected.to eq(
|
885
|
+
it { is_expected.to eq(local_details_with_swift) }
|
877
886
|
end
|
878
887
|
end
|
879
888
|
|
@@ -882,7 +891,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
882
891
|
let(:bank_code) { '10201026' }
|
883
892
|
let(:account_number) { '0000042270201111' }
|
884
893
|
|
885
|
-
it { is_expected.to eq(
|
894
|
+
it { is_expected.to eq(local_details_with_swift) }
|
886
895
|
|
887
896
|
context 'with a full length account number' do
|
888
897
|
let(:bank_code) { nil }
|
@@ -895,7 +904,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
895
904
|
|
896
905
|
context 'without an account number' do
|
897
906
|
let(:account_number) { nil }
|
898
|
-
it { is_expected.to eq(
|
907
|
+
it { is_expected.to eq(local_details_with_swift) }
|
899
908
|
end
|
900
909
|
end
|
901
910
|
|
@@ -905,21 +914,21 @@ describe Ibandit::LocalDetailsCleaner do
|
|
905
914
|
let(:branch_code) { '0023' }
|
906
915
|
let(:account_number) { '0023843000578' }
|
907
916
|
|
908
|
-
it { is_expected.to eq(
|
917
|
+
it { is_expected.to eq(local_details_with_swift) }
|
909
918
|
|
910
919
|
context 'without a bank code' do
|
911
920
|
let(:bank_code) { nil }
|
912
|
-
it { is_expected.to eq(
|
921
|
+
it { is_expected.to eq(local_details_with_swift) }
|
913
922
|
end
|
914
923
|
|
915
924
|
context 'without a branch code' do
|
916
925
|
let(:branch_code) { nil }
|
917
|
-
it { is_expected.to eq(
|
926
|
+
it { is_expected.to eq(local_details_with_swift) }
|
918
927
|
end
|
919
928
|
|
920
929
|
context 'without an account number' do
|
921
930
|
let(:account_number) { nil }
|
922
|
-
it { is_expected.to eq(
|
931
|
+
it { is_expected.to eq(local_details_with_swift) }
|
923
932
|
end
|
924
933
|
end
|
925
934
|
|
@@ -928,16 +937,16 @@ describe Ibandit::LocalDetailsCleaner do
|
|
928
937
|
let(:bank_code) { 'AAAA' }
|
929
938
|
let(:account_number) { '1B31007593840000' }
|
930
939
|
|
931
|
-
it { is_expected.to eq(
|
940
|
+
it { is_expected.to eq(local_details_with_swift) }
|
932
941
|
|
933
942
|
context 'without an account number' do
|
934
943
|
let(:account_number) { nil }
|
935
|
-
it { is_expected.to eq(
|
944
|
+
it { is_expected.to eq(local_details_with_swift) }
|
936
945
|
end
|
937
946
|
|
938
947
|
context 'without a bank code' do
|
939
948
|
let(:bank_code) { nil }
|
940
|
-
it { is_expected.to eq(
|
949
|
+
it { is_expected.to eq(local_details_with_swift) }
|
941
950
|
end
|
942
951
|
end
|
943
952
|
|
@@ -946,8 +955,10 @@ describe Ibandit::LocalDetailsCleaner do
|
|
946
955
|
let(:bank_code) { '501' }
|
947
956
|
let(:account_number) { '5013-1007270' }
|
948
957
|
|
949
|
-
its([:
|
950
|
-
its([:
|
958
|
+
its([:account_number]) { is_expected.to eq('1007270') }
|
959
|
+
its([:branch_code]) { is_expected.to eq('5013') }
|
960
|
+
its([:swift_bank_code]) { is_expected.to eq('501') }
|
961
|
+
its([:swift_account_number]) { is_expected.to eq('00000050131007270') }
|
951
962
|
|
952
963
|
context 'without an account number' do
|
953
964
|
let(:account_number) { nil }
|
@@ -957,8 +968,9 @@ describe Ibandit::LocalDetailsCleaner do
|
|
957
968
|
context 'without a bank code' do
|
958
969
|
let(:bank_code) { nil }
|
959
970
|
|
960
|
-
its([:
|
961
|
-
its([:account_number]) { is_expected.to eq('
|
971
|
+
its([:swift_bank_code]) { is_expected.to eq('500') }
|
972
|
+
its([:account_number]) { is_expected.to eq('1007270') }
|
973
|
+
its([:swift_account_number]) { is_expected.to eq('00000050131007270') }
|
962
974
|
end
|
963
975
|
end
|
964
976
|
|
@@ -967,7 +979,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
967
979
|
let(:bank_code) { '19100' }
|
968
980
|
let(:account_number) { '0000123438' }
|
969
981
|
|
970
|
-
it { is_expected.to eq(
|
982
|
+
it { is_expected.to eq(local_details_with_swift) }
|
971
983
|
|
972
984
|
context 'with an account number which needs zero-padding' do
|
973
985
|
let(:account_number) { '123438' }
|
@@ -976,12 +988,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
976
988
|
|
977
989
|
context 'without a bank code' do
|
978
990
|
let(:bank_code) { nil }
|
979
|
-
it { is_expected.to eq(
|
991
|
+
it { is_expected.to eq(local_details_with_swift) }
|
980
992
|
end
|
981
993
|
|
982
994
|
context 'without an account number' do
|
983
995
|
let(:account_number) { nil }
|
984
|
-
it { is_expected.to eq(
|
996
|
+
it { is_expected.to eq(local_details_with_swift) }
|
985
997
|
end
|
986
998
|
end
|
987
999
|
|
@@ -990,7 +1002,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
990
1002
|
let(:bank_code) { '1200' }
|
991
1003
|
let(:account_number) { '0000198742637541' }
|
992
1004
|
|
993
|
-
it { is_expected.to eq(
|
1005
|
+
it { is_expected.to eq(local_details_with_swift) }
|
994
1006
|
|
995
1007
|
context 'with an account number prefix' do
|
996
1008
|
let(:prefix) { '000019' }
|
@@ -1007,12 +1019,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
1007
1019
|
|
1008
1020
|
context 'without a bank code' do
|
1009
1021
|
let(:bank_code) { nil }
|
1010
|
-
it { is_expected.to eq(
|
1022
|
+
it { is_expected.to eq(local_details_with_swift) }
|
1011
1023
|
end
|
1012
1024
|
|
1013
1025
|
context 'without an account number' do
|
1014
1026
|
let(:account_number) { nil }
|
1015
|
-
it { is_expected.to eq(
|
1027
|
+
it { is_expected.to eq(local_details_with_swift) }
|
1016
1028
|
end
|
1017
1029
|
end
|
1018
1030
|
|
@@ -1022,11 +1034,11 @@ describe Ibandit::LocalDetailsCleaner do
|
|
1022
1034
|
let(:branch_code) { '11101' }
|
1023
1035
|
let(:account_number) { '000000123456' }
|
1024
1036
|
|
1025
|
-
it { is_expected.to eq(
|
1037
|
+
it { is_expected.to eq(local_details_with_swift) }
|
1026
1038
|
|
1027
1039
|
context 'with an explicit check digit' do
|
1028
1040
|
before { local_details.merge!(check_digit: 'Y') }
|
1029
|
-
it { is_expected.to eq(
|
1041
|
+
it { is_expected.to eq(local_details_with_swift) }
|
1030
1042
|
end
|
1031
1043
|
|
1032
1044
|
context 'with the account number not zero-padded' do
|
@@ -1036,17 +1048,17 @@ describe Ibandit::LocalDetailsCleaner do
|
|
1036
1048
|
|
1037
1049
|
context 'without a bank code' do
|
1038
1050
|
let(:bank_code) { nil }
|
1039
|
-
it { is_expected.to eq(
|
1051
|
+
it { is_expected.to eq(local_details_with_swift) }
|
1040
1052
|
end
|
1041
1053
|
|
1042
1054
|
context 'without a branch code' do
|
1043
1055
|
let(:branch_code) { nil }
|
1044
|
-
it { is_expected.to eq(
|
1056
|
+
it { is_expected.to eq(local_details_with_swift) }
|
1045
1057
|
end
|
1046
1058
|
|
1047
1059
|
context 'without an account number' do
|
1048
1060
|
let(:account_number) { nil }
|
1049
|
-
it { is_expected.to eq(
|
1061
|
+
it { is_expected.to eq(local_details_with_swift) }
|
1050
1062
|
end
|
1051
1063
|
end
|
1052
1064
|
end
|