diff --git a/lib/cmxl/fields/account_identification.rb b/lib/cmxl/fields/account_identification.rb index 617c686..e1f9794 100644 --- a/lib/cmxl/fields/account_identification.rb +++ b/lib/cmxl/fields/account_identification.rb @@ -2,7 +2,7 @@ module Cmxl module Fields class AccountIdentification < Field self.tag = 25 - self.parser = /(?\w{8,11})\/(?\d{0,23})(?[A-Z]{3})?|(?[a-zA-Z]{2})(?\d{11,36})/i + self.parser = /(?\w{7,11})\/(?\d{0,23})\/?(?[A-Z]{3})?|(?[a-zA-Z]{2})(?\d{11,36})/i def iban "#{country}#{ban}" diff --git a/spec/fields/account_identification_spec.rb b/spec/fields/account_identification_spec.rb index 4210cdd..9b70363 100644 --- a/spec/fields/account_identification_spec.rb +++ b/spec/fields/account_identification_spec.rb @@ -10,6 +10,15 @@ it { expect(subject.country).to be_nil } end + context 'legacy data with spillted iban' do + subject { Cmxl::Fields::AccountBalance.parse( fixture_line(:account_identification_short) ) } + + it { expect(subject.bank_code).to eql('AT32000') } + it { expect(subject.account_number).to eql('4005287001') } + it { expect(subject.currency).to eql('EUR') } + it { expect(subject.country).to be_nil } + end + context 'iban' do subject { Cmxl::Fields::AccountBalance.parse(fixture_line(:account_identification_iban)) } it { expect(subject.country).to eql('PL') } diff --git a/spec/fixtures/lines/account_identification_short.txt b/spec/fixtures/lines/account_identification_short.txt new file mode 100644 index 0000000..0af5e53 --- /dev/null +++ b/spec/fixtures/lines/account_identification_short.txt @@ -0,0 +1 @@ +:25:AT32000/4005287001/EUR