ibandit 0.11.23 → 0.11.24

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
- SHA256:
3
- metadata.gz: 0a541f50d4ef769df481b72fb36721389dee789f3b1999f20de23775f7523ef4
4
- data.tar.gz: 6e4317de4d3169b29dc6622ee30fbcd8c8b35be6d442ce3a26a4368b5618c8d9
2
+ SHA1:
3
+ metadata.gz: 668b1fb51b7cf069a3571031168991cdb97f0ea2
4
+ data.tar.gz: 4bfe3207906007a781617a7dbff3bbbe6bb82f25
5
5
  SHA512:
6
- metadata.gz: d1e7d29847abf410e11231539ba884fd0e542ea897a7ced9a888a737514fd33d76a8f5a67fbc66a87a1c714a89a39eab7fe9e44341e6073ab5fa7dafd7f5b459
7
- data.tar.gz: c690750c7f99853e34f08d973f02e02da391e7e7b7795c4d16e2abdde2be577d1ade377a42d289092df012a3ef3b4c0d0c24f17081693f2d3ce7ecb630e9d174
6
+ metadata.gz: bb3d8b5054d45f508f88a686040dfc51a8a3e4bd1971fe54300c31015cc5cd34ed81a8788740574f703d59738651b49f1852db0156bd22d35c4c8afdd6f19a5c
7
+ data.tar.gz: fe66a3af2e980f0f40d09e4db3b99391cfa3442cd23ce14a31e780b9d6a1ee0bcbc3e0c05f112d387b820b03fb7fe4dffedc6360eca2273832d881503fd8b466
@@ -1,3 +1,7 @@
1
+ ## 0.11.24 - December 13, 2018
2
+
3
+ - Add support for 3-digit financial institution numbers in Canada
4
+
1
5
  ## 0.11.23 - December 5, 2018
2
6
 
3
7
  - Add support for validating Canadian branch codes if a modulus checker is configured
data/README.md CHANGED
@@ -523,7 +523,7 @@ iban.iban # => nil
523
523
  # Canada
524
524
  iban = Ibandit::IBAN.new(
525
525
  country_code: 'CA',
526
- bank_code: '0036', # 4 Financial Institution number
526
+ bank_code: '0036', # 3 or 4 digit Financial Institution number
527
527
  branch_code: '00063', # 5 digit Branch Transit number
528
528
  account_number: '0123456' # 7 to 12 digits
529
529
  )
@@ -87,7 +87,16 @@ module Ibandit
87
87
  def self.clean_ca_details(local_details)
88
88
  return {} if local_details[:account_number].length < 7 # minimum length
89
89
 
90
- { account_number: local_details[:account_number].rjust(12, "0") }
90
+ bank_code = if local_details[:bank_code].length == 3
91
+ local_details[:bank_code].rjust(4, "0")
92
+ else
93
+ local_details[:bank_code]
94
+ end
95
+
96
+ {
97
+ account_number: local_details[:account_number].rjust(12, "0"),
98
+ bank_code: bank_code,
99
+ }
91
100
  end
92
101
 
93
102
  def self.clean_bg_details(local_details)
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = "0.11.23".freeze
2
+ VERSION = "0.11.24".freeze
3
3
  end
@@ -362,14 +362,53 @@ describe Ibandit::IBAN do
362
362
  let(:arg) do
363
363
  {
364
364
  country_code: "CA",
365
- bank_code: "0036",
365
+ bank_code: bank_code,
366
366
  branch_code: "00063",
367
367
  account_number: account_number,
368
368
  }
369
369
  end
370
370
 
371
+ context "and a 3 digit bank code" do
372
+ let(:account_number) { "0123456" }
373
+ let(:bank_code) { "036" }
374
+
375
+ its(:country_code) { is_expected.to eq("CA") }
376
+ its(:bank_code) { is_expected.to eq("0036") }
377
+ its(:branch_code) { is_expected.to eq("00063") }
378
+ its(:account_number) { is_expected.to eq("000000123456") }
379
+ its(:swift_bank_code) { is_expected.to eq("0036") }
380
+ its(:swift_branch_code) { is_expected.to eq("00063") }
381
+ its(:swift_account_number) { is_expected.to eq("000000123456") }
382
+ its(:swift_national_id) { is_expected.to eq("0036") }
383
+ its(:pseudo_iban) { is_expected.to eq("CAZZ003600063000000123456") }
384
+
385
+ its(:iban) { is_expected.to be_nil }
386
+ its(:valid?) { is_expected.to eq(true) }
387
+ its(:to_s) { is_expected.to eq("") }
388
+ end
389
+
390
+ context "and a 2 digit bank code" do
391
+ let(:account_number) { "0123456" }
392
+ let(:bank_code) { "36" }
393
+
394
+ its(:country_code) { is_expected.to eq("CA") }
395
+ its(:bank_code) { is_expected.to eq("36") }
396
+ its(:branch_code) { is_expected.to eq("00063") }
397
+ its(:account_number) { is_expected.to eq("000000123456") }
398
+ its(:swift_bank_code) { is_expected.to eq("36") }
399
+ its(:swift_branch_code) { is_expected.to eq("00063") }
400
+ its(:swift_account_number) { is_expected.to eq("000000123456") }
401
+ its(:swift_national_id) { is_expected.to eq("3600") }
402
+ its(:pseudo_iban) { is_expected.to eq("CAZZ__3600063000000123456") }
403
+
404
+ its(:iban) { is_expected.to be_nil }
405
+ its(:valid?) { is_expected.to eq(false) }
406
+ its(:to_s) { is_expected.to eq("") }
407
+ end
408
+
371
409
  context "and a 7 digit account number" do
372
410
  let(:account_number) { "0123456" }
411
+ let(:bank_code) { "0036" }
373
412
 
374
413
  its(:country_code) { is_expected.to eq("CA") }
375
414
  its(:bank_code) { is_expected.to eq("0036") }
@@ -388,6 +427,7 @@ describe Ibandit::IBAN do
388
427
 
389
428
  context "and a 12 digit account number" do
390
429
  let(:account_number) { "012345678900" }
430
+ let(:bank_code) { "0036" }
391
431
 
392
432
  its(:country_code) { is_expected.to eq("CA") }
393
433
  its(:bank_code) { is_expected.to eq("0036") }
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.23
4
+ version: 0.11.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-05 00:00:00.000000000 Z
11
+ date: 2018-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.7.3
213
+ rubygems_version: 2.5.2.3
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Convert national banking details into IBANs, and vice-versa.