Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cmxl/fields/account_identification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Cmxl
module Fields
class AccountIdentification < Field
self.tag = 25
self.parser = /(?<bank_code>\w{8,11})\/(?<account_number>\d{0,23})(?<currency>[A-Z]{3})?|(?<country>[a-zA-Z]{2})(?<ban>\d{11,36})/i
self.parser = /(?<bank_code>\w{7,11})\/(?<account_number>\d{0,23})\/?(?<currency>[A-Z]{3})?|(?<country>[a-zA-Z]{2})(?<ban>\d{11,36})/i

def iban
"#{country}#{ban}"
Expand Down
9 changes: 9 additions & 0 deletions spec/fields/account_identification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/lines/account_identification_short.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:25:AT32000/4005287001/EUR