ibandit 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/config/locales/de.yml +4 -3
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/fr.yml +1 -0
- data/config/locales/it.yml +1 -0
- data/config/locales/nl.yml +1 -0
- data/config/locales/pt.yml +1 -0
- data/lib/ibandit/errors.rb +0 -2
- data/lib/ibandit/iban.rb +19 -1
- data/lib/ibandit/local_details_cleaner.rb +6 -1
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_spec.rb +72 -0
- data/spec/ibandit/local_details_cleaner_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc1eddf185fe692eb8722cb1d94f8069e21f80df
|
4
|
+
data.tar.gz: b9df021973596bdfa6df1f554685af30b2038059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20535679cd0fcdd19e0ce57398d3bc0f4fa539761edb4706a466c34b4934347559903a63612db1a19d73f264490896efa33285220354cc00298a5bf0518ca593
|
7
|
+
data.tar.gz: aff6275493f96d55daf9a8a840b622b8c1fa97181762b0f8ef83a2e91a2f48a0d5bd868e6ef44cf48564557041c1654555ab0636059a23e2b8930d5a747f0a47
|
data/CHANGELOG.md
CHANGED
data/config/locales/de.yml
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
de:
|
2
2
|
ibandit:
|
3
|
-
is_required: 'muss ausgefüllt werden'
|
4
|
-
wrong_length: 'hat die falsche Länge (muss genau %{expected} Zeichen haben)'
|
5
|
-
is_invalid: 'ist nicht gültig'
|
6
3
|
invalid_country_code: "'%{country_code}' ist keine gültige IBAN Länderkennung"
|
7
4
|
invalid_check_digits: "Die Prüfzahlen sind inkorrekt. Erwartet wurde '%{expected_check_digits}', tatsächlich erhalten '%{check_digits}'."
|
8
5
|
invalid_length: "Die Länge stimmt nicht mit der SWIFT Spezifikation überein (erwartet wurden %{expected_length} Zeichen, tatsächlich erhalten %{length})"
|
6
|
+
is_required: 'muss ausgefüllt werden'
|
7
|
+
wrong_length: 'hat die falsche Länge (muss genau %{expected} Zeichen haben)'
|
9
8
|
not_used_in_country: "wird in %{country_code} nicht benutzt"
|
10
9
|
non_alphanumeric_characters: "Nicht-alphanumerische Zeichen gefunden: %{characters}"
|
11
10
|
invalid_format: "Unerwartetes Format für eine %{country_code} IBAN."
|
11
|
+
is_invalid: 'ist nicht gültig'
|
12
|
+
does_not_support_payments: "nicht Zahlungsverkehr unterstützt"
|
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/config/locales/it.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/config/locales/pt.yml
CHANGED
data/lib/ibandit/errors.rb
CHANGED
data/lib/ibandit/iban.rb
CHANGED
@@ -68,7 +68,8 @@ module Ibandit
|
|
68
68
|
valid_bank_code_format?,
|
69
69
|
valid_branch_code_format?,
|
70
70
|
valid_account_number_format?,
|
71
|
-
valid_local_modulus_check
|
71
|
+
valid_local_modulus_check?,
|
72
|
+
supports_iban_determination?
|
72
73
|
].all?
|
73
74
|
end
|
74
75
|
|
@@ -224,6 +225,23 @@ module Ibandit
|
|
224
225
|
valid_modulus_check_bank_code? && valid_modulus_check_account_number?
|
225
226
|
end
|
226
227
|
|
228
|
+
def supports_iban_determination?
|
229
|
+
return unless valid_format?
|
230
|
+
return true unless country_code == 'DE'
|
231
|
+
|
232
|
+
begin
|
233
|
+
GermanDetailsConverter.convert(
|
234
|
+
country_code: country_code,
|
235
|
+
bank_code: bank_code,
|
236
|
+
account_number: account_number
|
237
|
+
)
|
238
|
+
true
|
239
|
+
rescue UnsupportedAccountDetails
|
240
|
+
@errors[:account_number] = Ibandit.translate(:does_not_support_payments)
|
241
|
+
false
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
227
245
|
###################
|
228
246
|
# Private methods #
|
229
247
|
###################
|
@@ -96,7 +96,12 @@ module Ibandit
|
|
96
96
|
# There are many exceptions to the way German bank details translate
|
97
97
|
# into an IBAN, detailed into a 200 page document compiled by the
|
98
98
|
# Bundesbank, and handled by the GermanDetailsConverter class.
|
99
|
-
converted_details =
|
99
|
+
converted_details =
|
100
|
+
begin
|
101
|
+
GermanDetailsConverter.convert(local_details)
|
102
|
+
rescue UnsupportedAccountDetails
|
103
|
+
local_details.dup
|
104
|
+
end
|
100
105
|
|
101
106
|
return {} unless converted_details[:account_number].length >= 4
|
102
107
|
|
data/lib/ibandit/version.rb
CHANGED
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -1220,6 +1220,78 @@ describe Ibandit::IBAN do
|
|
1220
1220
|
end
|
1221
1221
|
end
|
1222
1222
|
end
|
1223
|
+
|
1224
|
+
describe 'supports_iban_determination?' do
|
1225
|
+
subject(:valid_local_modulus_check?) { iban.supports_iban_determination? }
|
1226
|
+
|
1227
|
+
context 'with unsupported account details' do
|
1228
|
+
let(:arg) do
|
1229
|
+
{
|
1230
|
+
country_code: 'DE',
|
1231
|
+
bank_code: '20000000',
|
1232
|
+
account_number: '7955791111'
|
1233
|
+
}
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
it { is_expected.to eq(false) }
|
1237
|
+
|
1238
|
+
context 'locale en', locale: :en do
|
1239
|
+
specify do
|
1240
|
+
iban.supports_iban_determination?
|
1241
|
+
expect(iban.errors).
|
1242
|
+
to include(account_number: 'does not support payments')
|
1243
|
+
end
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
context 'locale fr', locale: :fr do
|
1247
|
+
specify do
|
1248
|
+
iban.supports_iban_determination?
|
1249
|
+
expect(iban.errors).
|
1250
|
+
to include(account_number: 'ne supporte pas les paiements')
|
1251
|
+
end
|
1252
|
+
end
|
1253
|
+
|
1254
|
+
context 'locale de', locale: :de do
|
1255
|
+
specify do
|
1256
|
+
iban.supports_iban_determination?
|
1257
|
+
expect(iban.errors).
|
1258
|
+
to include(account_number: 'nicht Zahlungsverkehr unterstützt')
|
1259
|
+
end
|
1260
|
+
end
|
1261
|
+
|
1262
|
+
context 'locale pt', locale: :pt do
|
1263
|
+
specify do
|
1264
|
+
iban.supports_iban_determination?
|
1265
|
+
expect(iban.errors).
|
1266
|
+
to include(account_number: 'não suporta pagamentos')
|
1267
|
+
end
|
1268
|
+
end
|
1269
|
+
|
1270
|
+
context 'locale es', locale: :es do
|
1271
|
+
specify do
|
1272
|
+
iban.supports_iban_determination?
|
1273
|
+
expect(iban.errors).
|
1274
|
+
to include(account_number: 'no admite pagos')
|
1275
|
+
end
|
1276
|
+
end
|
1277
|
+
|
1278
|
+
context 'locale it', locale: :it do
|
1279
|
+
specify do
|
1280
|
+
iban.supports_iban_determination?
|
1281
|
+
expect(iban.errors).
|
1282
|
+
to include(account_number: 'non supporta pagamenti')
|
1283
|
+
end
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
context 'locale nl', locale: :nl do
|
1287
|
+
specify do
|
1288
|
+
iban.supports_iban_determination?
|
1289
|
+
expect(iban.errors).
|
1290
|
+
to include(account_number: 'ondersteunt geen betalingen')
|
1291
|
+
end
|
1292
|
+
end
|
1293
|
+
end
|
1294
|
+
end
|
1223
1295
|
end
|
1224
1296
|
|
1225
1297
|
describe '#valid?' do
|
@@ -156,6 +156,12 @@ describe Ibandit::LocalDetailsCleaner do
|
|
156
156
|
its([:bank_code]) { is_expected.to eq(bank_code) }
|
157
157
|
its([:account_number]) { is_expected.to eq('0215022000') }
|
158
158
|
end
|
159
|
+
|
160
|
+
context 'with unsupported account details' do
|
161
|
+
let(:account_number) { '7955791111' }
|
162
|
+
let(:bank_code) { '20000000' }
|
163
|
+
it { is_expected.to eq(local_details) }
|
164
|
+
end
|
159
165
|
end
|
160
166
|
|
161
167
|
context 'Estonia' 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: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grey Baker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|