ibandit 0.6.1 → 0.6.2
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/CHANGELOG.md +4 -0
- data/README.md +7 -8
- data/lib/ibandit/iban_assembler.rb +3 -3
- data/lib/ibandit/local_details_cleaner.rb +19 -3
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_assembler_spec.rb +22 -0
- data/spec/ibandit/local_details_cleaner_spec.rb +23 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d371335a59f94320ee6d0d47b0387e3e240b48d9
|
4
|
+
data.tar.gz: a340177bde1374d3b6cea5fec8450560978d87d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65c97889796f5c1e7b14b60da0e7d8a16fc750e5d9d8879d5722d5a86ef7cdb9666481ed07e66b32f04ed75c8de8dcdfa1e30a3b87a9b844ae9edc7bac184b19
|
7
|
+
data.tar.gz: 7e0cfce671a59389f8d254dcd5c35d4c1f75af538ba070bf050eee0153cc891eecffe21a51a120400980f00fff23c57579db7b50a6382debd2b711a100626cfb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -191,6 +191,13 @@ iban = Ibandit::IBAN.new(
|
|
191
191
|
)
|
192
192
|
iban.iban # => "DE89370400440532013000"
|
193
193
|
|
194
|
+
# Denmark
|
195
|
+
iban = Ibandit::IBAN.new(
|
196
|
+
country_code: 'DK',
|
197
|
+
account_number: '345-3179681',
|
198
|
+
)
|
199
|
+
iban.iban # => "DK8003450003179681"
|
200
|
+
|
194
201
|
# Estonia
|
195
202
|
iban = Ibandit::IBAN.new(
|
196
203
|
country_code: 'EE',
|
@@ -302,14 +309,6 @@ iban = Ibandit::IBAN.new(
|
|
302
309
|
iban.iban # => "NL91ABNA0417164300"
|
303
310
|
|
304
311
|
# Norway
|
305
|
-
iban = Ibandit::IBAN.new(
|
306
|
-
country_code: 'NO',
|
307
|
-
account_number: '1117947',
|
308
|
-
bank_code: '8601'
|
309
|
-
)
|
310
|
-
iban.iban # => "NO9386011117947"
|
311
|
-
|
312
|
-
# Norway with 11 digit account number
|
313
312
|
iban = Ibandit::IBAN.new(
|
314
313
|
country_code: 'NO',
|
315
314
|
account_number: '8601.1117947',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Ibandit
|
2
2
|
module IBANAssembler
|
3
|
-
SUPPORTED_COUNTRY_CODES = %w(AT BE CY DE EE ES FI FR GB GR IE IT LT LU LV
|
4
|
-
MT NL NO PT SE SI SK SM).freeze
|
3
|
+
SUPPORTED_COUNTRY_CODES = %w(AT BE CY DE DK EE ES FI FR GB GR IE IT LT LU LV
|
4
|
+
MC MT NL NO PT SE SI SK SM).freeze
|
5
5
|
|
6
6
|
EXCEPTION_COUNTRY_CODES = %w(IT SM BE).freeze
|
7
7
|
|
@@ -84,7 +84,7 @@ module Ibandit
|
|
84
84
|
|
85
85
|
def self.required_fields(country_code)
|
86
86
|
case country_code
|
87
|
-
when *%w(AT CY DE EE FI LT LU LV NL NO SE SI SK)
|
87
|
+
when *%w(AT CY DE EE FI LT LU LV NL NO SE SI SK DK)
|
88
88
|
%i(bank_code account_number)
|
89
89
|
when 'BE'
|
90
90
|
%i(account_number)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Ibandit
|
2
2
|
module LocalDetailsCleaner
|
3
|
-
SUPPORTED_COUNTRY_CODES = %w(AT BE CY DE EE ES FI FR GB GR IE IT LT LU LV
|
4
|
-
MT NL NO PT SE SI SK SM).freeze
|
3
|
+
SUPPORTED_COUNTRY_CODES = %w(AT BE CY DE DK EE ES FI FR GB GR IE IT LT LU LV
|
4
|
+
MC MT NL NO PT SE SI SK SM).freeze
|
5
5
|
|
6
6
|
def self.clean(local_details)
|
7
7
|
country_code = local_details[:country_code]
|
@@ -29,7 +29,7 @@ module Ibandit
|
|
29
29
|
case country_code
|
30
30
|
when 'AT', 'CY', 'DE', 'FI', 'LT', 'LU', 'LV', 'NL', 'SI', 'SK'
|
31
31
|
%i(bank_code account_number)
|
32
|
-
when 'BE', 'EE', 'ES', 'SE', 'NO'
|
32
|
+
when 'BE', 'EE', 'ES', 'SE', 'NO', 'DK'
|
33
33
|
%i(account_number)
|
34
34
|
when 'GB', 'IE', 'MT'
|
35
35
|
if Ibandit.bic_finder.nil? then %i(bank_code branch_code account_number)
|
@@ -111,6 +111,22 @@ module Ibandit
|
|
111
111
|
}
|
112
112
|
end
|
113
113
|
|
114
|
+
def self.clean_dk_details(local_details)
|
115
|
+
# This method supports being passed the component IBAN parts, as defined
|
116
|
+
# by SWIFT, or a single traditional-format string split by a '-'.
|
117
|
+
if local_details[:bank_code]
|
118
|
+
bank_code = local_details[:bank_code].rjust(4, '0')
|
119
|
+
account_number = local_details[:account_number].rjust(10, '0')
|
120
|
+
else
|
121
|
+
bank_code, account_number = local_details[:account_number].split('-', 2)
|
122
|
+
end
|
123
|
+
|
124
|
+
{
|
125
|
+
bank_code: bank_code.rjust(4, '0'),
|
126
|
+
account_number: account_number.rjust(10, '0')
|
127
|
+
}
|
128
|
+
end
|
129
|
+
|
114
130
|
def self.clean_ee_details(local_details)
|
115
131
|
# Account number may be up to 14 characters long.
|
116
132
|
# Add leading zeros to account number if < 14 digits.
|
data/lib/ibandit/version.rb
CHANGED
@@ -120,6 +120,28 @@ describe Ibandit::IBANAssembler do
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
+
context 'with DK as the country_code' do
|
124
|
+
let(:args) do
|
125
|
+
{ country_code: 'DK',
|
126
|
+
bank_code: '1199',
|
127
|
+
account_number: '0003179680' }
|
128
|
+
end
|
129
|
+
|
130
|
+
it { is_expected.to eq('DK2411990003179680') }
|
131
|
+
|
132
|
+
it_behaves_like 'allows round trips', 'DK24 1199 0003 1796 80'
|
133
|
+
|
134
|
+
context 'without a bank_code' do
|
135
|
+
before { args.delete(:bank_code) }
|
136
|
+
it { is_expected.to be_nil }
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'without an account_number' do
|
140
|
+
before { args.delete(:account_number) }
|
141
|
+
it { is_expected.to be_nil }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
123
145
|
context 'with EE as the country_code' do
|
124
146
|
let(:args) do
|
125
147
|
{
|
@@ -164,6 +164,29 @@ describe Ibandit::LocalDetailsCleaner do
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
context 'Denmark' do
|
168
|
+
let(:country_code) { 'DK' }
|
169
|
+
let(:bank_code) { '40' }
|
170
|
+
let(:account_number) { '440116243' }
|
171
|
+
|
172
|
+
its([:bank_code]) { is_expected.to eq('0040') }
|
173
|
+
its([:account_number]) { is_expected.to eq('0440116243') }
|
174
|
+
|
175
|
+
context 'with bank and branch codes in the account number' do
|
176
|
+
let(:bank_code) { nil }
|
177
|
+
let(:branch_code) { nil }
|
178
|
+
let(:account_number) { '345-3179681' }
|
179
|
+
|
180
|
+
its([:bank_code]) { is_expected.to eq('0345') }
|
181
|
+
its([:account_number]) { is_expected.to eq('0003179681') }
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'without an account number' do
|
185
|
+
let(:account_number) { nil }
|
186
|
+
it { is_expected.to eq(local_details) }
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
167
190
|
context 'Estonia' do
|
168
191
|
let(:country_code) { 'EE' }
|
169
192
|
let(:account_number) { '0221020145685' }
|