diff --git a/account_bank_statement_import/account_bank_statement_import.py b/account_bank_statement_import/account_bank_statement_import.py
index 5629c01..b688199 100644
--- a/account_bank_statement_import/account_bank_statement_import.py
+++ b/account_bank_statement_import/account_bank_statement_import.py
@@ -212,21 +212,36 @@ class AccountBankStatementImport(models.TransientModel):
else:
if bank_account.journal_id.id:
journal_id = bank_account.journal_id.id
-
# If importing into an existing journal, its currency must be the same
- # as the bank statement
- if journal_id:
- journal_currency_id = self.env['account.journal'].browse(
- journal_id).currency.id
- if currency_id and currency_id != journal_currency_id:
- raise Warning(_('The currency of the bank statement is not '
- 'the same as the currency of the journal !'))
-
- # If we couldn't find/create a journal, everything is lost
- if not journal_id:
- raise Warning(_('Cannot find in which journal import this '
- 'statement. Please manually select a journal.'))
-
+ # as the bank statement. When journal has no currency, currency must
+ # be equal to company currency.
+ if journal_id and currency_id:
+ journal_obj = self.env['account.journal'].browse(journal_id)
+ if journal_obj.currency:
+ if currency_id != journal_obj.currency.id:
+ # ALso log message with id's for technical analysis:
+ _logger.warn(_(
+ 'Statement currency id is %d,'
+ ' but journal currency id = %d.') %
+ (currency_id, journal_currency_id,)
+ )
+ raise Warning(_(
+ 'The currency of the bank statement is not '
+ 'the same as the currency of the journal !'
+ ))
+ else:
+ company_currency_id = self.env.user.company_id.currency_id.id
+ if currency_id != company_currency_id:
+ # ALso log message with id's for technical analysis:
+ _logger.warn(_(
+ 'Statement currency id is %d,'
+ ' but company currency id = %d.') %
+ (currency_id, company_currency_id,)
+ )
+ raise Warning(_(
+ 'The currency of the bank statement is not '
+ 'the same as the company currency !'
+ ))
return journal_id
@api.model
diff --git a/account_bank_statement_import/tests/test_import_bank_statement.py b/account_bank_statement_import/tests/test_import_bank_statement.py
index 26eb0ee..76ca660 100644
--- a/account_bank_statement_import/tests/test_import_bank_statement.py
+++ b/account_bank_statement_import/tests/test_import_bank_statement.py
@@ -25,13 +25,13 @@
from openerp.tests.common import TransactionCase
-class TestAccountBankStatemetImport(TransactionCase):
+class TestAccountBankStatementImport(TransactionCase):
"""Tests for import bank statement file import
(account.bank.statement.import)
"""
def setUp(self):
- super(TestAccountBankStatemetImport, self).setUp()
+ super(TestAccountBankStatementImport, self).setUp()
self.statement_import_model = self.env[
'account.bank.statement.import']
self.account_journal_model = self.env['account.journal']
diff --git a/bank_statement_parse/parserlib.py b/bank_statement_parse/parserlib.py
index cc928fa..1ff1bb0 100644
--- a/bank_statement_parse/parserlib.py
+++ b/bank_statement_parse/parserlib.py
@@ -31,7 +31,7 @@ def convert_transaction(transaction):
'ref': transaction.eref,
'amount': transaction.transferred_amount,
'partner_name': transaction.remote_owner,
- 'acc_number': transaction.remote_account,
+ 'account_number': transaction.remote_account,
'unique_import_id': transaction.transaction_id,
}
return vals_line
diff --git a/bank_statement_parse_mt940/mt940.py b/bank_statement_parse_mt940/mt940.py
index 0652de8..a58d221 100644
--- a/bank_statement_parse_mt940/mt940.py
+++ b/bank_statement_parse_mt940/mt940.py
@@ -252,7 +252,7 @@ class MT940(object):
stmt = self.current_statement
stmt.end_balance = str2amount(data[0], data[10:])
stmt.date = datetime.strptime(data[1:7], '%y%m%d')
- stmt.id = '%s-%s' % (
+ stmt.statement_id = '%s-%s' % (
stmt.local_account,
stmt.date.strftime('%Y-%m-%d'),
)
diff --git a/bank_statement_parse_nl_ing_mt940/__openerp__.py b/bank_statement_parse_nl_ing_mt940/__openerp__.py
index cecef6e..c773faa 100644
--- a/bank_statement_parse_nl_ing_mt940/__openerp__.py
+++ b/bank_statement_parse_nl_ing_mt940/__openerp__.py
@@ -28,5 +28,8 @@
'bank_statement_parse_mt940'
],
'data': [],
+ 'demo': [
+ 'demo/demo_data.xml',
+ ],
'installable': True
}
diff --git a/bank_statement_parse_nl_ing_mt940/demo/demo_data.xml b/bank_statement_parse_nl_ing_mt940/demo/demo_data.xml
new file mode 100644
index 0000000..2be59cd
--- /dev/null
+++ b/bank_statement_parse_nl_ing_mt940/demo/demo_data.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+ Bank Journal - (test mt940 ING)
+ TBNKMT940ING
+ bank
+
+
+
+
+
+
+
+ Your Company
+ NL77ABNA0574908765
+
+
+
+ bank
+
+
+
+
+
diff --git a/bank_statement_parse_nl_ing_mt940/tests/test_import_bank_statement.py b/bank_statement_parse_nl_ing_mt940/tests/test_import_bank_statement.py
index 30bb1a6..dbf9952 100644
--- a/bank_statement_parse_nl_ing_mt940/tests/test_import_bank_statement.py
+++ b/bank_statement_parse_nl_ing_mt940/tests/test_import_bank_statement.py
@@ -48,8 +48,9 @@ class TestStatementFile(TransactionCase):
)
)
import_model.import_file(cr, uid, [bank_statement_id])
+ # statement name is account number + '-' + date of last 62F line:
ids = statement_model.search(
- cr, uid, [('name', '=', '2014-02-19/00000')])
+ cr, uid, [('name', '=', 'NL77ABNA0574908765-2014-02-20')])
self.assertTrue(ids, 'Statement not found after parse.')
statement_id = ids[0]
statement_obj = statement_model.browse(
diff --git a/bank_statement_parse_nl_rabo_mt940/test_files/test-rabo.swi b/bank_statement_parse_nl_rabo_mt940/test_files/test-rabo.swi
new file mode 100644
index 0000000..80c42d8
--- /dev/null
+++ b/bank_statement_parse_nl_rabo_mt940/test_files/test-rabo.swi
@@ -0,0 +1,29 @@
+:940:
+:20:940S140102
+:25:NL34RABO0142623393 EUR
+:28C:0
+:60F:C131231EUR000000004433,52
+:61:140102C000000000400,00N541NONREF
+NL66RABO0160878799
+:86:/ORDP//NAME/R. SMITH/ADDR/Green market 74 3311BE Sheepcity Nederl
+and NL/REMI/Test money paid by other partner:
+/ISDT/2014-01-02
+:62F:C140102EUR000000004833,52
+:20:940S140103
+:25:NL34RABO0142623393 EUR
+:28C:0
+:60F:C140102EUR000000004833,52
+:62F:C140103EUR000000004833,52
+:20:940S140106
+:25:NL34RABO0142623393 EUR
+:28C:0
+:60F:C140103EUR000000004833,52
+:61:140101D000000000034,61N093NONREF
+:86:/BENM//NAME/Kosten/REMI/Periode 01-10-2013 t/m 31-12-2013/ISDT/20
+14-01-01
+:62F:C140106EUR000000004798,91
+:20:940S140107
+:25:NL34RABO0142623393 EUR
+:28C:0
+:60F:C140106EUR000000004798,91
+:62F:C140107EUR000000004798,91
diff --git a/bank_statement_parse_nl_rabo_mt940/tests/__init__.py b/bank_statement_parse_nl_rabo_mt940/tests/__init__.py
new file mode 100644
index 0000000..37fdfc8
--- /dev/null
+++ b/bank_statement_parse_nl_rabo_mt940/tests/__init__.py
@@ -0,0 +1,25 @@
+# -*- encoding: utf-8 -*-
+"""Test import of bank statement for MT940 ING."""
+##############################################################################
+#
+# Copyright (C) 2015 Therp BV .
+#
+# All other contributions are (C) by their respective contributors
+#
+# All Rights Reserved
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from . import test_import_bank_statement
diff --git a/bank_statement_parse_nl_rabo_mt940/tests/test_import_bank_statement.py b/bank_statement_parse_nl_rabo_mt940/tests/test_import_bank_statement.py
new file mode 100644
index 0000000..b0332bb
--- /dev/null
+++ b/bank_statement_parse_nl_rabo_mt940/tests/test_import_bank_statement.py
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+"""Run test to import MT940 IBAN RABO import."""
+##############################################################################
+#
+# Copyright (C) 2015 Therp BV .
+#
+# All other contributions are (C) by their respective contributors
+#
+# All Rights Reserved
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from openerp.tests.common import TransactionCase
+from openerp.modules.module import get_module_resource
+
+
+class TestStatementFile(TransactionCase):
+ """Run test to import MT940 RABO import."""
+
+ def test_statement_import(self):
+ """Test correct creation of single statement.
+
+ For this test there is NOT an existing bank-account. Therefore a
+ bank account should automatically be created in the main company.
+ """
+ partner_bank_model = self.env['res.partner.bank']
+ import_model = self.registry('account.bank.statement.import')
+ statement_model = self.registry('account.bank.statement')
+ cr, uid = self.cr, self.uid
+ statement_path = get_module_resource(
+ 'bank_statement_parse_nl_rabo_mt940',
+ 'test_files',
+ 'test-rabo.swi'
+ )
+ statement_file = open(
+ statement_path, 'rb').read().encode('base64')
+ bank_statement_id = import_model.create(
+ cr, uid,
+ dict(
+ data_file=statement_file,
+ )
+ )
+ import_model.import_file(cr, uid, [bank_statement_id])
+ # Check wether bank account has been created:
+ vals = partner_bank_model.search(
+ [('acc_number', '=', 'NL34RABO0142623393')])
+ self.assertEquals(
+ 1, len(vals),
+ 'Bank account not created from statement'
+ )
+ # statement name is account number + '-' + date of last 62F line:
+ ids = statement_model.search(
+ cr, uid, [('name', '=', 'NL34RABO0142623393-2014-01-07')])
+ self.assertTrue(ids, 'Statement not found after parse.')
+ statement_id = ids[0]
+ statement_obj = statement_model.browse(
+ cr, uid, statement_id)
+ self.assertTrue(
+ abs(statement_obj.balance_start - 4433.52) < 0.00001,
+ 'Start balance %f not equal to 4433.52' %
+ statement_obj.balance_start
+ )
+ self.assertTrue(
+ abs(statement_obj.balance_end_real - 4798.91) < 0.00001,
+ 'Real end balance %f not equal to 4798.91' %
+ statement_obj.balance_end_real
+ )
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: