From 1786200efc56d40b77b8727ac271bdb775c0869e Mon Sep 17 00:00:00 2001 From: Ivan Giuliani Date: Wed, 30 May 2018 10:36:55 +0100 Subject: [PATCH 1/2] Allow 5 digits account numbers for Australian bank details It appears that 5-digits account numbers are valid accounts in Australia. --- lib/ibandit/local_details_cleaner.rb | 4 ++-- spec/ibandit/iban_spec.rb | 36 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/ibandit/local_details_cleaner.rb b/lib/ibandit/local_details_cleaner.rb index d5bfaa4..8034028 100644 --- a/lib/ibandit/local_details_cleaner.rb +++ b/lib/ibandit/local_details_cleaner.rb @@ -65,8 +65,8 @@ def self.clean_au_details(local_details) # Account number may be up to 10 digits long. # Add leading zeros to account number if < 10 digits. # - # Minimum account_number length is 6 - return {} unless local_details[:account_number].length >= 6 + # Minimum account_number length is 5 + return {} unless local_details[:account_number].length >= 5 { branch_code: local_details[:branch_code].delete("-"), diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 55239ed..e1d66e0 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -185,6 +185,23 @@ its(:to_s) { is_expected.to eq("") } end + context "and a 5 digit account number" do + let(:account_number) { "12345" } + + its(:country_code) { is_expected.to eq("AU") } + its(:bank_code) { is_expected.to be_nil } + its(:branch_code) { is_expected.to eq("123456") } + its(:account_number) { is_expected.to eq("0000012345") } + its(:swift_bank_code) { is_expected.to be_nil } + its(:swift_branch_code) { is_expected.to eq("123456") } + its(:swift_account_number) { is_expected.to eq("0000012345") } + its(:swift_national_id) { is_expected.to eq("123456") } + its(:iban) { is_expected.to be_nil } + its(:pseudo_iban) { is_expected.to eq("AUZZ1234560000012345") } + its(:valid?) { is_expected.to eq(true) } + its(:to_s) { is_expected.to eq("") } + end + context "and a 6 digit account number" do let(:account_number) { "123456" } @@ -300,6 +317,25 @@ end end + context "when the input is an account number too short for Australia" do + let(:arg) do + { + country_code: "AU", + branch_code: "123456", + account_number: "1234", + } + end + + its(:iban) { is_expected.to be_nil } + its(:pseudo_iban) { is_expected.to eq("AUZZ123456______1234") } + it "is invalid and has the correct errors" do + expect(subject.valid?).to eq(false) + expect(subject.errors).to eq( + account_number: "is the wrong length (should be 10 characters)", + ) + end + end + context "when the input is invalid local details for Australia" do let(:arg) do { From dc70ce94e30b132d1a55f59214d3f69b25cd0459 Mon Sep 17 00:00:00 2001 From: Ivan Giuliani Date: Wed, 30 May 2018 10:42:13 +0100 Subject: [PATCH 2/2] Bump version number and update changelog --- CHANGELOG.md | 4 ++++ lib/ibandit/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0aa630..6f02baa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.13 - May 30, 2018 + +- Allow 5-digits Australian account numbers + ## 0.11.12 - March 21, 2018 - Validate Australian BSBs diff --git a/lib/ibandit/version.rb b/lib/ibandit/version.rb index a20d8a8..6518c14 100644 --- a/lib/ibandit/version.rb +++ b/lib/ibandit/version.rb @@ -1,3 +1,3 @@ module Ibandit - VERSION = "0.11.12".freeze + VERSION = "0.11.13".freeze end