ibandit 0.11.10 → 0.11.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9a33af92874b7a40f4a8696b7cd25eb59590094
4
- data.tar.gz: 3cdd502edd0f62bc40119f3863b8711a21bd6669
3
+ metadata.gz: 7cf488eed67769ff39b6249be1b7689359f9eb4a
4
+ data.tar.gz: 0f32aaf43214999c417badf26c730a334bdd3610
5
5
  SHA512:
6
- metadata.gz: 062edcac1e201a30ea007c6dacf131d611fd679bf74c711d290ea18e91246c933cd4cc55a9e523c9bbdd810aa6dcde80b11af092adbdcbb110c3d736b3638126
7
- data.tar.gz: d00da8559f97e04603bed2dac82fc66792bff1ed3d95510f4cfc3d8c0480581dd3f0c13e0b901efc4f1ddce1b0568e7cf119706143f60f25f490b11cc0316e80
6
+ metadata.gz: 20202b4dd9710f4912bbef1b0c7f108c1c65aa6c1fc6c279e9b4538df4e204e1aade6dd4c2ce5b28fe8351c46d24363c75125e2c1f7c75e57ce3dce2d6a54bac
7
+ data.tar.gz: f918279bb0f3943d334ae6f1fbc67f38357d3902a0e09af53f8187c7879232137a54b45ae0660f82472c30411a40519a6087f00414dee02e4ca6678c8d6e4ed7
@@ -1,3 +1,7 @@
1
+ ## 0.11.11 - March 1, 2018
2
+
3
+ - Fix padding for Australian pseudo-IBANs
4
+
1
5
  ## 0.11.10 - February 21, 2018
2
6
 
3
7
  - Fix support for Australian bank accounts
@@ -10,6 +10,11 @@ module Ibandit
10
10
 
11
11
  PSEUDO_IBAN_CHECK_DIGITS = "ZZ".freeze
12
12
 
