ibandit 0.4.5 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f88c8589210ccf1f924f9549ed48d364d4b0b8e4
4
- data.tar.gz: 50fb4d41cefdd0e1c783707773b0d77b7ae81f83
3
+ metadata.gz: fc1eddf185fe692eb8722cb1d94f8069e21f80df
4
+ data.tar.gz: b9df021973596bdfa6df1f554685af30b2038059
5
5
  SHA512:
6
- metadata.gz: 2ce1ae1432a7d4d244b2c66e1cbb2d9fd54f9f7bd1e27f1bea4624c48b2b6e9e3a4016770aba09d887f8219dce3d5f3564e42a9d0783504e0b4bffe62a48142e
7
- data.tar.gz: 1783cc91ad10bac4e939a9dfc26f1e78b9fe8fe1248e71cbf2249a9f7ec650010d5c239f2856a47ddc54fe4d568e65825adc34b9575d9976bcccae4a97002d34
6
+ metadata.gz: 20535679cd0fcdd19e0ce57398d3bc0f4fa539761edb4706a466c34b4934347559903a63612db1a19d73f264490896efa33285220354cc00298a5bf0518ca593
7
+ data.tar.gz: aff6275493f96d55daf9a8a840b622b8c1fa97181762b0f8ef83a2e91a2f48a0d5bd868e6ef44cf48564557041c1654555ab0636059a23e2b8930d5a747f0a47
@@ -1,3 +1,8 @@
1
+ ## 0.5.0 - July 12, 2015
2
+
3
+ - Add an error for unsupported German bank details, and stop raising whilst
4
+ cleaning them
5
+
1
6
  ## 0.4.5 - June 25, 2015
2
7
 
3
8
  - Add Dutch translation
@@ -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"
@@ -9,3 +9,4 @@ en:
9
9
  non_alphanumeric_characters: "Non-alphanumeric characters found: %{characters}"
10
10
  invalid_format: "Unexpected format for a %{country_code} IBAN."
11
11
  is_invalid: "is invalid"
12
+ does_not_support_payments: "does not support payments"
@@ -9,3 +9,4 @@ es:
9
9
  non_alphanumeric_characters: "Se han econtrado símbolos no alfanuméricos: %{characters}"
10
10
  invalid_format: "Formato inesperado para un IBAN de %{country_code}."
11
11
  is_invalid: "es inválido"
12
+ does_not_support_payments: "no admite pagos"
@@ -9,3 +9,4 @@ fr:
9
9
  non_alphanumeric_characters: "Caractères non alphanumériques présents : %{characters}"
10
10
  invalid_format: "Format inconnu pour l'IBAN %{country_code}."
11
11
  is_invalid: "est invalide"
12
+ does_not_support_payments: "ne supporte pas les paiements"
@@ -9,3 +9,4 @@ it:
9
9
  non_alphanumeric_characters: "Un carattere non-alfanumerico è stato trovato: %{characters}"
10
10
  invalid_format: "Formato non atteso per un IBAN %{country_code}."
11
11
  is_invalid: "non è valido"
12
+ does_not_support_payments: "non supporta pagamenti"
@@ -9,3 +9,4 @@ nl:
9
9
  non_alphanumeric_characters: "Niet-alfanumerieke tekens gevonden: %{characters}"
10
10
  invalid_format: "Onverwachte formaat voor een %{country_code} IBAN."
11
11
  is_invalid: "is ongeldig"
12
+ does_not_support_payments: "ondersteunt geen betalingen"
@@ -9,3 +9,4 @@ pt:
9
9
  non_alphanumeric_characters: "Caracteres não alfanuméricos encontrados: %{characters}"
10
10
  invalid_format: "Formato errado para um IBAN %{country_code}."
11
11
  is_invalid: "é inválido"
12
+ does_not_support_payments: "não suporta pagamentos"
@@ -1,6 +1,4 @@
1
1
  module Ibandit
2
- class BicNotFoundError < StandardError; end
3
2
  class InvalidCharacterError < StandardError; end
4
- class UnsupportedCountryError < StandardError; end
5
3
  class UnsupportedAccountDetails < StandardError; end
6
4
  end
@@ -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 = GermanDetailsConverter.convert(local_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
 
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = '0.4.5'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -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.5
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-06-25 00:00:00.000000000 Z
11
+ date: 2015-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec