Skip to content

Commit

Permalink
Allow 5 digits account numbers for Australian bank details
Browse files Browse the repository at this point in the history
It appears that 5-digits account numbers are valid accounts in Australia.
  • Loading branch information
ivgiuliani committed May 30, 2018
1 parent 71a04aa commit 1786200
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ibandit/local_details_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("-"),
Expand Down
36 changes: 36 additions & 0 deletions spec/ibandit/iban_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 1786200

Please sign in to comment.