From a117dbb699b7f16f6cc2225bf8a73c17eebf3b57 Mon Sep 17 00:00:00 2001 From: George Allen Date: Wed, 7 Feb 2018 18:50:34 +0000 Subject: [PATCH] Return correct swift national id for Australia The swift national id in Australia is the 6 digit BSB number. --- data/structures.yml | 1 + lib/ibandit/iban.rb | 2 +- spec/ibandit/iban_spec.rb | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/data/structures.yml b/data/structures.yml index 7dece86..e68038a 100644 --- a/data/structures.yml +++ b/data/structures.yml @@ -58,6 +58,7 @@ AU: :pseudo_iban_bank_code_length: 0 :pseudo_iban_branch_code_length: 6 :pseudo_iban_account_number_length: 9 + :national_id_length: 6 AZ: :bank_code_position: 5 :bank_code_length: 4 diff --git a/lib/ibandit/iban.rb b/lib/ibandit/iban.rb index d667b1a..229f491 100644 --- a/lib/ibandit/iban.rb +++ b/lib/ibandit/iban.rb @@ -45,7 +45,7 @@ def to_s(format = :compact) ################### def swift_national_id - return unless decomposable? + return if swift_bank_code.nil? && swift_branch_code.nil? national_id = swift_bank_code.to_s national_id += swift_branch_code.to_s diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 54c67f5..20daebd 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -175,6 +175,7 @@ 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("123456789") } + its(:swift_national_id) { is_expected.to eq("123456") } its(:iban) { is_expected.to be_nil } its(:pseudo_iban) { is_expected.to eq("AUZZ123456123456789") } its(:valid?) { is_expected.to eq(true) } @@ -191,6 +192,7 @@ 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("123456789") } + its(:swift_national_id) { is_expected.to eq("123456") } its(:iban) { is_expected.to be_nil } its(:pseudo_iban) { is_expected.to eq("AUZZ123456123456789") } its(:valid?) { is_expected.to eq(true) }