Skip to content

Commit

Permalink
Merge pull request #99 from gocardless/five-digits-accno
Browse files Browse the repository at this point in the history
Allow 5 digits account numbers for Australian bank details
  • Loading branch information
ivgiuliani authored May 30, 2018
2 parents 71a04aa + dc70ce9 commit a95fc0a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
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
2 changes: 1 addition & 1 deletion lib/ibandit/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Ibandit
VERSION = "0.11.12".freeze
VERSION = "0.11.13".freeze
end
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 a95fc0a

Please sign in to comment.