13
+ PSEUDO_IBAN_PADDING_CHARACTER_FOR = {
14
+ "SE" => "X", # Using X for backwards compatibility
15
+ "AU" => "_", # Using _ because AU account numbers are alphanumeric
16
+ }.freeze
17
+
13
18
  SUPPORTED_COUNTRY_CODES = (
14
19
  CONSTRUCTABLE_IBAN_COUNTRY_CODES +
15
20
  DECONSTRUCTABLE_IBAN_COUNTRY_CODES +
@@ -35,6 +35,10 @@ module Ibandit
35
35
  Constants::PSEUDO_IBAN_COUNTRY_CODES.include?(@country_code)
36
36
  end
37
37
 
38
+ def padding_character
39
+ Constants::PSEUDO_IBAN_PADDING_CHARACTER_FOR[@country_code]
40
+ end
41
+
38
42
  def bank_code_valid?
39
43
  param_valid?(@bank_code, :pseudo_iban_bank_code_length)
40
44
  end
@@ -67,7 +71,7 @@ module Ibandit
67
71
 
68
72
  def pad(number, length_key)
69
73
  return if number.nil?
70
- number.rjust(structure[length_key], "X")
74
+ number.rjust(structure[length_key], padding_character)
71
75
  end
72
76
 
73
77
  def structure
@@ -65,12 +65,17 @@ module Ibandit
65
65
  Constants::PSEUDO_IBAN_COUNTRY_CODES.include?(country_code)
66
66
  end
67
67
 
68
+ def padding_character
69
+ Constants::PSEUDO_IBAN_PADDING_CHARACTER_FOR[country_code]
70
+ end
71
+
68
72
  def structure
69
73
  Ibandit.structures[country_code]
70
74
  end
71
75
 
72
76
  def remove_leading_padding(input)
73
- input.gsub(/\AX+/, "")
77
+ return unless padding_character
78
+ input.gsub(/\A#{padding_character}+/, "")
74
79
  end
75
80
  end
76
81
  end
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = "0.11.10".freeze
2
+ VERSION = "0.11.11".freeze
3
3
  end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ describe Ibandit::Constants do
4
+ Ibandit::Constants::PSEUDO_IBAN_COUNTRY_CODES.each do |country_code|
5
+ context country_code do
6
+ it "has padding character" do
7
+ padding =
8
+ Ibandit::Constants::PSEUDO_IBAN_PADDING_CHARACTER_FOR[country_code]
9
+ expect(padding).to_not be_nil
10
+ expect(padding.length).to eq(1)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -202,19 +202,53 @@ describe Ibandit::IBAN do
202
202
  its(:to_s) { is_expected.to eq("") }
203
203
  end
204
204
 
205
- context "and a 10 characters alphanumeric account number" do
206
- let(:account_number) { "AB1234567" }
205
+ context "and a 10 characters account number" do
206
+ let(:account_number) { "ABC1234567" }
207
207
 
208
208
  its(:country_code) { is_expected.to eq("AU") }
209
209
  its(:bank_code) { is_expected.to be_nil }
210
210
  its(:branch_code) { is_expected.to eq("123456") }
211
- its(:account_number) { is_expected.to eq("0AB1234567") }
211
+ its(:account_number) { is_expected.to eq("ABC1234567") }
212
212
  its(:swift_bank_code) { is_expected.to be_nil }
213
213
  its(:swift_branch_code) { is_expected.to eq("123456") }
214
- its(:swift_account_number) { is_expected.to eq("0AB1234567") }
214
+ its(:swift_account_number) { is_expected.to eq("ABC1234567") }
215
215
  its(:swift_national_id) { is_expected.to eq("123456") }
216
216
  its(:iban) { is_expected.to be_nil }
217
- its(:pseudo_iban) { is_expected.to eq("AUZZ1234560AB1234567") }
217
+ its(:pseudo_iban) { is_expected.to eq("AUZZ123456ABC1234567") }
218
+ its(:valid?) { is_expected.to eq(true) }
219
+ its(:to_s) { is_expected.to eq("") }
220
+ end
221
+
222
+ context "and a 9 characters account number starting with X" do
223
+ let(:account_number) { "XX1234567" }
224
+
225
+ its(:country_code) { is_expected.to eq("AU") }
226
+ its(:bank_code) { is_expected.to be_nil }
227
+ its(:branch_code) { is_expected.to eq("123456") }
228
+ its(:account_number) { is_expected.to eq("0XX1234567") }
229
+ its(:swift_bank_code) { is_expected.to be_nil }
230
+ its(:swift_branch_code) { is_expected.to eq("123456") }
231
+ its(:swift_account_number) { is_expected.to eq("0XX1234567") }
232
+ its(:swift_national_id) { is_expected.to eq("123456") }
233
+ its(:iban) { is_expected.to be_nil }
234
+ its(:pseudo_iban) { is_expected.to eq("AUZZ1234560XX1234567") }
235
+ its(:valid?) { is_expected.to eq(true) }
236
+ its(:to_s) { is_expected.to eq("") }
237
+ end
238
+
239
+ context "and a 10 characters account number starting with X" do
240
+ let(:account_number) { "XX12345678" }
241
+
242
+ its(:country_code) { is_expected.to eq("AU") }
243
+ its(:bank_code) { is_expected.to be_nil }
244
+ its(:branch_code) { is_expected.to eq("123456") }
245
+ its(:account_number) { is_expected.to eq("XX12345678") }
246
+ its(:swift_bank_code) { is_expected.to be_nil }
247
+ its(:swift_branch_code) { is_expected.to eq("123456") }
248
+ its(:swift_account_number) { is_expected.to eq("XX12345678") }
249
+ its(:swift_national_id) { is_expected.to eq("123456") }
250
+ its(:iban) { is_expected.to be_nil }
251
+ its(:pseudo_iban) { is_expected.to eq("AUZZ123456XX12345678") }
218
252
  its(:valid?) { is_expected.to eq(true) }
219
253
  its(:to_s) { is_expected.to eq("") }
220
254
  end
@@ -235,6 +269,23 @@ describe Ibandit::IBAN do
235
269
  its(:pseudo_iban) { is_expected.to eq("AUZZ1234560123456789") }
236
270
  its(:valid?) { is_expected.to eq(true) }
237
271
  its(:to_s) { is_expected.to eq("") }
272
+
273
+ context "with a leading X on the account number" do
274
+ let(:arg) { "AUZZ123456XABCD12345" }
275
+
276
+ its(:country_code) { is_expected.to eq("AU") }
277
+ its(:bank_code) { is_expected.to be_nil }
278
+ its(:branch_code) { is_expected.to eq("123456") }
279
+ its(:account_number) { is_expected.to eq("XABCD12345") }
280
+ its(:swift_bank_code) { is_expected.to be_nil }
281
+ its(:swift_branch_code) { is_expected.to eq("123456") }
282
+ its(:swift_account_number) { is_expected.to eq("XABCD12345") }
283
+ its(:swift_national_id) { is_expected.to eq("123456") }
284
+ its(:iban) { is_expected.to be_nil }
285
+ its(:pseudo_iban) { is_expected.to eq("AUZZ123456XABCD12345") }
286
+ its(:valid?) { is_expected.to eq(true) }
287
+ its(:to_s) { is_expected.to eq("") }
288
+ end
238
289
  end
239
290
 
240
291
  context "when the input is an invalid Australian pseudo-IBAN" do
@@ -52,6 +52,18 @@ describe Ibandit::PseudoIBANAssembler do
52
52
  it { is_expected.to eq("AUZZ123456A123456789") }
53
53
  end
54
54
 
55
+ context "with valid parameters and padding" do
56
+ let(:local_details) do
57
+ {
58
+ country_code: "AU",
59
+ branch_code: "123456",
60
+ account_number: "XABC",
61
+ }
62
+ end
63
+
64
+ it { is_expected.to eq("AUZZ123456______XABC") }
65
+ end
66
+
55
67
  context "without a branch code" do
56
68
  let(:local_details) do
57
69
  {
@@ -23,5 +23,41 @@ describe Ibandit::PseudoIBANSplitter do
23
23
  its([:branch_code]) { is_expected.to eq("123456") }
24
24
  its([:account_number]) { is_expected.to eq("123456789") }
25
25
  end
26
+
27
+ context "for an australian pseudo-IBAN with padding" do
28
+ let(:pseudo_iban) { "AUZZ123456______XABC" }
29
+
30
+ its([:country_code]) { is_expected.to eq("AU") }
31
+ its([:bank_code]) { is_expected.to be_nil }
32
+ its([:branch_code]) { is_expected.to eq("123456") }
33
+ its([:account_number]) { is_expected.to eq("XABC") }
34
+ end
35
+
36
+ context "for an australian 10 character alphanumeric pseudo-iban" do
37
+ let(:pseudo_iban) { "AUZZ12345601234567AB" }
38
+
39
+ its([:country_code]) { is_expected.to eq("AU") }
40
+ its([:bank_code]) { is_expected.to be_nil }
41
+ its([:branch_code]) { is_expected.to eq("123456") }
42
+ its([:account_number]) { is_expected.to eq("01234567AB") }
43
+ end
44
+
45
+ context "for an australian 10 character pseudo-iban with an X" do
46
+ let(:pseudo_iban) { "AUZZ1234560X12345678" }
47
+
48
+ its([:country_code]) { is_expected.to eq("AU") }
49
+ its([:bank_code]) { is_expected.to be_nil }
50
+ its([:branch_code]) { is_expected.to eq("123456") }
51
+ its([:account_number]) { is_expected.to eq("0X12345678") }
52
+ end
53
+
54
+ context "for an australian 10 character pseudo-iban with a leading X" do
55
+ let(:pseudo_iban) { "AUZZ123456X123456789" }
56
+
57
+ its([:country_code]) { is_expected.to eq("AU") }
58
+ its([:bank_code]) { is_expected.to be_nil }
59
+ its([:branch_code]) { is_expected.to eq("123456") }
60
+ its([:account_number]) { is_expected.to eq("X123456789") }
61
+ end
26
62
  end
27
63
  end
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.11.10
4
+ version: 0.11.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -174,6 +174,7 @@ files:
174
174
  - lib/ibandit/version.rb
175
175
  - spec/fixtures/germany_integration_test_cases.json
176
176
  - spec/fixtures/germany_unit_test_cases.json
177
+ - spec/ibandit/constants_spec.rb
177
178
  - spec/ibandit/german_details_converter_spec.rb
178
179
  - spec/ibandit/iban_assembler_spec.rb
179
180
  - spec/ibandit/iban_spec.rb
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  version: '0'
206
207
  requirements: []
207
208
  rubyforge_project:
208
- rubygems_version: 2.6.14
209
+ rubygems_version: 2.6.13
209
210
  signing_key:
210
211
  specification_version: 4
211
212
  summary: Convert national banking details into IBANs, and vice-versa.