ibandit 1.34.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94889979e0c49c255ce74acc38b1c9462b36bc4e4d9a80c214ae8905047dba4d
4
- data.tar.gz: 4aa46bac681573a174c62ee4879fedefcbe56d11c18e8d6743c67c72e77849c7
3
+ metadata.gz: 0c66078162418a28f36b4b770f14683b5ef73404be4317d999e104c106887c6d
4
+ data.tar.gz: 41764feef79fdd0da97fc0a9dd45224d3f49f01599cf21c9b739f73c1b44814b
5
5
  SHA512:
6
- metadata.gz: 8606eb4bf0b1524196175ddce5e4b0f153d5cbbcda1767ef8985a8bc2df1a3abcbba63847243b15a461b1892f14c89e6c75fbe72815274940275b73afa929e01
7
- data.tar.gz: fe4757e398d63e1d9a9552e7a8f4d5e02b2074fa04617b6d4a402d7c615513ded4e09e9cc820483659a649a984c05a67f7356c1453ec49e4e57f7276c8ef8269
6
+ metadata.gz: 990c8803f134029f9c080ee728d4d0a6c419fef6897cac6ecf0021cc93a504700bded9fecf2db7f70fddbf040616ac6ec3257f29eb87434e47fbf6541c4bcc3f
7
+ data.tar.gz: da30ef6a3c3ed3a6173d197ec2f711ef07b4a6462e12bf2193ebf759daa669ae3eabc4a07ae17ca7bc4da7feabd65d8f0c8831eebf0baebd1429cb8df36ab684
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
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
+
1
5
  ## 1.34.0 - September 11, 2026
2
6
 
3
7
  - [Breaking] Reject NZ account numbers whose 3 digit suffix does not start with a zero
data/README.md CHANGED
@@ -548,8 +548,9 @@ iban = Ibandit::IBAN.new(
548
548
  iban.pseudo_iban # => "NZZZ0100043333333044"
549
549
  iban.iban # => nil
550
550
 
551
- # A 2 digit suffix is padded with a leading zero. A suffix given as 3 digits
552
- # must already start with that zero: `SS` becomes `0SS`, never `SS0`.
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`.
553
554
 
554
555
  iban = Ibandit::IBAN.new(
555
556
  country_code: 'NZ',
@@ -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 (BBbbbb-AAAAAAA-0SS) in the
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 == 9
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 insert the zero in cases where it is ignored.
498
- account_number = account_number[0..6] + "0" + account_number[7..8]
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
  {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibandit
4
- VERSION = "1.34.0"
4
+ VERSION = "1.35.0"
5
5
  end
@@ -810,6 +810,19 @@ describe Ibandit::IBAN do
810
810
  its(:to_s) { is_expected.to eq("") }
811
811
  end
812
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
+
813
826
  context "with a nil account number" do
814
827
  let(:account_number) { nil }
815
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.34.0
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: 2026-09-14 00:00:00.000000000 Z
10
+ date: 2026-09-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: i18n