ibandit 1.33.0 → 1.35.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +14 -8
- data/data/raw/pseudo_ibans.yml +1 -1
- data/data/structures.yml +1 -1
- data/lib/ibandit/local_details_cleaner.rb +6 -6
- data/lib/ibandit/version.rb +1 -1
- data/spec/fixtures/germany_integration_test_cases.json +0 -21
- data/spec/fixtures/germany_unit_test_cases.json +0 -6
- data/spec/ibandit/iban_spec.rb +28 -4
- data/spec/ibandit/local_details_cleaner_spec.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c66078162418a28f36b4b770f14683b5ef73404be4317d999e104c106887c6d
|
|
4
|
+
data.tar.gz: 41764feef79fdd0da97fc0a9dd45224d3f49f01599cf21c9b739f73c1b44814b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 990c8803f134029f9c080ee728d4d0a6c419fef6897cac6ecf0021cc93a504700bded9fecf2db7f70fddbf040616ac6ec3257f29eb87434e47fbf6541c4bcc3f
|
|
7
|
+
data.tar.gz: da30ef6a3c3ed3a6173d197ec2f711ef07b4a6462e12bf2193ebf759daa669ae3eabc4a07ae17ca7bc4da7feabd65d8f0c8831eebf0baebd1429cb8df36ab684
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 1.35.0 - September 28, 2026
|
|
2
|
+
|
|
3
|
+
- Accept one-digit NZ account suffixes and normalise them to the three-digit bank form.
|
|
4
|
+
|
|
5
|
+
## 1.34.0 - September 11, 2026
|
|
6
|
+
|
|
7
|
+
- [Breaking] Reject NZ account numbers whose 3 digit suffix does not start with a zero
|
|
8
|
+
|
|
1
9
|
## 1.33.0 - September 2, 2026
|
|
2
10
|
|
|
3
11
|
- Update BLZ data - BLZ_20260907
|
data/README.md
CHANGED
|
@@ -548,20 +548,26 @@ iban = Ibandit::IBAN.new(
|
|
|
548
548
|
iban.pseudo_iban # => "NZZZ0100043333333044"
|
|
549
549
|
iban.iban # => nil
|
|
550
550
|
|
|
551
|
+
# A 1 or 2 digit suffix is padded with leading zeroes to the three-digit bank
|
|
552
|
+
# form. A suffix supplied with 3 digits must already start with a zero: `S`
|
|
553
|
+
# becomes `00S`, `SS` becomes `0SS`, never `SS0`.
|
|
554
|
+
|
|
551
555
|
iban = Ibandit::IBAN.new(
|
|
552
556
|
country_code: 'NZ',
|
|
553
557
|
account_number: '01-0004-3333333-44'
|
|
554
558
|
)
|
|
555
|
-
iban.pseudo_iban
|
|
556
|
-
iban.bank_code
|
|
557
|
-
iban.branch_code
|
|
558
|
-
iban.account_number
|
|
559
|
+
iban.pseudo_iban # => "NZZZ0100043333333044"
|
|
560
|
+
iban.bank_code # => "01"
|
|
561
|
+
iban.branch_code # => "0004"
|
|
562
|
+
iban.account_number # => "3333333"
|
|
563
|
+
iban.account_number_suffix # => "044"
|
|
559
564
|
|
|
560
565
|
iban = Ibandit::IBAN.new('NZZZ0100043333333044')
|
|
561
|
-
iban.country_code
|
|
562
|
-
iban.bank_code
|
|
563
|
-
iban.branch_code
|
|
564
|
-
iban.account_number
|
|
566
|
+
iban.country_code # => "NZ"
|
|
567
|
+
iban.bank_code # => "01"
|
|
568
|
+
iban.branch_code # => "0004"
|
|
569
|
+
iban.account_number # => "3333333"
|
|
570
|
+
iban.account_number_suffix # => "044"
|
|
565
571
|
|
|
566
572
|
# USA
|
|
567
573
|
iban = Ibandit::IBAN.new(
|
data/data/raw/pseudo_ibans.yml
CHANGED
|
@@ -35,7 +35,7 @@ NZ:
|
|
|
35
35
|
:account_number_length: 10
|
|
36
36
|
:bank_code_format: "\\d{2}"
|
|
37
37
|
:branch_code_format: "\\d{4}"
|
|
38
|
-
:account_number_format: "\\d{7}\\d{
|
|
38
|
+
:account_number_format: "\\d{7}0\\d{2}"
|
|
39
39
|
:pseudo_iban_bank_code_length: 2
|
|
40
40
|
:pseudo_iban_branch_code_length: 4
|
|
41
41
|
:pseudo_iban_account_number_length: 10
|
data/data/structures.yml
CHANGED
|
@@ -1598,7 +1598,7 @@ NZ:
|
|
|
1598
1598
|
:account_number_length: 10
|
|
1599
1599
|
:bank_code_format: "\\d{2}"
|
|
1600
1600
|
:branch_code_format: "\\d{4}"
|
|
1601
|
-
:account_number_format: "\\d{7}\\d{
|
|
1601
|
+
:account_number_format: "\\d{7}0\\d{2}"
|
|
1602
1602
|
:pseudo_iban_bank_code_length: 2
|
|
1603
1603
|
:pseudo_iban_branch_code_length: 4
|
|
1604
1604
|
:pseudo_iban_account_number_length: 10
|
|
@@ -468,12 +468,12 @@ module Ibandit
|
|
|
468
468
|
|
|
469
469
|
def self.clean_nz_details(local_details)
|
|
470
470
|
# This method supports being passed the component parts of the NZ account
|
|
471
|
-
# number, or a single 15/16 digit string
|
|
471
|
+
# number, or a single 14/15/16 digit string with a 1/2/3-digit suffix in the
|
|
472
472
|
# account number field.
|
|
473
473
|
#
|
|
474
|
-
# When given a 15/16 digit string, the component parts (i.e bank_code,
|
|
474
|
+
# When given a 14/15/16 digit string, the component parts (i.e bank_code,
|
|
475
475
|
# branch_code and account_number) are extracted, with the 7-digit account
|
|
476
|
-
# number body and 2/3-digit account number suffix making up the actual
|
|
476
|
+
# number body and 1/2/3-digit account number suffix making up the actual
|
|
477
477
|
# account_number field.
|
|
478
478
|
if local_details[:bank_code] && local_details[:branch_code]
|
|
479
479
|
bank_code = local_details[:bank_code]
|
|
@@ -486,7 +486,7 @@ module Ibandit
|
|
|
486
486
|
account_number = cleaned_account_number[6..]
|
|
487
487
|
end
|
|
488
488
|
|
|
489
|
-
if account_number && account_number.length
|
|
489
|
+
if account_number && [8, 9].include?(account_number.length)
|
|
490
490
|
# > Some banks (such as BNZ) include three digits of the suffix in their
|
|
491
491
|
# > presentation of the account number to the end customer. Other banks
|
|
492
492
|
# > only show the last two digits of the suffix to the end customer.
|
|
@@ -494,8 +494,8 @@ module Ibandit
|
|
|
494
494
|
# > first digit of the suffix is always 0 so it's usually ignored.
|
|
495
495
|
# > [https://en.wikipedia.org/wiki/New_Zealand_bank_account_number]
|
|
496
496
|
#
|
|
497
|
-
# Here, we
|
|
498
|
-
account_number = account_number[0..6] +
|
|
497
|
+
# Here, we restore omitted leading zeros in the suffix.
|
|
498
|
+
account_number = account_number[0..6] + account_number[7..].rjust(3, "0")
|
|
499
499
|
end
|
|
500
500
|
|
|
501
501
|
{
|
data/lib/ibandit/version.rb
CHANGED
|
@@ -12,15 +12,6 @@
|
|
|
12
12
|
{ "bank_code": "10060198", "account_number" : "1" }
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
|
-
// {
|
|
16
|
-
// "convertor": "000300",
|
|
17
|
-
// "valid": [
|
|
18
|
-
// { "bank_code": "51010800", "account_number" : "1" }
|
|
19
|
-
// ],
|
|
20
|
-
// "invalid": [
|
|
21
|
-
// { "bank_code": "51010800", "account_number" : "6161604670" }
|
|
22
|
-
// ]
|
|
23
|
-
// },
|
|
24
15
|
{
|
|
25
16
|
"convertor": "000400",
|
|
26
17
|
"valid": [
|
|
@@ -91,12 +82,6 @@
|
|
|
91
82
|
{"bank_code":"51020000","account_number":"30009963","converted_bank_code":"50020200","converted_account_number":"30009963"}
|
|
92
83
|
]
|
|
93
84
|
},
|
|
94
|
-
// {
|
|
95
|
-
// "convertor": "000900",
|
|
96
|
-
// "valid": [
|
|
97
|
-
// {"bank_code":"68351976","account_number":"1116232594","converted_bank_code":"68351557","converted_account_number":"3047232594"}
|
|
98
|
-
// ]
|
|
99
|
-
// },
|
|
100
85
|
{
|
|
101
86
|
"convertor": "001001",
|
|
102
87
|
"valid": [
|
|
@@ -157,10 +142,4 @@
|
|
|
157
142
|
{ "bank_code": "30060010", "account_number": "12345678", "converted_account_number": "12345678" }
|
|
158
143
|
]
|
|
159
144
|
}
|
|
160
|
-
// {
|
|
161
|
-
// "convertor": "001900",
|
|
162
|
-
// "valid": [
|
|
163
|
-
// { "bank_code": "50130100", "account_number": "556", "converted_bank_code": "50120383" }
|
|
164
|
-
// ]
|
|
165
|
-
// }
|
|
166
145
|
]
|
|
@@ -136,12 +136,6 @@
|
|
|
136
136
|
{ "bank_code": "10010010", "account_number" : "556", "converted_account_number": "0120440110" }
|
|
137
137
|
]
|
|
138
138
|
},
|
|
139
|
-
// {
|
|
140
|
-
// "convertor": "001900",
|
|
141
|
-
// "valid": [
|
|
142
|
-
// { "bank_code": "10010010", "account_number" : "1234567890", "converted_bank_code": "50120383" }
|
|
143
|
-
// ]
|
|
144
|
-
// },
|
|
145
139
|
{
|
|
146
140
|
"convertor": "002002",
|
|
147
141
|
"valid": [
|
data/spec/ibandit/iban_spec.rb
CHANGED
|
@@ -764,23 +764,34 @@ describe Ibandit::IBAN do
|
|
|
764
764
|
end
|
|
765
765
|
|
|
766
766
|
context "with a 3 digit account number suffix" do
|
|
767
|
-
let(:account_number) { "3333333-
|
|
767
|
+
let(:account_number) { "3333333-044" }
|
|
768
768
|
|
|
769
769
|
its(:country_code) { is_expected.to eq("NZ") }
|
|
770
770
|
its(:bank_code) { is_expected.to eq("11") }
|
|
771
771
|
its(:branch_code) { is_expected.to eq("2222") }
|
|
772
772
|
its(:account_number) { is_expected.to eq("3333333") }
|
|
773
|
-
its(:account_number_suffix) { is_expected.to eq("
|
|
773
|
+
its(:account_number_suffix) { is_expected.to eq("044") }
|
|
774
774
|
its(:swift_bank_code) { is_expected.to eq("11") }
|
|
775
775
|
its(:swift_branch_code) { is_expected.to eq("2222") }
|
|
776
|
-
its(:swift_account_number) { is_expected.to eq("
|
|
776
|
+
its(:swift_account_number) { is_expected.to eq("3333333044") }
|
|
777
777
|
its(:swift_national_id) { is_expected.to eq("112222") }
|
|
778
778
|
its(:iban) { is_expected.to be_nil }
|
|
779
|
-
its(:pseudo_iban) { is_expected.to eq("
|
|
779
|
+
its(:pseudo_iban) { is_expected.to eq("NZZZ1122223333333044") }
|
|
780
780
|
its(:valid?) { is_expected.to eq(true) }
|
|
781
781
|
its(:to_s) { is_expected.to eq("") }
|
|
782
782
|
end
|
|
783
783
|
|
|
784
|
+
context "with a 3 digit account number suffix not starting with a zero" do
|
|
785
|
+
let(:account_number) { "3333333-500" }
|
|
786
|
+
|
|
787
|
+
its(:account_number_suffix) { is_expected.to eq("500") }
|
|
788
|
+
|
|
789
|
+
it "is invalid and has the correct errors" do
|
|
790
|
+
expect(subject.valid?).to eq(false)
|
|
791
|
+
expect(subject.errors).to eq(account_number: "format is invalid")
|
|
792
|
+
end
|
|
793
|
+
end
|
|
794
|
+
|
|
784
795
|
context "with a 2 digit account number suffix" do
|
|
785
796
|
let(:account_number) { "3333333-44" }
|
|
786
797
|
|
|
@@ -799,6 +810,19 @@ describe Ibandit::IBAN do
|
|
|
799
810
|
its(:to_s) { is_expected.to eq("") }
|
|
800
811
|
end
|
|
801
812
|
|
|
813
|
+
context "with a 1 digit account number suffix" do
|
|
814
|
+
let(:account_number) { "3333333-1" }
|
|
815
|
+
|
|
816
|
+
its(:country_code) { is_expected.to eq("NZ") }
|
|
817
|
+
its(:bank_code) { is_expected.to eq("11") }
|
|
818
|
+
its(:branch_code) { is_expected.to eq("2222") }
|
|
819
|
+
its(:account_number) { is_expected.to eq("3333333") }
|
|
820
|
+
its(:account_number_suffix) { is_expected.to eq("001") }
|
|
821
|
+
its(:swift_account_number) { is_expected.to eq("3333333001") }
|
|
822
|
+
its(:pseudo_iban) { is_expected.to eq("NZZZ1122223333333001") }
|
|
823
|
+
its(:valid?) { is_expected.to eq(true) }
|
|
824
|
+
end
|
|
825
|
+
|
|
802
826
|
context "with a nil account number" do
|
|
803
827
|
let(:account_number) { nil }
|
|
804
828
|
|
|
@@ -1076,6 +1076,14 @@ describe Ibandit::LocalDetailsCleaner do
|
|
|
1076
1076
|
its([:branch_code]) { is_expected.to eq("2222") }
|
|
1077
1077
|
its([:account_number]) { is_expected.to eq("3333333044") }
|
|
1078
1078
|
|
|
1079
|
+
context "with a 1-digit account number suffix" do
|
|
1080
|
+
let(:account_number) { "11-2222-3333333-1" }
|
|
1081
|
+
|
|
1082
|
+
its([:bank_code]) { is_expected.to eq("11") }
|
|
1083
|
+
its([:branch_code]) { is_expected.to eq("2222") }
|
|
1084
|
+
its([:account_number]) { is_expected.to eq("3333333001") }
|
|
1085
|
+
end
|
|
1086
|
+
|
|
1079
1087
|
context "with a 2-digit account number suffix" do
|
|
1080
1088
|
let(:account_number) { "11-2222-3333333-44" }
|
|
1081
1089
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ibandit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.35.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GoCardless
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-09-28 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: i18n
|
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
114
114
|
- !ruby/object:Gem::Version
|
|
115
115
|
version: '0'
|
|
116
116
|
requirements: []
|
|
117
|
-
rubygems_version: 3.6.
|
|
117
|
+
rubygems_version: 3.6.2
|
|
118
118
|
specification_version: 4
|
|
119
119
|
summary: Convert national banking details into IBANs, and vice-versa.
|
|
120
120
|
test_files: []
|