spec/mt940_ing_spec.rb in zilverline-mt940-1.0 vs spec/mt940_ing_spec.rb in zilverline-mt940-2.0

- old
+ new

@@ -3,11 +3,11 @@ describe "ING" do context 'old mt940' do before :each do @file_name = File.dirname(__FILE__) + '/fixtures/ing.txt' - @bank_statements = MT940::Base.parse_mt940(@file_name)["1234567"] + @bank_statements = MT940Structured::Parser.parse_mt940(@file_name)["1234567"] @transactions = @bank_statements.flat_map(&:transactions) @transaction = @transactions.first end it 'have the correct number of transactions' do @@ -64,11 +64,11 @@ context 'new mt940' do before :each do @file_name = File.dirname(__FILE__) + '/fixtures/ing_structured.txt' - @bank_statements = MT940::Base.parse_mt940(@file_name)["1234567"] + @bank_statements = MT940Structured::Parser.parse_mt940(@file_name)["1234567"] @transactions = @bank_statements.flat_map(&:transactions) @transaction = @transactions.first end it 'has the correct number of transactions' do @@ -221,7 +221,83 @@ it 'is unable to parse the contra account owner' do @transaction.contra_account_owner.should be_nil end end + end + + context 'europese incasso' do + before :each do + @file_name = File.dirname(__FILE__) + '/fixtures/ing/eu_incasso.txt' + @bank_statements = MT940Structured::Parser.parse_mt940(@file_name)["1234567"] + @transactions = @bank_statements.flat_map(&:transactions) + @transaction = @transactions.first + end + + it 'has a description' do + @transaction.description.should == 'NL10XXX100020000000 01000 00000000 000000000000-AAAA12345678 Premie xxxxxxxxxxxxxxxxxxxxxxx' + end + + it 'has a contra account' do + @transaction.contra_account.should == "3000" + end + + it 'has a contra account iban' do + @transaction.contra_account_iban.should == "NL58INGB0000003000" + end + + it 'has a contra account owner' do + @transaction.contra_account_owner.should == "JAAPJAAP FIETS PAPIER QWDFDFGGASDFGDSFGS NV" + end + end + + context 'foreign transaction' do + before :each do + @file_name = File.dirname(__FILE__) + '/fixtures/ing/eu_incasso_foreign_transaction.txt' + @bank_statements = MT940Structured::Parser.parse_mt940(@file_name)["1234567"] + @transactions = @bank_statements.flat_map(&:transactions) + @transaction = @transactions.first + end + + it 'has a description' do + @transaction.description.should == 'GB40G01SDDCITI00000011091334 9087653421 NL0 001MKXD ADWORDS:3455667788:NL0001MKXD' + end + + it 'has a contra account' do + @transaction.contra_account.should == "BB123456789876567898" + end + + it 'has a contra account iban' do + @transaction.contra_account_iban.should == "BB123456789876567898" + end + + it 'has a contra account owner' do + @transaction.contra_account_owner.should == "Google Ireland Limited" + end + end + + describe 'new line in reference after company name' do + before :each do + @file_name = File.dirname(__FILE__) + '/fixtures/ing/failing.txt' + @bank_statements = MT940Structured::Parser.parse_mt940(@file_name)["1234567"] + @transactions = @bank_statements.flat_map(&:transactions) + @transaction = @transactions.first + end + + it 'has a description' do + @transaction.description.should == 'NL72 BOB998877665544 BOB213654789387485940392049 1234567898765432 Kenmerk: 3333.1111.2222.3333 Omschrijving: 987654321 01-01-2012 3 MND 9878878787 Servicecontract' + end + + it 'has a contra account' do + @transaction.contra_account.should == "123456789" + end + + it 'has a contra account iban' do + @transaction.contra_account_iban.should == "NL80RABO0123456789" + end + + it 'has a contra account owner' do + @transaction.contra_account_owner.should == "BOB" + end + end end