From d8ed130fa56591f4a735ba2984e53793d1fe6dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 23 Jul 2015 15:32:38 +0200 Subject: [PATCH 01/28] [IMP] rename bank_statement_parse_ to account_bank_statement_import_ Move parserlib to account_bank_statement_import and remove bank_statement_parse module --- account_bank_statement_import_camt/README.rst | 49 ++++ .../__init__.py | 1 + .../__openerp__.py | 34 +++ .../account_bank_statement_import.py | 44 ++++ account_bank_statement_import_camt/camt.py | 238 +++++++++++++++++ .../demo/demo_data.xml | 26 ++ .../test_files/test-camt053.xml | 241 ++++++++++++++++++ .../tests/__init__.py | 23 ++ .../tests/test_import_bank_statement.py | 45 ++++ 9 files changed, 701 insertions(+) create mode 100644 account_bank_statement_import_camt/README.rst create mode 100644 account_bank_statement_import_camt/__init__.py create mode 100644 account_bank_statement_import_camt/__openerp__.py create mode 100644 account_bank_statement_import_camt/account_bank_statement_import.py create mode 100644 account_bank_statement_import_camt/camt.py create mode 100644 account_bank_statement_import_camt/demo/demo_data.xml create mode 100644 account_bank_statement_import_camt/test_files/test-camt053.xml create mode 100644 account_bank_statement_import_camt/tests/__init__.py create mode 100644 account_bank_statement_import_camt/tests/test_import_bank_statement.py diff --git a/account_bank_statement_import_camt/README.rst b/account_bank_statement_import_camt/README.rst new file mode 100644 index 00000000..f027351a --- /dev/null +++ b/account_bank_statement_import_camt/README.rst @@ -0,0 +1,49 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Bank Statement Parse Camt +========================= + +Module to import SEPA CAMT.053 Format bank statement files. + +Based on the Banking addons framework. + +Known issues / Roadmap +====================== + +* None + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Stefan Rijnhart +* Ronald Portier + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. +This module should make it easy to migrate bank statement import +modules written for earlies versions of Odoo/OpenERP. diff --git a/account_bank_statement_import_camt/__init__.py b/account_bank_statement_import_camt/__init__.py new file mode 100644 index 00000000..7dafcd16 --- /dev/null +++ b/account_bank_statement_import_camt/__init__.py @@ -0,0 +1 @@ +from . import account_bank_statement_import diff --git a/account_bank_statement_import_camt/__openerp__.py b/account_bank_statement_import_camt/__openerp__.py new file mode 100644 index 00000000..dbccdc20 --- /dev/null +++ b/account_bank_statement_import_camt/__openerp__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2013-2015 Therp BV +# +# 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 . +# +############################################################################## +{ + 'name': 'CAMT Format Bank Statements Import', + 'version': '0.3', + 'license': 'AGPL-3', + 'author': 'Odoo Community Association (OCA), Therp BV', + 'website': 'https://github.com/OCA/bank-statement-import', + 'category': 'Banking addons', + 'depends': [ + 'account_bank_statement_import', + ], + 'demo': [ + 'demo/demo_data.xml', + ], + 'installable': True, +} diff --git a/account_bank_statement_import_camt/account_bank_statement_import.py b/account_bank_statement_import_camt/account_bank_statement_import.py new file mode 100644 index 00000000..8814670f --- /dev/null +++ b/account_bank_statement_import_camt/account_bank_statement_import.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +"""Add process_camt method to account.bank.statement.import.""" +############################################################################## +# +# Copyright (C) 2013-2015 Therp BV +# +# 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 . +# +############################################################################## +import logging +from openerp import models +from .camt import CamtParser as Parser + + +_logger = logging.getLogger(__name__) + + +class AccountBankStatementImport(models.TransientModel): + """Add process_camt method to account.bank.statement.import.""" + _inherit = 'account.bank.statement.import' + + def _parse_file(self, cr, uid, data_file, context=None): + """Parse a CAMT053 XML file.""" + parser = Parser() + try: + _logger.debug("Try parsing with camt.") + return parser.parse(data_file) + except ValueError: + # Not a camt file, returning super will call next candidate: + _logger.debug("Statement file was not a camt file.", + exc_info=True) + return super(AccountBankStatementImport, self)._parse_file( + cr, uid, data_file, context=context) diff --git a/account_bank_statement_import_camt/camt.py b/account_bank_statement_import_camt/camt.py new file mode 100644 index 00000000..5e6d7190 --- /dev/null +++ b/account_bank_statement_import_camt/camt.py @@ -0,0 +1,238 @@ +# -*- coding: utf-8 -*- +"""Class to parse camt files.""" +############################################################################## +# +# Copyright (C) 2013-2015 Therp BV +# +# 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 . +# +############################################################################## +import re +from datetime import datetime +from lxml import etree +from openerp.addons.account_bank_statement_import.parserlib import BankStatement + + +class CamtParser(object): + """Parser for camt bank statement import files.""" + + def parse_amount(self, ns, node): + """Parse element that contains Amount and CreditDebitIndicator.""" + if node is None: + return 0.0 + sign = 1 + amount = 0.0 + sign_node = node.xpath('ns:CdtDbtInd', namespaces={'ns': ns}) + if sign_node and sign_node[0].text == 'DBIT': + sign = -1 + amount_node = node.xpath('ns:Amt', namespaces={'ns': ns}) + if amount_node: + amount = sign * float(amount_node[0].text) + return amount + + def add_value_from_node( + self, ns, node, xpath_str, obj, attr_name, join_str=None): + """Add value to object from first or all nodes found with xpath. + + If xpath_str is a list (or iterable), it will be seen as a series + of search path's in order of preference. The first item that results + in a found node will be used to set a value.""" + if not isinstance(xpath_str, (list, tuple)): + xpath_str = [xpath_str] + for search_str in xpath_str: + found_node = node.xpath(search_str, namespaces={'ns': ns}) + if found_node: + if join_str is None: + attr_value = found_node[0].text + else: + attr_value = join_str.join([x.text for x in found_node]) + setattr(obj, attr_name, attr_value) + break + + def parse_transaction_details(self, ns, node, transaction): + """Parse transaction details (message, party, account...).""" + # message + self.add_value_from_node( + ns, node, [ + './ns:RmtInf/ns:Ustrd', + './ns:AddtlTxInf', + './ns:AddtlNtryInf', + ], transaction, 'message') + # eref + self.add_value_from_node( + ns, node, [ + './ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref', + './ns:Refs/ns:EndToEndId', + ], + transaction, 'eref' + ) + # remote party values + party_type = 'Dbtr' + party_type_node = node.xpath( + '../../ns:CdtDbtInd', namespaces={'ns': ns}) + if party_type_node and party_type_node[0].text != 'CRDT': + party_type = 'Cdtr' + party_node = node.xpath( + './ns:RltdPties/ns:%s' % party_type, namespaces={'ns': ns}) + if party_node: + self.add_value_from_node( + ns, party_node[0], './ns:Nm', transaction, 'remote_owner') + self.add_value_from_node( + ns, party_node[0], './ns:PstlAdr/ns:Ctry', transaction, + 'remote_owner_country' + ) + address_node = party_node[0].xpath( + './ns:PstlAdr/ns:AdrLine', namespaces={'ns': ns}) + if address_node: + transaction.remote_owner_address = [address_node[0].text] + # Get remote_account from iban or from domestic account: + account_node = node.xpath( + './ns:RltdPties/ns:%sAcct/ns:Id' % party_type, + namespaces={'ns': ns} + ) + if account_node: + iban_node = account_node[0].xpath( + './ns:IBAN', namespaces={'ns': ns}) + if iban_node: + transaction.remote_account = iban_node[0].text + bic_node = node.xpath( + './ns:RltdAgts/ns:%sAgt/ns:FinInstnId/ns:BIC' % party_type, + namespaces={'ns': ns} + ) + if bic_node: + transaction.remote_bank_bic = bic_node[0].text + else: + self.add_value_from_node( + ns, account_node[0], './ns:Othr/ns:Id', transaction, + 'remote_account' + ) + + def parse_transaction(self, ns, node, transaction): + """Parse transaction (entry) node.""" + self.add_value_from_node( + ns, node, './ns:BkTxCd/ns:Prtry/ns:Cd', transaction, + 'transfer_type' + ) + self.add_value_from_node( + ns, node, './ns:BookgDt/ns:Dt', transaction, 'execution_date') + self.add_value_from_node( + ns, node, './ns:ValDt/ns:Dt', transaction, 'value_date') + transaction.transferred_amount = self.parse_amount(ns, node) + details_node = node.xpath( + './ns:NtryDtls/ns:TxDtls', namespaces={'ns': ns}) + if details_node: + self.parse_transaction_details(ns, details_node[0], transaction) + transaction.data = etree.tostring(node) + return transaction + + def get_balance_amounts(self, ns, node): + """Return opening and closing balance. + + Depending on kind of balance and statement, the balance might be in a + different kind of node: + OPBD = OpeningBalance + PRCD = PreviousClosingBalance + ITBD = InterimBalance (first ITBD is start-, second is end-balance) + CLBD = ClosingBalance + """ + start_balance_node = None + end_balance_node = None + for node_name in ['OPBD', 'PRCD', 'CLBD', 'ITBD']: + code_expr = ( + './ns:Bal/ns:Tp/ns:CdOrPrtry/ns:Cd[text()="%s"]/../../..' % + node_name + ) + balance_node = node.xpath(code_expr, namespaces={'ns': ns}) + if balance_node: + if node_name in ['OPBD', 'PRCD']: + start_balance_node = balance_node[0] + elif node_name == 'CLBD': + end_balance_node = balance_node[0] + else: + if not start_balance_node: + start_balance_node = balance_node[0] + if not end_balance_node: + end_balance_node = balance_node[-1] + return ( + self.parse_amount(ns, start_balance_node), + self.parse_amount(ns, end_balance_node) + ) + + def parse_statement(self, ns, node): + """Parse a single Stmt node.""" + statement = BankStatement() + self.add_value_from_node( + ns, node, [ + './ns:Acct/ns:Id/ns:IBAN', + './ns:Acct/ns:Id/ns:Othr/ns:Id', + ], statement, 'local_account' + ) + self.add_value_from_node( + ns, node, './ns:Id', statement, 'statement_id') + self.add_value_from_node( + ns, node, './ns:Acct/ns:Ccy', statement, 'local_currency') + (statement.start_balance, statement.end_balance) = ( + self.get_balance_amounts(ns, node)) + transaction_nodes = node.xpath('./ns:Ntry', namespaces={'ns': ns}) + for entry_node in transaction_nodes: + transaction = statement.create_transaction() + self.parse_transaction(ns, entry_node, transaction) + if statement['transactions']: + statement.date = datetime.strptime( + statement['transactions'][0].execution_date, "%Y-%m-%d") + return statement + + def check_version(self, ns, root): + """Validate validity of camt file.""" + # Check wether it is camt at all: + re_camt = re.compile( + r'(^urn:iso:std:iso:20022:tech:xsd:camt.' + r'|^ISO:camt.)' + ) + if not re_camt.search(ns): + raise ValueError('no camt: ' + ns) + # Check wether version 052 or 053: + re_camt_version = re.compile( + r'(^urn:iso:std:iso:20022:tech:xsd:camt.053.' + r'|^urn:iso:std:iso:20022:tech:xsd:camt.052.' + r'|^ISO:camt.053.' + r'|^ISO:camt.052.)' + ) + if not re_camt_version.search(ns): + raise ValueError('no camt 052 or 053: ' + ns) + # Check GrpHdr element: + root_0_0 = root[0][0].tag[len(ns) + 2:] # strip namespace + if root_0_0 != 'GrpHdr': + raise ValueError('expected GrpHdr, got: ' + root_0_0) + + def parse(self, data): + """Parse a camt.052 or camt.053 file.""" + try: + root = etree.fromstring( + data, parser=etree.XMLParser(recover=True)) + except etree.XMLSyntaxError: + # ABNAmro is known to mix up encodings + root = etree.fromstring( + data.decode('iso-8859-15').encode('utf-8')) + if root is None: + raise ValueError( + 'Not a valid xml file, or not an xml file at all.') + ns = root.tag[1:root.tag.index("}")] + self.check_version(ns, root) + statements = [] + for node in root[0][1:]: + statement = self.parse_statement(ns, node) + if len(statement['transactions']): + statements.append(statement) + return statements diff --git a/account_bank_statement_import_camt/demo/demo_data.xml b/account_bank_statement_import_camt/demo/demo_data.xml new file mode 100644 index 00000000..7fc44d77 --- /dev/null +++ b/account_bank_statement_import_camt/demo/demo_data.xml @@ -0,0 +1,26 @@ + + + + + + Bank Journal - (test camt) + TBNKCAMT + bank + + + + + + + + Your Company + NL77ABNA0574908765 + + + + bank + + + + + diff --git a/account_bank_statement_import_camt/test_files/test-camt053.xml b/account_bank_statement_import_camt/test_files/test-camt053.xml new file mode 100644 index 00000000..1d74d81b --- /dev/null +++ b/account_bank_statement_import_camt/test_files/test-camt053.xml @@ -0,0 +1,241 @@ + + + + TESTBANK/NL/1420561226673 + 2013-01-06T16:20:26.673Z + + + 1234Test/1 + 2 + 2013-01-06T16:20:26.673Z + + 2013-01-05T00:00:00.000Z + 2013-01-05T23:59:59.999Z + + + + NL77ABNA0574908765 + + Example company + + + ABNANL2A + + + + + + + OPBD + + + 15568.27 + CRDT +
+
2013-01-05
+ +
+ + + + CLBD + + + 15121.12 + CRDT +
+
2013-01-05
+ +
+ + 754.25 + DBIT + BOOK + +
2013-01-05
+
+ +
2013-01-05
+
+ + + PMNT + + RDDT + ESDD + + + + EI + + + + + + INNDNL2U20141231000142300002844 + 435005714488-ABNO33052620 + 1880000341866 + + + + 754.25 + + + + + INSURANCE COMPANY TESTX + + TEST STREET 20 + 1234 AB TESTCITY + NL + + + + + NL46ABNA0499998748 + + + + + + + ABNANL2A + + + + + Insurance policy 857239PERIOD 01.01.2013 - 31.12.2013 + + MKB Insurance 859239PERIOD 01.01.2013 - 31.12.2013 + + +
+ + 594.05 + DBIT + true + BOOK + +
2013-01-05
+
+ +
2013-01-05
+
+ + + PMNT + + IDDT + UPDD + + + + EIST + + + + + + TESTBANK/NL/20141229/01206408 + TESTBANK/NL/20141229/01206408 + NL22ZZZ524885430000-C0125.1 + + + + 564.05 + + + + + Test Customer + + NL + + + + + NL46ABNA0499998748 + + + + + + + ABNANL2A + + + + + Direct Debit S14 0410 + + + + AC06 + + + Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408 + + +
+ + 1405.31 + CRDT + BOOK + +
2013-01-05
+
+ +
2013-01-05
+
+ + + PMNT + + RCDT + ESCT + + + + ET + + + + + + INNDNL2U20130105000217200000708 + 115 + + + + 1405.31 + + + + + 3rd party Media + + SOMESTREET 570-A + 1276 ML HOUSCITY + NL + + + + + NL69ABNA0522123643 + + + + + + + ABNANL2A + + + + #RD PARTY MEDIA CUSNO 90782 4210773 + + +
+
+
+
diff --git a/account_bank_statement_import_camt/tests/__init__.py b/account_bank_statement_import_camt/tests/__init__.py new file mode 100644 index 00000000..cd97bcae --- /dev/null +++ b/account_bank_statement_import_camt/tests/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +"""Test import of bank statement for camt.053.""" +############################################################################## +# +# Copyright (C) 2015 Therp BV . +# +# All other contributions are (C) by their respective contributors +# +# 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/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py new file mode 100644 index 00000000..8a1694f0 --- /dev/null +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +"""Run test to import camt.053 import.""" +############################################################################## +# +# Copyright (C) 2015 Therp BV . +# +# 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.addons.account_bank_statement_import.tests import ( + TestStatementFile) + + +class TestImport(TestStatementFile): + """Run test to import camt import.""" + + def test_statement_import(self): + """Test correct creation of single statement.""" + transactions = [ + { + 'remote_account': 'NL46ABNA0499998748', + 'transferred_amount': -754.25, + 'value_date': '2013-01-05', + 'ref': '435005714488-ABNO33052620', + }, + ] + # statement name is account number + '-' + date of last 62F line: + self._test_statement_import( + 'account_bank_statement_import_camt', 'test-camt053.xml', + '1234Test/1', + local_account='NL77ABNA0574908765', + start_balance=15568.27, end_balance=15121.12, + transactions=transactions + ) From d1b36ea20cc7c4bbbede2cf01c73cf4987e42373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 23 Jul 2015 16:30:44 +0200 Subject: [PATCH 02/28] [FIX] pep8 --- account_bank_statement_import_camt/camt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/account_bank_statement_import_camt/camt.py b/account_bank_statement_import_camt/camt.py index 5e6d7190..81fd1de2 100644 --- a/account_bank_statement_import_camt/camt.py +++ b/account_bank_statement_import_camt/camt.py @@ -21,7 +21,8 @@ import re from datetime import datetime from lxml import etree -from openerp.addons.account_bank_statement_import.parserlib import BankStatement +from openerp.addons.account_bank_statement_import.parserlib import ( + BankStatement) class CamtParser(object): From b3b82322b0496a148f1d71f0fab95e4e9136d4a4 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Tue, 1 Sep 2015 12:20:23 -0400 Subject: [PATCH 03/28] OCA Transbot updated translations from Transifex --- account_bank_statement_import_camt/i18n/es.po | 23 ++++++++++++++++++ account_bank_statement_import_camt/i18n/fr.po | 23 ++++++++++++++++++ .../i18n/lt_LT.po | 23 ++++++++++++++++++ account_bank_statement_import_camt/i18n/nl.po | 24 +++++++++++++++++++ account_bank_statement_import_camt/i18n/sl.po | 23 ++++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 account_bank_statement_import_camt/i18n/es.po create mode 100644 account_bank_statement_import_camt/i18n/fr.po create mode 100644 account_bank_statement_import_camt/i18n/lt_LT.po create mode 100644 account_bank_statement_import_camt/i18n/nl.po create mode 100644 account_bank_statement_import_camt/i18n/sl.po diff --git a/account_bank_statement_import_camt/i18n/es.po b/account_bank_statement_import_camt/i18n/es.po new file mode 100644 index 00000000..ebef1f34 --- /dev/null +++ b/account_bank_statement_import_camt/i18n/es.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-07-24 07:41+0000\n" +"Last-Translator: <>\n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importar extracto bancario" diff --git a/account_bank_statement_import_camt/i18n/fr.po b/account_bank_statement_import_camt/i18n/fr.po new file mode 100644 index 00000000..72f164b6 --- /dev/null +++ b/account_bank_statement_import_camt/i18n/fr.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-07-24 07:41+0000\n" +"Last-Translator: <>\n" +"Language-Team: French (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importer Relevé Bancaire" diff --git a/account_bank_statement_import_camt/i18n/lt_LT.po b/account_bank_statement_import_camt/i18n/lt_LT.po new file mode 100644 index 00000000..7207693b --- /dev/null +++ b/account_bank_statement_import_camt/i18n/lt_LT.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-07-24 07:41+0000\n" +"Last-Translator: <>\n" +"Language-Team: Lithuanian (Lithuania) (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/lt_LT/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: lt_LT\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importuoti banko išrašą" diff --git a/account_bank_statement_import_camt/i18n/nl.po b/account_bank_statement_import_camt/i18n/nl.po new file mode 100644 index 00000000..408e305e --- /dev/null +++ b/account_bank_statement_import_camt/i18n/nl.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +# Erwin van der Ploeg , 2015 +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-07-31 06:44+0000\n" +"Last-Translator: Erwin van der Ploeg \n" +"Language-Team: Dutch (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/nl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importeer bankafschrift" diff --git a/account_bank_statement_import_camt/i18n/sl.po b/account_bank_statement_import_camt/i18n/sl.po new file mode 100644 index 00000000..4aa623da --- /dev/null +++ b/account_bank_statement_import_camt/i18n/sl.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-07-25 12:19+0000\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Uvoz bančnega izpiska" From c885e14f6c1099547b3a1354d55b5c2494f62edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 9 Oct 2015 09:59:36 +0200 Subject: [PATCH 04/28] [UPD] prefix versions with 8.0 --- account_bank_statement_import_camt/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_camt/__openerp__.py b/account_bank_statement_import_camt/__openerp__.py index dbccdc20..47113f36 100644 --- a/account_bank_statement_import_camt/__openerp__.py +++ b/account_bank_statement_import_camt/__openerp__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name': 'CAMT Format Bank Statements Import', - 'version': '0.3', + 'version': '8.0.0.3.0', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', From 3c4d3b0979489680fda89bec9f4ab045e3f76f1a Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 10 Oct 2015 21:23:01 -0400 Subject: [PATCH 05/28] OCA Transbot updated translations from Transifex --- .../i18n/pt_BR.po | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 account_bank_statement_import_camt/i18n/pt_BR.po diff --git a/account_bank_statement_import_camt/i18n/pt_BR.po b/account_bank_statement_import_camt/i18n/pt_BR.po new file mode 100644 index 00000000..a56eec56 --- /dev/null +++ b/account_bank_statement_import_camt/i18n/pt_BR.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-09 09:23+0000\n" +"PO-Revision-Date: 2015-10-09 00:26+0000\n" +"Last-Translator: danimaribeiro \n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importar Extrato Bancário" From eade72471b887e29866e5869b05d8ee998f9ee5b Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 14 Oct 2015 02:19:40 +0200 Subject: [PATCH 06/28] [MIG] Make modules uninstallable --- account_bank_statement_import_camt/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_camt/__openerp__.py b/account_bank_statement_import_camt/__openerp__.py index 47113f36..a59c096d 100644 --- a/account_bank_statement_import_camt/__openerp__.py +++ b/account_bank_statement_import_camt/__openerp__.py @@ -30,5 +30,5 @@ 'demo': [ 'demo/demo_data.xml', ], - 'installable': True, + 'installable': False, } From 9f1d755c4df012b30b19da6d181ab44b4bc32fe0 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 14:47:55 +0200 Subject: [PATCH 07/28] [MIG] Rename manifest files --- .../{__openerp__.py => __manifest__.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename account_bank_statement_import_camt/{__openerp__.py => __manifest__.py} (100%) diff --git a/account_bank_statement_import_camt/__openerp__.py b/account_bank_statement_import_camt/__manifest__.py similarity index 100% rename from account_bank_statement_import_camt/__openerp__.py rename to account_bank_statement_import_camt/__manifest__.py From 6e66eadf8e675045d224e664ed0cdc797c2ce476 Mon Sep 17 00:00:00 2001 From: Rudolf Schnapka Date: Sun, 4 Oct 2015 11:57:58 +0200 Subject: [PATCH 08/28] german translations for bank-statement-import --- account_bank_statement_import_camt/i18n/de.po | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 account_bank_statement_import_camt/i18n/de.po diff --git a/account_bank_statement_import_camt/i18n/de.po b/account_bank_statement_import_camt/i18n/de.po new file mode 100644 index 00000000..b503264c --- /dev/null +++ b/account_bank_statement_import_camt/i18n/de.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-07-24 21:51+0000\n" +"PO-Revision-Date: 2015-10-04 11:43+0200\n" +"Last-Translator: Rudolf Schnapka \n" +"Language-Team: French (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Poedit 1.8.3\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Kontoauszug importieren" From 6a7d0a665cd1b1f87b2b55571287e1eabb9357b0 Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Fri, 9 Oct 2015 15:08:42 +0200 Subject: [PATCH 09/28] Make sure message is filled for camt. Message was not taken from AddtlNtryInf element, if not part of details. Not sure wether it actually can be part of details (NtryDtls element), but this change least intrusive. --- account_bank_statement_import_camt/camt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/account_bank_statement_import_camt/camt.py b/account_bank_statement_import_camt/camt.py index 81fd1de2..96e7a51e 100644 --- a/account_bank_statement_import_camt/camt.py +++ b/account_bank_statement_import_camt/camt.py @@ -134,6 +134,9 @@ class CamtParser(object): './ns:NtryDtls/ns:TxDtls', namespaces={'ns': ns}) if details_node: self.parse_transaction_details(ns, details_node[0], transaction) + if not transaction.message: + self.add_value_from_node( + ns, node, './ns:AddtlNtryInf', transaction, 'message') transaction.data = etree.tostring(node) return transaction From 0762dbb20636708e4532bb2fdad11a3733ea0b2d Mon Sep 17 00:00:00 2001 From: "Ronald Portier (Therp BV)" Date: Sat, 13 Jun 2015 01:20:18 +0200 Subject: [PATCH 10/28] Support zip files. --- .../__manifest__.py | 2 +- account_bank_statement_import_camt/camt.py | 9 +++++- .../test_files/test-camt053.xml | 30 +++++++++--------- .../test_files/test-camt053.zip | Bin 0 -> 3111 bytes .../tests/test_import_bank_statement.py | 11 +++++-- 5 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 account_bank_statement_import_camt/test_files/test-camt053.zip diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt/__manifest__.py index a59c096d..86ce0c57 100644 --- a/account_bank_statement_import_camt/__manifest__.py +++ b/account_bank_statement_import_camt/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { 'name': 'CAMT Format Bank Statements Import', - 'version': '8.0.0.3.0', + 'version': '8.0.0.4.0', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', diff --git a/account_bank_statement_import_camt/camt.py b/account_bank_statement_import_camt/camt.py index 96e7a51e..aed01dbf 100644 --- a/account_bank_statement_import_camt/camt.py +++ b/account_bank_statement_import_camt/camt.py @@ -69,7 +69,7 @@ class CamtParser(object): './ns:RmtInf/ns:Ustrd', './ns:AddtlTxInf', './ns:AddtlNtryInf', - ], transaction, 'message') + ], transaction, 'message', join_str='\n') # eref self.add_value_from_node( ns, node, [ @@ -137,6 +137,13 @@ class CamtParser(object): if not transaction.message: self.add_value_from_node( ns, node, './ns:AddtlNtryInf', transaction, 'message') + if not transaction.eref: + self.add_value_from_node( + ns, node, [ + './ns:NtryDtls/ns:Btch/ns:PmtInfId', + ], + transaction, 'eref' + ) transaction.data = etree.tostring(node) return transaction diff --git a/account_bank_statement_import_camt/test_files/test-camt053.xml b/account_bank_statement_import_camt/test_files/test-camt053.xml index 1d74d81b..4a2a0473 100644 --- a/account_bank_statement_import_camt/test_files/test-camt053.xml +++ b/account_bank_statement_import_camt/test_files/test-camt053.xml @@ -2,15 +2,15 @@ TESTBANK/NL/1420561226673 - 2013-01-06T16:20:26.673Z + 2014-01-06T16:20:26.673Z 1234Test/1 2 - 2013-01-06T16:20:26.673Z + 2014-01-06T16:20:26.673Z - 2013-01-05T00:00:00.000Z - 2013-01-05T23:59:59.999Z + 2014-01-05T00:00:00.000Z + 2014-01-05T23:59:59.999Z @@ -32,7 +32,7 @@ 15568.27 CRDT
-
2013-01-05
+
2014-01-05
@@ -44,7 +44,7 @@ 15121.12 CRDT
-
2013-01-05
+
2014-01-05
@@ -52,10 +52,10 @@ DBIT BOOK -
2013-01-05
+
2014-01-05
-
2013-01-05
+
2014-01-05
@@ -104,9 +104,9 @@ - Insurance policy 857239PERIOD 01.01.2013 - 31.12.2013 + Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014 - MKB Insurance 859239PERIOD 01.01.2013 - 31.12.2013 + MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014
@@ -116,10 +116,10 @@ true BOOK -
2013-01-05
+
2014-01-05
-
2013-01-05
+
2014-01-05
@@ -182,10 +182,10 @@ CRDT BOOK -
2013-01-05
+
2014-01-05
-
2013-01-05
+
2014-01-05
@@ -202,7 +202,7 @@ - INNDNL2U20130105000217200000708 + INNDNL2U20140105000217200000708 115 diff --git a/account_bank_statement_import_camt/test_files/test-camt053.zip b/account_bank_statement_import_camt/test_files/test-camt053.zip new file mode 100644 index 0000000000000000000000000000000000000000..ccf5b3c2ba72ad03cc137edcf2ee55f67b7a2952 GIT binary patch literal 3111 zcmeH}=T{S08pZ=5FccF7R764P14xk;5EP_{0RmY=5O4w{AVr!$C=oHlAWJhyReBE! zAqJ!U#$s;Q+O;qQmC7X$#CFp;S53XKp3 z@bIyK0Kng`kJ*<4=k&#UW|xqT(@Tov5YUyorl#QtnL>GL823Dkl9(M6fc0cI%(|Ni z6Q^GLcu71wsM2}%?CvjH!8b!s<&9$V%#|&29fp7$*Z6H3|gs9r@Iab`}w zn70^AGxt!43sw21&ugEeu5!s zB=aSvS|O$Bs(_1W`3N!7kW{?C+9uvd?a-AuvRv(>X!goeIdlV;b{mCeyP1vK$0=9p zhvGziT|Owbw0q_obsli0rv4Sr^-c(wMC`04QcZhDwWKHp@XFHQlHEbhsWMKSBZZOw zA}>C4#%A3WrP-sj`HDO4lA-;!yrBVX&3%#eOMKMU@+IV(nv7lhYS%{;$3{6@D@-?8 zj%$0W-f~sSJ^sQi^P9;MO$$IZFznJn;)6b5Ft;O?XIp3Wvr?Mxgx4Co_F1d*^z6>W z16A~WLf`!H5cIp~GA4ZCR{`G`WEw$zws*gec}$;&fZM zo5o5(B`9uG=!A2Ina*WDMms&g&>^6!qHt5;GqTVR1>*Ec+Z)I*wlOs-1v{7k(SD7cx&3TX>4UUU|z4aL*H}d*MEMlY`)`QpML{Lh>UZ>Y$ z#RRHb?tB{p^?Uws=MQd|l>2$Th%nhp47tF`Rx7B!RoxbGo{x9Ijt)~YQ+V444% zPzs&KG$xTJ)T2(Qz^8|QRB}mXgGS2uVz8>+^ZoN75^~j6MqhVW51<$wUzWDyF|J1 zirME@jT#|^OHAAz3aV0H+~Jxv^`tk-VY6f-Rl*g=@Y-F-Ba{e9gU80nOv-XmG14&C zV(E)5%on5Y=I7h_Gab0duA42{ST}8V<9on@o5adK;Lj4$TmL;iTZRlaNcE zF1&6LTv;hka~iWF8};~H>r~tMthOl-2An0f&eCUPY+h! z>c3ZOHlMoCRY`(}DnQqY19eBIViuA`HhKm_r5I4{dR+8rdB$SfS*>Oa_D7-8&b&W) z{U@*guX)YGD-Hakf-SLEya527J(Uu_PrqBYLI0@RzhO7R`d`NX9R>ex{Ae#A{?quM b!LVoiJE4HE2JwIY3-8{k*?V1uzi)p7q~E=A literal 0 HcmV?d00001 diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py index 8a1694f0..d14aca96 100644 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -31,11 +31,10 @@ class TestImport(TestStatementFile): { 'remote_account': 'NL46ABNA0499998748', 'transferred_amount': -754.25, - 'value_date': '2013-01-05', + 'value_date': '2014-01-05', 'ref': '435005714488-ABNO33052620', }, ] - # statement name is account number + '-' + date of last 62F line: self._test_statement_import( 'account_bank_statement_import_camt', 'test-camt053.xml', '1234Test/1', @@ -43,3 +42,11 @@ class TestImport(TestStatementFile): start_balance=15568.27, end_balance=15121.12, transactions=transactions ) + + def test_zip_import(self): + """Test import of multiple statements from zip file.""" + self._test_statement_import( + 'account_bank_statement_import_camt', 'test-camt053.zip', + '1234Test/2', # Only name of first statement + local_account='NL77ABNA0574908765', + ) From 3a878db918182de98396e8aad0e777ff14563c74 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 17 Sep 2016 01:47:05 -0400 Subject: [PATCH 11/28] OCA Transbot updated translations from Transifex --- .../i18n/pt_PT.po | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 account_bank_statement_import_camt/i18n/pt_PT.po diff --git a/account_bank_statement_import_camt/i18n/pt_PT.po b/account_bank_statement_import_camt/i18n/pt_PT.po new file mode 100644 index 00000000..7b0f8e8d --- /dev/null +++ b/account_bank_statement_import_camt/i18n/pt_PT.po @@ -0,0 +1,23 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: bank-statement-import (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-08-18 10:27+0000\n" +"PO-Revision-Date: 2015-07-24 07:41+0000\n" +"Last-Translator: <>\n" +"Language-Team: Portuguese (Portugal) (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/pt_PT/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_PT\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importar Extrato Bancário" From 6e143fa4ffbae1afc82091bb1a83787e5fa6036a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 10 Nov 2016 17:18:30 +0100 Subject: [PATCH 12/28] migrate account_bank_statement_import_camt --- account_bank_statement_import_camt/README.rst | 1 + .../__init__.py | 6 +- .../__manifest__.py | 26 ++--- .../account_bank_statement_import.py | 44 -------- account_bank_statement_import_camt/camt.py | 100 +++++++++--------- .../demo/demo_data.xml | 39 +++---- .../models/__init__.py | 4 + .../models/account_bank_statement_import.py | 42 ++++++++ .../{test-camt053.xml => test-camt053} | 0 .../tests/__init__.py | 22 +--- .../tests/test_import_bank_statement.py | 84 ++++++++------- .../views/account_bank_statement_import.xml | 15 +++ 12 files changed, 182 insertions(+), 201 deletions(-) delete mode 100644 account_bank_statement_import_camt/account_bank_statement_import.py create mode 100644 account_bank_statement_import_camt/models/__init__.py create mode 100644 account_bank_statement_import_camt/models/account_bank_statement_import.py rename account_bank_statement_import_camt/test_files/{test-camt053.xml => test-camt053} (100%) create mode 100644 account_bank_statement_import_camt/views/account_bank_statement_import.xml diff --git a/account_bank_statement_import_camt/README.rst b/account_bank_statement_import_camt/README.rst index f027351a..a564f7a8 100644 --- a/account_bank_statement_import_camt/README.rst +++ b/account_bank_statement_import_camt/README.rst @@ -28,6 +28,7 @@ Credits Contributors ------------ +* Holger Brunn * Stefan Rijnhart * Ronald Portier diff --git a/account_bank_statement_import_camt/__init__.py b/account_bank_statement_import_camt/__init__.py index 7dafcd16..6350c719 100644 --- a/account_bank_statement_import_camt/__init__.py +++ b/account_bank_statement_import_camt/__init__.py @@ -1 +1,5 @@ -from . import account_bank_statement_import +# -*- coding: utf-8 -*- +# © 2013-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models +from . import camt diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt/__manifest__.py index 86ce0c57..92e10bd1 100644 --- a/account_bank_statement_import_camt/__manifest__.py +++ b/account_bank_statement_import_camt/__manifest__.py @@ -1,25 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2013-2015 Therp BV -# -# 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 . -# -############################################################################## +# © 2013-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'CAMT Format Bank Statements Import', - 'version': '8.0.0.4.0', + 'version': '9.0.1.0.0', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', @@ -30,5 +14,7 @@ 'demo': [ 'demo/demo_data.xml', ], - 'installable': False, + 'data': [ + 'views/account_bank_statement_import.xml', + ], } diff --git a/account_bank_statement_import_camt/account_bank_statement_import.py b/account_bank_statement_import_camt/account_bank_statement_import.py deleted file mode 100644 index 8814670f..00000000 --- a/account_bank_statement_import_camt/account_bank_statement_import.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -"""Add process_camt method to account.bank.statement.import.""" -############################################################################## -# -# Copyright (C) 2013-2015 Therp BV -# -# 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 . -# -############################################################################## -import logging -from openerp import models -from .camt import CamtParser as Parser - - -_logger = logging.getLogger(__name__) - - -class AccountBankStatementImport(models.TransientModel): - """Add process_camt method to account.bank.statement.import.""" - _inherit = 'account.bank.statement.import' - - def _parse_file(self, cr, uid, data_file, context=None): - """Parse a CAMT053 XML file.""" - parser = Parser() - try: - _logger.debug("Try parsing with camt.") - return parser.parse(data_file) - except ValueError: - # Not a camt file, returning super will call next candidate: - _logger.debug("Statement file was not a camt file.", - exc_info=True) - return super(AccountBankStatementImport, self)._parse_file( - cr, uid, data_file, context=context) diff --git a/account_bank_statement_import_camt/camt.py b/account_bank_statement_import_camt/camt.py index aed01dbf..d5fa82db 100644 --- a/account_bank_statement_import_camt/camt.py +++ b/account_bank_statement_import_camt/camt.py @@ -1,28 +1,9 @@ # -*- coding: utf-8 -*- """Class to parse camt files.""" -############################################################################## -# -# Copyright (C) 2013-2015 Therp BV -# -# 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 . -# -############################################################################## +# © 2013-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import re -from datetime import datetime from lxml import etree -from openerp.addons.account_bank_statement_import.parserlib import ( - BankStatement) class CamtParser(object): @@ -58,7 +39,7 @@ class CamtParser(object): attr_value = found_node[0].text else: attr_value = join_str.join([x.text for x in found_node]) - setattr(obj, attr_name, attr_value) + obj[attr_name] = attr_value break def parse_transaction_details(self, ns, node, transaction): @@ -67,16 +48,21 @@ class CamtParser(object): self.add_value_from_node( ns, node, [ './ns:RmtInf/ns:Ustrd', - './ns:AddtlTxInf', './ns:AddtlNtryInf', - ], transaction, 'message', join_str='\n') + './ns:Refs/ns:InstrId', + ], transaction, 'note', join_str='\n') + # name + self.add_value_from_node( + ns, node, [ + './ns:AddtlTxInf', + ], transaction, 'name', join_str='\n') # eref self.add_value_from_node( ns, node, [ './ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref', './ns:Refs/ns:EndToEndId', ], - transaction, 'eref' + transaction, 'ref' ) # remote party values party_type = 'Dbtr' @@ -88,15 +74,15 @@ class CamtParser(object): './ns:RltdPties/ns:%s' % party_type, namespaces={'ns': ns}) if party_node: self.add_value_from_node( - ns, party_node[0], './ns:Nm', transaction, 'remote_owner') + ns, party_node[0], './ns:Nm', transaction, 'partner_name') self.add_value_from_node( ns, party_node[0], './ns:PstlAdr/ns:Ctry', transaction, - 'remote_owner_country' + 'partner_country' ) address_node = party_node[0].xpath( './ns:PstlAdr/ns:AdrLine', namespaces={'ns': ns}) if address_node: - transaction.remote_owner_address = [address_node[0].text] + transaction['partner_address'] = [address_node[0].text] # Get remote_account from iban or from domestic account: account_node = node.xpath( './ns:RltdPties/ns:%sAcct/ns:Id' % party_type, @@ -106,45 +92,52 @@ class CamtParser(object): iban_node = account_node[0].xpath( './ns:IBAN', namespaces={'ns': ns}) if iban_node: - transaction.remote_account = iban_node[0].text + transaction['account_number'] = iban_node[0].text bic_node = node.xpath( './ns:RltdAgts/ns:%sAgt/ns:FinInstnId/ns:BIC' % party_type, namespaces={'ns': ns} ) if bic_node: - transaction.remote_bank_bic = bic_node[0].text + transaction['account_bic'] = bic_node[0].text else: self.add_value_from_node( ns, account_node[0], './ns:Othr/ns:Id', transaction, - 'remote_account' + 'account_number' ) - def parse_transaction(self, ns, node, transaction): + def parse_transaction(self, ns, node): """Parse transaction (entry) node.""" + transaction = {} self.add_value_from_node( ns, node, './ns:BkTxCd/ns:Prtry/ns:Cd', transaction, 'transfer_type' ) + self.add_value_from_node( + ns, node, './ns:BookgDt/ns:Dt', transaction, 'date') self.add_value_from_node( ns, node, './ns:BookgDt/ns:Dt', transaction, 'execution_date') self.add_value_from_node( ns, node, './ns:ValDt/ns:Dt', transaction, 'value_date') - transaction.transferred_amount = self.parse_amount(ns, node) + + transaction['amount'] = self.parse_amount(ns, node) + details_node = node.xpath( './ns:NtryDtls/ns:TxDtls', namespaces={'ns': ns}) if details_node: self.parse_transaction_details(ns, details_node[0], transaction) - if not transaction.message: + if not transaction.get('name'): self.add_value_from_node( - ns, node, './ns:AddtlNtryInf', transaction, 'message') - if not transaction.eref: + ns, node, './ns:AddtlNtryInf', transaction, 'name') + if not transaction.get('name'): + transaction['name'] = '/' + if not transaction.get('ref'): self.add_value_from_node( ns, node, [ './ns:NtryDtls/ns:Btch/ns:PmtInfId', ], - transaction, 'eref' + transaction, 'ref' ) - transaction.data = etree.tostring(node) + transaction['data'] = etree.tostring(node) return transaction def get_balance_amounts(self, ns, node): @@ -182,27 +175,28 @@ class CamtParser(object): def parse_statement(self, ns, node): """Parse a single Stmt node.""" - statement = BankStatement() + result = {} self.add_value_from_node( ns, node, [ './ns:Acct/ns:Id/ns:IBAN', './ns:Acct/ns:Id/ns:Othr/ns:Id', - ], statement, 'local_account' + ], result, 'account_number' ) self.add_value_from_node( - ns, node, './ns:Id', statement, 'statement_id') + ns, node, './ns:Id', result, 'name') self.add_value_from_node( - ns, node, './ns:Acct/ns:Ccy', statement, 'local_currency') - (statement.start_balance, statement.end_balance) = ( + ns, node, './ns:Dt', result, 'date') + self.add_value_from_node( + ns, node, './ns:Acct/ns:Ccy', result, 'currency') + result['balance_start'], result['balance_end_real'] = ( self.get_balance_amounts(ns, node)) transaction_nodes = node.xpath('./ns:Ntry', namespaces={'ns': ns}) + result['transactions'] = [] for entry_node in transaction_nodes: - transaction = statement.create_transaction() - self.parse_transaction(ns, entry_node, transaction) - if statement['transactions']: - statement.date = datetime.strptime( - statement['transactions'][0].execution_date, "%Y-%m-%d") - return statement + transaction = self.parse_transaction(ns, entry_node) + if transaction: + result['transactions'].append(transaction) + return result def check_version(self, ns, root): """Validate validity of camt file.""" @@ -242,8 +236,14 @@ class CamtParser(object): ns = root.tag[1:root.tag.index("}")] self.check_version(ns, root) statements = [] + currency = None + account_number = None for node in root[0][1:]: statement = self.parse_statement(ns, node) if len(statement['transactions']): + if 'currency' in statement: + currency = statement.pop('currency') + if 'account_number' in statement: + account_number = statement.pop('account_number') statements.append(statement) - return statements + return currency, account_number, statements diff --git a/account_bank_statement_import_camt/demo/demo_data.xml b/account_bank_statement_import_camt/demo/demo_data.xml index 7fc44d77..e6313a13 100644 --- a/account_bank_statement_import_camt/demo/demo_data.xml +++ b/account_bank_statement_import_camt/demo/demo_data.xml @@ -1,26 +1,15 @@ - - - - - Bank Journal - (test camt) - TBNKCAMT - bank - - - - - - - - Your Company - NL77ABNA0574908765 - - - - bank - - - - - + + + NL77ABNA0574908765 + + + + + + Bank Journal - (test camt) + TBNKCAMT + bank + + + diff --git a/account_bank_statement_import_camt/models/__init__.py b/account_bank_statement_import_camt/models/__init__.py new file mode 100644 index 00000000..44b33628 --- /dev/null +++ b/account_bank_statement_import_camt/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2013-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import account_bank_statement_import diff --git a/account_bank_statement_import_camt/models/account_bank_statement_import.py b/account_bank_statement_import_camt/models/account_bank_statement_import.py new file mode 100644 index 00000000..9d711d80 --- /dev/null +++ b/account_bank_statement_import_camt/models/account_bank_statement_import.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +"""Add process_camt method to account.bank.statement.import.""" +# © 2013-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import logging +import StringIO +import zipfile +from openerp import api, models +from ..camt import CamtParser as Parser + +_logger = logging.getLogger(__name__) + + +class AccountBankStatementImport(models.TransientModel): + """Add process_camt method to account.bank.statement.import.""" + _inherit = 'account.bank.statement.import' + + @api.model + def _parse_file(self, data_file): + """Parse a CAMT053 XML file.""" + try: + parser = Parser() + _logger.debug("Try parsing with camt.") + return parser.parse(data_file) + except ValueError: + try: + with zipfile.ZipFile(StringIO.StringIO(data_file)) as data: + currency = None + account_number = None + transactions = [] + for member in data.namelist(): + currency, account_number, new = self._parse_file( + data.open(member).read() + ) + transactions.extend(new) + return currency, account_number, transactions + except (zipfile.BadZipfile, ValueError): + pass + # Not a camt file, returning super will call next candidate: + _logger.debug("Statement file was not a camt file.", + exc_info=True) + return super(AccountBankStatementImport, self)._parse_file(data_file) diff --git a/account_bank_statement_import_camt/test_files/test-camt053.xml b/account_bank_statement_import_camt/test_files/test-camt053 similarity index 100% rename from account_bank_statement_import_camt/test_files/test-camt053.xml rename to account_bank_statement_import_camt/test_files/test-camt053 diff --git a/account_bank_statement_import_camt/tests/__init__.py b/account_bank_statement_import_camt/tests/__init__.py index cd97bcae..06d3af2f 100644 --- a/account_bank_statement_import_camt/tests/__init__.py +++ b/account_bank_statement_import_camt/tests/__init__.py @@ -1,23 +1,5 @@ # -*- encoding: utf-8 -*- """Test import of bank statement for camt.053.""" -############################################################################## -# -# Copyright (C) 2015 Therp BV . -# -# All other contributions are (C) by their respective contributors -# -# 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 . -# -############################################################################## +# © 2013-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import test_import_bank_statement diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py index d14aca96..496ae943 100644 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -1,52 +1,54 @@ # -*- coding: utf-8 -*- """Run test to import camt.053 import.""" -############################################################################## -# -# Copyright (C) 2015 Therp BV . -# -# 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.addons.account_bank_statement_import.tests import ( - TestStatementFile) +# © 2013-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import base64 +from openerp.tests.common import TransactionCase +from openerp.tools.misc import file_open -class TestImport(TestStatementFile): +class TestImport(TransactionCase): """Run test to import camt import.""" + transactions = [ + { + 'account_number': 'NL46ABNA0499998748', + 'amount': -754.25, + 'date': '2014-01-05', + 'ref': '435005714488-ABNO33052620', + }, + ] def test_statement_import(self): """Test correct creation of single statement.""" - transactions = [ - { - 'remote_account': 'NL46ABNA0499998748', - 'transferred_amount': -754.25, - 'value_date': '2014-01-05', - 'ref': '435005714488-ABNO33052620', - }, - ] - self._test_statement_import( - 'account_bank_statement_import_camt', 'test-camt053.xml', - '1234Test/1', - local_account='NL77ABNA0574908765', - start_balance=15568.27, end_balance=15121.12, - transactions=transactions - ) + action = {} + with file_open( + 'account_bank_statement_import_camt/test_files/test-camt053' + ) as testfile: + action = self.env['account.bank.statement.import'].create({ + 'data_file': base64.b64encode(testfile.read()), + }).import_file() + for statement in self.env['account.bank.statement'].browse( + action['context']['statement_ids'] + ): + self.assertTrue(any( + all( + line[key] == self.transactions[0][key] + for key in ['amount', 'date', 'ref'] + ) and + line.bank_account_id.acc_number == + self.transactions[0]['account_number'] + for line in statement.line_ids + )) def test_zip_import(self): """Test import of multiple statements from zip file.""" - self._test_statement_import( - 'account_bank_statement_import_camt', 'test-camt053.zip', - '1234Test/2', # Only name of first statement - local_account='NL77ABNA0574908765', - ) + with file_open( + 'account_bank_statement_import_camt/test_files/test-camt053.zip' + ) as testfile: + action = self.env['account.bank.statement.import'].create({ + 'data_file': base64.b64encode(testfile.read()), + }).import_file() + for statement in self.env['account.bank.statement'].browse( + action['context']['statement_ids'] + ): + self.assertTrue(statement.line_ids) diff --git a/account_bank_statement_import_camt/views/account_bank_statement_import.xml b/account_bank_statement_import_camt/views/account_bank_statement_import.xml new file mode 100644 index 00000000..1b9b2653 --- /dev/null +++ b/account_bank_statement_import_camt/views/account_bank_statement_import.xml @@ -0,0 +1,15 @@ + + + + + account.bank.statement.import + + +
    +
  • CAMT
  • +
  • zipped CAMT
  • +
+
+
+
+
From 33a11d4a23e8e796925a07a15320db15699cdd05 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Fri, 9 Dec 2016 17:29:09 +0100 Subject: [PATCH 13/28] Create demo data during the execution of tests This ensures that the demo chart of accounts is already installed when the bank journal account is created for the bank journal that is needed to test the import. Otherwise, the demo chart from l10n_generic_coa will fail to install because there is already a journal account in the system. --- .../__manifest__.py | 3 --- .../demo/demo_data.xml | 15 --------------- .../tests/test_import_bank_statement.py | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 account_bank_statement_import_camt/demo/demo_data.xml diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt/__manifest__.py index 92e10bd1..2b1a3f56 100644 --- a/account_bank_statement_import_camt/__manifest__.py +++ b/account_bank_statement_import_camt/__manifest__.py @@ -11,9 +11,6 @@ 'depends': [ 'account_bank_statement_import', ], - 'demo': [ - 'demo/demo_data.xml', - ], 'data': [ 'views/account_bank_statement_import.xml', ], diff --git a/account_bank_statement_import_camt/demo/demo_data.xml b/account_bank_statement_import_camt/demo/demo_data.xml deleted file mode 100644 index e6313a13..00000000 --- a/account_bank_statement_import_camt/demo/demo_data.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - NL77ABNA0574908765 - - - - - - Bank Journal - (test camt) - TBNKCAMT - bank - - - diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py index 496ae943..b043e712 100644 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -18,6 +18,21 @@ class TestImport(TransactionCase): }, ] + def setUp(self): + super(TestImport, self).setUp() + bank = self.env['res.partner.bank'].create({ + 'acc_number': 'NL77ABNA0574908765', + 'partner_id': self.env.ref('base.main_partner').id, + 'company_id': self.env.ref('base.main_company').id, + 'bank_id': self.env.ref('base.res_bank_1').id, + }) + self.env['account.journal'].create({ + 'name': 'Bank Journal - (test camt)', + 'code': 'TBNKCAMT', + 'type': 'bank', + 'bank_account_id': bank.id, + }) + def test_statement_import(self): """Test correct creation of single statement.""" action = {} From 5264d5188dfb200f963eb15a5c194f255822e2c4 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Fri, 9 Dec 2016 19:13:45 -0500 Subject: [PATCH 14/28] OCA Transbot updated translations from Transifex --- .../i18n/fr_CH.po | 34 +++++++++++++++++++ account_bank_statement_import_camt/i18n/gl.po | 34 +++++++++++++++++++ .../i18n/nb_NO.po | 34 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 account_bank_statement_import_camt/i18n/fr_CH.po create mode 100644 account_bank_statement_import_camt/i18n/gl.po create mode 100644 account_bank_statement_import_camt/i18n/nb_NO.po diff --git a/account_bank_statement_import_camt/i18n/fr_CH.po b/account_bank_statement_import_camt/i18n/fr_CH.po new file mode 100644 index 00000000..3b8e8135 --- /dev/null +++ b/account_bank_statement_import_camt/i18n/fr_CH.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-09 17:00+0000\n" +"PO-Revision-Date: 2016-12-09 17:00+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: French (Switzerland) (https://www.transifex.com/oca/teams/23907/fr_CH/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr_CH\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "CAMT" +msgstr "" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importer Relevé" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "zipped CAMT" +msgstr "" diff --git a/account_bank_statement_import_camt/i18n/gl.po b/account_bank_statement_import_camt/i18n/gl.po new file mode 100644 index 00000000..7ac52f60 --- /dev/null +++ b/account_bank_statement_import_camt/i18n/gl.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +# Alejandro Santana , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-09 17:00+0000\n" +"PO-Revision-Date: 2016-12-09 17:00+0000\n" +"Last-Translator: Alejandro Santana , 2016\n" +"Language-Team: Galician (https://www.transifex.com/oca/teams/23907/gl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: gl\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "CAMT" +msgstr "" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importar extracto bancario" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "zipped CAMT" +msgstr "" diff --git a/account_bank_statement_import_camt/i18n/nb_NO.po b/account_bank_statement_import_camt/i18n/nb_NO.po new file mode 100644 index 00000000..8b0659a3 --- /dev/null +++ b/account_bank_statement_import_camt/i18n/nb_NO.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +# Imre Kristoffer Eilertsen , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-09 17:00+0000\n" +"PO-Revision-Date: 2016-12-09 17:00+0000\n" +"Last-Translator: Imre Kristoffer Eilertsen , 2016\n" +"Language-Team: Norwegian Bokmål (Norway) (https://www.transifex.com/oca/teams/23907/nb_NO/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: nb_NO\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "CAMT" +msgstr "" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Importer bankutsagn" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "zipped CAMT" +msgstr "" From 64669d6a4186185e0b23b986cea660d3fdd91059 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Fri, 13 Jan 2017 20:10:08 -0500 Subject: [PATCH 15/28] OCA Transbot updated translations from Transifex --- account_bank_statement_import_camt/i18n/fi.po | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 account_bank_statement_import_camt/i18n/fi.po diff --git a/account_bank_statement_import_camt/i18n/fi.po b/account_bank_statement_import_camt/i18n/fi.po new file mode 100644 index 00000000..09b901e0 --- /dev/null +++ b/account_bank_statement_import_camt/i18n/fi.po @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +# Jarmo Kortetjärvi , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-10 05:00+0000\n" +"PO-Revision-Date: 2016-12-10 05:00+0000\n" +"Last-Translator: Jarmo Kortetjärvi , 2017\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fi\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "CAMT" +msgstr "" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Tuo pankkiaineisto" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "zipped CAMT" +msgstr "" From fe667614ee73cee31f606b403223aacbdd26e2a8 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Tue, 13 Dec 2016 21:08:12 +0100 Subject: [PATCH 16/28] [MIG] account_bank_statement_import_camt 10.0 --- .../__manifest__.py | 2 +- .../models/account_bank_statement_import.py | 2 +- .../tests/test_import_bank_statement.py | 4 +-- .../views/account_bank_statement_import.xml | 26 +++++++++---------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt/__manifest__.py index 2b1a3f56..d2415dce 100644 --- a/account_bank_statement_import_camt/__manifest__.py +++ b/account_bank_statement_import_camt/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'CAMT Format Bank Statements Import', - 'version': '9.0.1.0.0', + 'version': '10.0.1.0.0', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', diff --git a/account_bank_statement_import_camt/models/account_bank_statement_import.py b/account_bank_statement_import_camt/models/account_bank_statement_import.py index 9d711d80..0d6f9289 100644 --- a/account_bank_statement_import_camt/models/account_bank_statement_import.py +++ b/account_bank_statement_import_camt/models/account_bank_statement_import.py @@ -5,7 +5,7 @@ import logging import StringIO import zipfile -from openerp import api, models +from odoo import api, models from ..camt import CamtParser as Parser _logger = logging.getLogger(__name__) diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py index b043e712..b3c57aaa 100644 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -3,8 +3,8 @@ # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import base64 -from openerp.tests.common import TransactionCase -from openerp.tools.misc import file_open +from odoo.tests.common import TransactionCase +from odoo.tools.misc import file_open class TestImport(TransactionCase): diff --git a/account_bank_statement_import_camt/views/account_bank_statement_import.xml b/account_bank_statement_import_camt/views/account_bank_statement_import.xml index 1b9b2653..92d3c08e 100644 --- a/account_bank_statement_import_camt/views/account_bank_statement_import.xml +++ b/account_bank_statement_import_camt/views/account_bank_statement_import.xml @@ -1,15 +1,13 @@ - - - - account.bank.statement.import - - -
    -
  • CAMT
  • -
  • zipped CAMT
  • -
-
-
-
-
+ + + account.bank.statement.import + + +
    +
  • CAMT
  • +
  • zipped CAMT
  • +
+
+
+
From ad9a1b23a15dc3f79d7c2bfeb15e9cda4faca38c Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 12 Aug 2017 02:24:40 +0200 Subject: [PATCH 17/28] OCA Transbot updated translations from Transifex --- account_bank_statement_import_camt/i18n/fr.po | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/account_bank_statement_import_camt/i18n/fr.po b/account_bank_statement_import_camt/i18n/fr.po index 72f164b6..92b04b6e 100644 --- a/account_bank_statement_import_camt/i18n/fr.po +++ b/account_bank_statement_import_camt/i18n/fr.po @@ -3,21 +3,33 @@ # * account_bank_statement_import_camt # # Translators: +# OCA Transbot , 2017 +# Quentin THEURET , 2017 msgid "" msgstr "" -"Project-Id-Version: bank-statement-import (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 21:51+0000\n" -"PO-Revision-Date: 2015-07-24 07:41+0000\n" -"Last-Translator: <>\n" -"Language-Team: French (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/fr/)\n" +"POT-Creation-Date: 2017-08-11 02:41+0000\n" +"PO-Revision-Date: 2017-08-11 02:41+0000\n" +"Last-Translator: Quentin THEURET , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "CAMT" +msgstr "CAMT" + #. module: account_bank_statement_import_camt #: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importer Relevé Bancaire" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "zipped CAMT" +msgstr "CAMT zippé" From a66b4bf7cf314d1cb4666fbfcff00260a7c6c3b0 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Fri, 21 Apr 2017 14:31:50 +0200 Subject: [PATCH 18/28] camt: allow modules to enhance the parser --- account_bank_statement_import_camt/__init__.py | 1 - account_bank_statement_import_camt/__manifest__.py | 4 ++-- account_bank_statement_import_camt/models/__init__.py | 1 + .../models/account_bank_statement_import.py | 3 +-- .../{camt.py => models/parser.py} | 5 ++++- 5 files changed, 8 insertions(+), 6 deletions(-) rename account_bank_statement_import_camt/{camt.py => models/parser.py} (98%) diff --git a/account_bank_statement_import_camt/__init__.py b/account_bank_statement_import_camt/__init__.py index 6350c719..1eb5270e 100644 --- a/account_bank_statement_import_camt/__init__.py +++ b/account_bank_statement_import_camt/__init__.py @@ -2,4 +2,3 @@ # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models -from . import camt diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt/__manifest__.py index d2415dce..1ff167c3 100644 --- a/account_bank_statement_import_camt/__manifest__.py +++ b/account_bank_statement_import_camt/__manifest__.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# © 2013-2016 Therp BV +# © 2013-2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'CAMT Format Bank Statements Import', - 'version': '10.0.1.0.0', + 'version': '10.0.1.1.0', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', diff --git a/account_bank_statement_import_camt/models/__init__.py b/account_bank_statement_import_camt/models/__init__.py index 44b33628..0251c8f1 100644 --- a/account_bank_statement_import_camt/models/__init__.py +++ b/account_bank_statement_import_camt/models/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import parser from . import account_bank_statement_import diff --git a/account_bank_statement_import_camt/models/account_bank_statement_import.py b/account_bank_statement_import_camt/models/account_bank_statement_import.py index 0d6f9289..4490f167 100644 --- a/account_bank_statement_import_camt/models/account_bank_statement_import.py +++ b/account_bank_statement_import_camt/models/account_bank_statement_import.py @@ -6,7 +6,6 @@ import logging import StringIO import zipfile from odoo import api, models -from ..camt import CamtParser as Parser _logger = logging.getLogger(__name__) @@ -19,7 +18,7 @@ class AccountBankStatementImport(models.TransientModel): def _parse_file(self, data_file): """Parse a CAMT053 XML file.""" try: - parser = Parser() + parser = self.env['account.bank.statement.import.camt.parser'] _logger.debug("Try parsing with camt.") return parser.parse(data_file) except ValueError: diff --git a/account_bank_statement_import_camt/camt.py b/account_bank_statement_import_camt/models/parser.py similarity index 98% rename from account_bank_statement_import_camt/camt.py rename to account_bank_statement_import_camt/models/parser.py index d5fa82db..51d78207 100644 --- a/account_bank_statement_import_camt/camt.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -5,8 +5,11 @@ import re from lxml import etree +from odoo import models -class CamtParser(object): + +class CamtParser(models.AbstractModel): + _name = 'account.bank.statement.import.camt.parser' """Parser for camt bank statement import files.""" def parse_amount(self, ns, node): From c7e5d6ec3c24e3eed0572cf0a437d75a3752418b Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 25 Nov 2017 03:11:53 +0100 Subject: [PATCH 19/28] OCA Transbot updated translations from Transifex --- account_bank_statement_import_camt/i18n/es.po | 41 ++++++++++++++++--- account_bank_statement_import_camt/i18n/fr.po | 28 +++++++++++-- 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/account_bank_statement_import_camt/i18n/es.po b/account_bank_statement_import_camt/i18n/es.po index ebef1f34..c198351c 100644 --- a/account_bank_statement_import_camt/i18n/es.po +++ b/account_bank_statement_import_camt/i18n/es.po @@ -3,21 +3,52 @@ # * account_bank_statement_import_camt # # Translators: +# OCA Transbot , 2017 msgid "" msgstr "" -"Project-Id-Version: bank-statement-import (8.0)\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-24 21:51+0000\n" -"PO-Revision-Date: 2015-07-24 07:41+0000\n" -"Last-Translator: <>\n" -"Language-Team: Spanish (http://www.transifex.com/oca/OCA-bank-statement-import-8-0/language/es/)\n" +"POT-Creation-Date: 2017-11-21 01:42+0000\n" +"PO-Revision-Date: 2017-11-21 01:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "CAMT" +msgstr "" + +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_display_name +msgid "Display Name" +msgstr "Nombre a mostrar" + +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_id +msgid "ID" +msgstr "ID" + #. module: account_bank_statement_import_camt #: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importar extracto bancario" + +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser___last_update +msgid "Last Modified on" +msgstr "Última modificación en" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import_camt_parser +msgid "account.bank.statement.import.camt.parser" +msgstr "" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "zipped CAMT" +msgstr "" diff --git a/account_bank_statement_import_camt/i18n/fr.po b/account_bank_statement_import_camt/i18n/fr.po index 92b04b6e..96f6d639 100644 --- a/account_bank_statement_import_camt/i18n/fr.po +++ b/account_bank_statement_import_camt/i18n/fr.po @@ -3,15 +3,15 @@ # * account_bank_statement_import_camt # # Translators: -# OCA Transbot , 2017 # Quentin THEURET , 2017 +# OCA Transbot , 2017 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-11 02:41+0000\n" -"PO-Revision-Date: 2017-08-11 02:41+0000\n" -"Last-Translator: Quentin THEURET , 2017\n" +"POT-Creation-Date: 2017-11-21 01:42+0000\n" +"PO-Revision-Date: 2017-11-21 01:42+0000\n" +"Last-Translator: OCA Transbot , 2017\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -24,11 +24,31 @@ msgstr "" msgid "CAMT" msgstr "CAMT" +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_id +msgid "ID" +msgstr "ID" + #. module: account_bank_statement_import_camt #: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importer Relevé Bancaire" +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser___last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import_camt_parser +msgid "account.bank.statement.import.camt.parser" +msgstr "" + #. module: account_bank_statement_import_camt #: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view msgid "zipped CAMT" From f0a4fe8a97ae51bdbd0c4f3f92fb2875d5109163 Mon Sep 17 00:00:00 2001 From: david wulliamoz Date: Tue, 18 Apr 2017 17:24:46 +0200 Subject: [PATCH 20/28] allow camt054 to be parsed IMP README --- account_bank_statement_import_camt/README.rst | 2 +- account_bank_statement_import_camt/__manifest__.py | 2 +- account_bank_statement_import_camt/models/parser.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/account_bank_statement_import_camt/README.rst b/account_bank_statement_import_camt/README.rst index a564f7a8..92aaeaa5 100644 --- a/account_bank_statement_import_camt/README.rst +++ b/account_bank_statement_import_camt/README.rst @@ -4,7 +4,7 @@ Bank Statement Parse Camt ========================= -Module to import SEPA CAMT.053 Format bank statement files. +Module to import SEPA CAMT.053 and CAMT.054 Format bank statement files. Based on the Banking addons framework. diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt/__manifest__.py index 1ff167c3..1a4d5122 100644 --- a/account_bank_statement_import_camt/__manifest__.py +++ b/account_bank_statement_import_camt/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'CAMT Format Bank Statements Import', - 'version': '10.0.1.1.0', + 'version': '10.0.1.1.1', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index 51d78207..cc4b6be9 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -210,10 +210,12 @@ class CamtParser(models.AbstractModel): ) if not re_camt.search(ns): raise ValueError('no camt: ' + ns) - # Check wether version 052 or 053: + # Check wether version 052 ,053 or 054: re_camt_version = re.compile( + r'(^urn:iso:std:iso:20022:tech:xsd:camt.054.' r'(^urn:iso:std:iso:20022:tech:xsd:camt.053.' r'|^urn:iso:std:iso:20022:tech:xsd:camt.052.' + r'|^ISO:camt.054.' r'|^ISO:camt.053.' r'|^ISO:camt.052.)' ) From aad82e82411b3ca5301f5875c8a82739252dacea Mon Sep 17 00:00:00 2001 From: Emanuel Cino Date: Wed, 19 Apr 2017 08:36:53 +0200 Subject: [PATCH 21/28] Fix typo --- account_bank_statement_import_camt/models/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index cc4b6be9..21657747 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -213,7 +213,7 @@ class CamtParser(models.AbstractModel): # Check wether version 052 ,053 or 054: re_camt_version = re.compile( r'(^urn:iso:std:iso:20022:tech:xsd:camt.054.' - r'(^urn:iso:std:iso:20022:tech:xsd:camt.053.' + r'|^urn:iso:std:iso:20022:tech:xsd:camt.053.' r'|^urn:iso:std:iso:20022:tech:xsd:camt.052.' r'|^ISO:camt.054.' r'|^ISO:camt.053.' From c4dc160eda0b817d0f64cd647cbdedf64446620d Mon Sep 17 00:00:00 2001 From: ecino Date: Wed, 24 Jan 2018 15:11:26 +0100 Subject: [PATCH 22/28] [10.0] Better parse camt groupped transactions (#131) * correctly parse entries with multiple transactions Our bank does it. Care has been taken not to break cases where Ntry/NtryDtls/TxDtls isn't used: if any piece of information isn't found on these nodes, the matching information from the Ntry is used. Most often the entry has a sum or a summary and the transaction details are more precise and specific, so it makes sense to use their contents rather than its. * more complete unit tests for camt parser This checks the whole output data of the parser against its expected output. * add a test case that checks TxDtls decoding * special case for Ntrys without TxDtls * CO-12 - Date Import BVR * FIX tests * CO-1232 Fixed issues with CAMT parser tests --- .../models/parser.py | 70 +++--- .../test_files/golden-camt053-txdtls.pydata | 26 +++ .../test_files/golden-camt053.pydata | 45 ++++ .../test_files/test-camt053-txdtls | 214 ++++++++++++++++++ .../tests/test_import_bank_statement.py | 45 +++- 5 files changed, 368 insertions(+), 32 deletions(-) create mode 100644 account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata create mode 100644 account_bank_statement_import_camt/test_files/golden-camt053.pydata create mode 100644 account_bank_statement_import_camt/test_files/test-camt053-txdtls diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index 21657747..fedc386c 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Class to parse camt files.""" # © 2013-2016 Therp BV +# Copyright 2017 Open Net Sàrl # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import re from lxml import etree @@ -46,7 +47,7 @@ class CamtParser(models.AbstractModel): break def parse_transaction_details(self, ns, node, transaction): - """Parse transaction details (message, party, account...).""" + """Parse TxDtls node.""" # message self.add_value_from_node( ns, node, [ @@ -64,9 +65,13 @@ class CamtParser(models.AbstractModel): ns, node, [ './ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref', './ns:Refs/ns:EndToEndId', + './ns:Ntry/ns:AcctSvcrRef' ], transaction, 'ref' ) + amount = self.parse_amount(ns, node) + if amount != 0.0: + transaction['amount'] = amount # remote party values party_type = 'Dbtr' party_type_node = node.xpath( @@ -107,10 +112,11 @@ class CamtParser(models.AbstractModel): ns, account_node[0], './ns:Othr/ns:Id', transaction, 'account_number' ) + transaction['data'] = etree.tostring(node) - def parse_transaction(self, ns, node): - """Parse transaction (entry) node.""" - transaction = {} + def parse_entry(self, ns, node): + """Parse an Ntry node and yield transactions""" + transaction = {'name': '/', 'amount': 0} # fallback defaults self.add_value_from_node( ns, node, './ns:BkTxCd/ns:Prtry/ns:Cd', transaction, 'transfer_type' @@ -121,27 +127,30 @@ class CamtParser(models.AbstractModel): ns, node, './ns:BookgDt/ns:Dt', transaction, 'execution_date') self.add_value_from_node( ns, node, './ns:ValDt/ns:Dt', transaction, 'value_date') + amount = self.parse_amount(ns, node) + if amount != 0.0: + transaction['amount'] = amount + self.add_value_from_node( + ns, node, './ns:AddtlNtryInf', transaction, 'name') + self.add_value_from_node( + ns, node, [ + './ns:NtryDtls/ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref', + './ns:NtryDtls/ns:Btch/ns:PmtInfId', + './ns:NtryDtls/ns:TxDtls/ns:Refs/ns:AcctSvcrRef' + ], + transaction, 'ref' + ) - transaction['amount'] = self.parse_amount(ns, node) - - details_node = node.xpath( + details_nodes = node.xpath( './ns:NtryDtls/ns:TxDtls', namespaces={'ns': ns}) - if details_node: - self.parse_transaction_details(ns, details_node[0], transaction) - if not transaction.get('name'): - self.add_value_from_node( - ns, node, './ns:AddtlNtryInf', transaction, 'name') - if not transaction.get('name'): - transaction['name'] = '/' - if not transaction.get('ref'): - self.add_value_from_node( - ns, node, [ - './ns:NtryDtls/ns:Btch/ns:PmtInfId', - ], - transaction, 'ref' - ) - transaction['data'] = etree.tostring(node) - return transaction + if len(details_nodes) == 0: + yield transaction + return + transaction_base = transaction + for node in details_nodes: + transaction = transaction_base.copy() + self.parse_transaction_details(ns, node, transaction) + yield transaction def get_balance_amounts(self, ns, node): """Return opening and closing balance. @@ -193,12 +202,15 @@ class CamtParser(models.AbstractModel): ns, node, './ns:Acct/ns:Ccy', result, 'currency') result['balance_start'], result['balance_end_real'] = ( self.get_balance_amounts(ns, node)) - transaction_nodes = node.xpath('./ns:Ntry', namespaces={'ns': ns}) - result['transactions'] = [] - for entry_node in transaction_nodes: - transaction = self.parse_transaction(ns, entry_node) - if transaction: - result['transactions'].append(transaction) + entry_nodes = node.xpath('./ns:Ntry', namespaces={'ns': ns}) + transactions = [] + for entry_node in entry_nodes: + transactions.extend(self.parse_entry(ns, entry_node)) + result['transactions'] = transactions + result['date'] = sorted(transactions, + key=lambda x: x['date'], + reverse=True + )[0]['date'] return result def check_version(self, ns, root): diff --git a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata new file mode 100644 index 00000000..f641bfbf --- /dev/null +++ b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata @@ -0,0 +1,26 @@ +(None, + 'CH1111000000123456789', + [{'balance_end_real': 79443.15, + 'balance_start': 75960.15, + 'date': '2017-03-22', + 'name': '20170323123456789012345', + 'transactions': [{'account_number': 'CH2222000000123456789', + 'amount': 2187.0, + 'data': '\n \n 123456CHCAFEBABE\n \n 01\n 123456CHCAFEBABE\n \n \n 2187.00\n CRDT\n \n \n PMNT\n \n RCDT\n AUTT\n \n \n \n \n \n Banque Cantonale Vaudoise\n \n Place Saint-François\n 14\n 1003\n Lausanne\n CH1\n \n \n \n \n CH2222000000123456789\n \n \n \n \n \n \n POFICHBEXXX\n POSTFINANCE AG\n \n MINGERSTRASSE 20\n 3030 BERNE\n \n \n \n \n \n \n \n \n \n ISR Reference\n \n \n 302388292000011111111111111\n \n ?REJECT?0\n \n \n \n 2017-03-22T20:00:00\n \n \n ', + 'date': '2017-03-22', + 'execution_date': '2017-03-22', + 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', + 'partner_country': 'CH1', + 'partner_name': 'Banque Cantonale Vaudoise', + 'ref': '302388292000011111111111111', + 'value_date': '2017-03-23'}, + {'account_number': 'CH3333000000123456789', + 'amount': 1296.0, + 'data': '\n \n 123456CHCAFEBABE\n \n 01\n 123456CHCAFEBABE\n \n \n 1296.00\n CRDT\n \n \n PMNT\n \n RCDT\n AUTT\n \n \n \n \n \n Banque Cantonale Vaudoise\n \n Place Saint-François\n 14\n 1003\n Lausanne\n CH2\n \n \n \n \n CH3333000000123456789\n \n \n \n \n \n \n POFICHBEYYY\n POSTFINANCE AG\n \n MINGERSTRASSE 20\n 3030 BERNE\n \n \n \n \n \n \n \n \n \n ISR Reference\n \n \n 302388292000022222222222222\n \n ?REJECT?0\n \n \n \n 2017-03-22T20:00:00\n \n \n ', + 'date': '2017-03-22', + 'execution_date': '2017-03-22', + 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', + 'partner_country': 'CH2', + 'partner_name': 'Banque Cantonale Vaudoise', + 'ref': '302388292000022222222222222', + 'value_date': '2017-03-23'}]}]) diff --git a/account_bank_statement_import_camt/test_files/golden-camt053.pydata b/account_bank_statement_import_camt/test_files/golden-camt053.pydata new file mode 100644 index 00000000..da29c8da --- /dev/null +++ b/account_bank_statement_import_camt/test_files/golden-camt053.pydata @@ -0,0 +1,45 @@ +(None, + 'NL77ABNA0574908765', + [{'balance_end_real': 15121.12, + 'balance_start': 15568.27, + 'date': '2014-01-05', + 'name': '1234Test/1', + 'transactions': [{'account_bic': 'ABNANL2A', + 'account_number': 'NL46ABNA0499998748', + 'amount': -754.25, + 'data': '\n \n INNDNL2U20141231000142300002844\n 435005714488-ABNO33052620\n 1880000341866\n \n \n \n 754.25\n \n \n \n \n INSURANCE COMPANY TESTX\n \n TEST STREET 20\n 1234 AB TESTCITY\n NL\n \n \n \n \n NL46ABNA0499998748\n \n \n \n \n \n \n ABNANL2A\n \n \n \n \n Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014\n \n MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014\n \n ', + 'date': '2014-01-05', + 'execution_date': '2014-01-05', + 'name': 'MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014', + 'note': 'Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014', + 'partner_country': 'NL', + 'partner_name': 'INSURANCE COMPANY TESTX', + 'ref': '435005714488-ABNO33052620', + 'transfer_type': 'EI', + 'value_date': '2014-01-05'}, + {'account_bic': 'ABNANL2A', + 'account_number': 'NL46ABNA0499998748', + 'amount': -594.05, + 'data': '\n \n TESTBANK/NL/20141229/01206408\n TESTBANK/NL/20141229/01206408\n NL22ZZZ524885430000-C0125.1\n \n \n \n 564.05\n \n \n \n \n Test Customer\n \n NL\n \n \n \n \n NL46ABNA0499998748\n \n \n \n \n \n \n ABNANL2A\n \n \n \n \n Direct Debit S14 0410\n \n \n \n AC06\n \n \n Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408\n \n ', + 'date': '2014-01-05', + 'execution_date': '2014-01-05', + 'name': 'Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408', + 'note': 'Direct Debit S14 0410', + 'partner_country': 'NL', + 'partner_name': 'Test Customer', + 'ref': 'TESTBANK/NL/20141229/01206408', + 'transfer_type': 'EIST', + 'value_date': '2014-01-05'}, + {'account_bic': 'ABNANL2A', + 'account_number': 'NL69ABNA0522123643', + 'amount': 1405.31, + 'data': '\n \n INNDNL2U20140105000217200000708\n 115\n \n \n \n 1405.31\n \n \n \n \n 3rd party Media\n \n SOMESTREET 570-A\n 1276 ML HOUSCITY\n NL\n \n \n \n \n NL69ABNA0522123643\n \n \n \n \n \n \n ABNANL2A\n \n \n \n #RD PARTY MEDIA CUSNO 90782 4210773\n \n ', + 'date': '2014-01-05', + 'execution_date': '2014-01-05', + 'name': '#RD PARTY MEDIA CUSNO 90782 4210773', + 'note': 'INNDNL2U20140105000217200000708', + 'partner_country': 'NL', + 'partner_name': '3rd party Media', + 'ref': '115', + 'transfer_type': 'ET', + 'value_date': '2014-01-05'}]}]) diff --git a/account_bank_statement_import_camt/test_files/test-camt053-txdtls b/account_bank_statement_import_camt/test_files/test-camt053-txdtls new file mode 100644 index 00000000..cf7c38f2 --- /dev/null +++ b/account_bank_statement_import_camt/test_files/test-camt053-txdtls @@ -0,0 +1,214 @@ + + + + + 20170323312345678900000 + 2017-03-23T14:47:00 + + 1 + true + + Test + + + 20170323123456789012345 + 58 + 2017-03-23T14:47:00 + + 2017-03-23T00:00:00 + 2017-03-23T23:59:59 + + + + CH1111000000123456789 + + + Open Net S. à r.l. Prilly + + + + + + OPBD + + + 75960.15 + CRDT +
+
2017-03-22
+ +
+ + + + CLBD + + + 79443.15 + CRDT +
+
2017-03-23
+ +
+ + 012345678 + 3483.00 + CRDT + false + BOOK + +
2017-03-22
+
+ +
2017-03-23
+
+ 20170323001234567891234567891234 + + + PMNT + + RCDT + VCOM + + + + + + 2 + + + + 123456CHCAFEBABE + + 01 + 123456CHCAFEBABE + + + 2187.00 + CRDT + + + PMNT + + RCDT + AUTT + + + + + + Banque Cantonale Vaudoise + + Place Saint-François + 14 + 1003 + Lausanne + CH1 + + + + + CH2222000000123456789 + + + + + + + POFICHBEXXX + POSTFINANCE AG + + MINGERSTRASSE 20 + 3030 BERNE + + + + + + + + + + ISR Reference + + + 302388292000011111111111111 + + ?REJECT?0 + + + + 2017-03-22T20:00:00 + + + + + 123456CHCAFEBABE + + 01 + 123456CHCAFEBABE + + + 1296.00 + CRDT + + + PMNT + + RCDT + AUTT + + + + + + Banque Cantonale Vaudoise + + Place Saint-François + 14 + 1003 + Lausanne + CH2 + + + + + CH3333000000123456789 + + + + + + + POFICHBEYYY + POSTFINANCE AG + + MINGERSTRASSE 20 + 3030 BERNE + + + + + + + + + + ISR Reference + + + 302388292000022222222222222 + + ?REJECT?0 + + + + 2017-03-22T20:00:00 + + + + CRÉDIT GROUPÉ BVR TRAITEMENT DU 22.03.2017 NUMÉRO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE +
+
+
+
diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py index b3c57aaa..840f005b 100644 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -1,12 +1,53 @@ # -*- coding: utf-8 -*- """Run test to import camt.053 import.""" # © 2013-2016 Therp BV +# Copyright 2017 Open Net Sàrl # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import base64 +import difflib +import pprint +import tempfile + from odoo.tests.common import TransactionCase from odoo.tools.misc import file_open +DATA_DIR = 'account_bank_statement_import_camt/test_files/' + + +class TestParser(TransactionCase): + """Tests for the camt parser itself.""" + def setUp(self): + super(TestParser, self).setUp() + self.parser = self.env['account.bank.statement.import.camt.parser'] + + def _do_parse_test(self, inputfile, goldenfile): + with file_open(inputfile) as testfile: + data = testfile.read() + res = self.parser.parse(data) + with tempfile.NamedTemporaryFile(suffix='.pydata') as temp: + pprint.pprint(res, temp) + with file_open(goldenfile) as golden: + temp.seek(0) + diff = list( + difflib.unified_diff(golden.readlines(), temp.readlines(), + golden.name, temp.name)) + if len(diff) > 2: + self.fail( + "actual output doesn't match exptected output:\n%s" % + "".join(diff)) + + def test_parse(self): + self._do_parse_test( + DATA_DIR + 'test-camt053', + DATA_DIR + 'golden-camt053.pydata') + + def test_parse_txdtls(self): + self._do_parse_test( + DATA_DIR + 'test-camt053-txdtls', + DATA_DIR + 'golden-camt053-txdtls.pydata') + + class TestImport(TransactionCase): """Run test to import camt import.""" transactions = [ @@ -36,9 +77,7 @@ class TestImport(TransactionCase): def test_statement_import(self): """Test correct creation of single statement.""" action = {} - with file_open( - 'account_bank_statement_import_camt/test_files/test-camt053' - ) as testfile: + with file_open(DATA_DIR + 'test-camt053') as testfile: action = self.env['account.bank.statement.import'].create({ 'data_file': base64.b64encode(testfile.read()), }).import_file() From 4a6a517dead65928523d2ff62d6cb86211ca7705 Mon Sep 17 00:00:00 2001 From: eLBati Date: Tue, 20 Feb 2018 12:41:56 +0100 Subject: [PATCH 23/28] FIX account_bank_statement_import_camt error message and comment --- account_bank_statement_import_camt/models/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index fedc386c..c6b75e3c 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -232,14 +232,14 @@ class CamtParser(models.AbstractModel): r'|^ISO:camt.052.)' ) if not re_camt_version.search(ns): - raise ValueError('no camt 052 or 053: ' + ns) + raise ValueError('no camt 052 or 053 or 054: ' + ns) # Check GrpHdr element: root_0_0 = root[0][0].tag[len(ns) + 2:] # strip namespace if root_0_0 != 'GrpHdr': raise ValueError('expected GrpHdr, got: ' + root_0_0) def parse(self, data): - """Parse a camt.052 or camt.053 file.""" + """Parse a camt.052 or camt.053 or camt.054 file.""" try: root = etree.fromstring( data, parser=etree.XMLParser(recover=True)) From 0a97650ce93b69bf6b253cf3c33ca7b0b1832540 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 20 Feb 2018 10:05:40 +0100 Subject: [PATCH 24/28] camt: remove dead code Fix warning account.bank.statement.line.create() includes unknown fields: data, execution_date, transfer_type, value_date --- .../models/parser.py | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index c6b75e3c..c98e7155 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -83,14 +83,6 @@ class CamtParser(models.AbstractModel): if party_node: self.add_value_from_node( ns, party_node[0], './ns:Nm', transaction, 'partner_name') - self.add_value_from_node( - ns, party_node[0], './ns:PstlAdr/ns:Ctry', transaction, - 'partner_country' - ) - address_node = party_node[0].xpath( - './ns:PstlAdr/ns:AdrLine', namespaces={'ns': ns}) - if address_node: - transaction['partner_address'] = [address_node[0].text] # Get remote_account from iban or from domestic account: account_node = node.xpath( './ns:RltdPties/ns:%sAcct/ns:Id' % party_type, @@ -101,32 +93,17 @@ class CamtParser(models.AbstractModel): './ns:IBAN', namespaces={'ns': ns}) if iban_node: transaction['account_number'] = iban_node[0].text - bic_node = node.xpath( - './ns:RltdAgts/ns:%sAgt/ns:FinInstnId/ns:BIC' % party_type, - namespaces={'ns': ns} - ) - if bic_node: - transaction['account_bic'] = bic_node[0].text else: self.add_value_from_node( ns, account_node[0], './ns:Othr/ns:Id', transaction, 'account_number' ) - transaction['data'] = etree.tostring(node) def parse_entry(self, ns, node): """Parse an Ntry node and yield transactions""" transaction = {'name': '/', 'amount': 0} # fallback defaults - self.add_value_from_node( - ns, node, './ns:BkTxCd/ns:Prtry/ns:Cd', transaction, - 'transfer_type' - ) self.add_value_from_node( ns, node, './ns:BookgDt/ns:Dt', transaction, 'date') - self.add_value_from_node( - ns, node, './ns:BookgDt/ns:Dt', transaction, 'execution_date') - self.add_value_from_node( - ns, node, './ns:ValDt/ns:Dt', transaction, 'value_date') amount = self.parse_amount(ns, node) if amount != 0.0: transaction['amount'] = amount @@ -196,8 +173,6 @@ class CamtParser(models.AbstractModel): ) self.add_value_from_node( ns, node, './ns:Id', result, 'name') - self.add_value_from_node( - ns, node, './ns:Dt', result, 'date') self.add_value_from_node( ns, node, './ns:Acct/ns:Ccy', result, 'currency') result['balance_start'], result['balance_end_real'] = ( From 300d133e6d02a560d361d1d1edd1294148343bf1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 20 Feb 2018 17:54:55 +0100 Subject: [PATCH 25/28] Remove dead fields from unittests --- .../test_files/golden-camt053-txdtls.pydata | 12 ++------ .../test_files/golden-camt053.pydata | 30 ++++--------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata index f641bfbf..7d1755f4 100644 --- a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata +++ b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata @@ -6,21 +6,13 @@ 'name': '20170323123456789012345', 'transactions': [{'account_number': 'CH2222000000123456789', 'amount': 2187.0, - 'data': '\n \n 123456CHCAFEBABE\n \n 01\n 123456CHCAFEBABE\n \n \n 2187.00\n CRDT\n \n \n PMNT\n \n RCDT\n AUTT\n \n \n \n \n \n Banque Cantonale Vaudoise\n \n Place Saint-François\n 14\n 1003\n Lausanne\n CH1\n \n \n \n \n CH2222000000123456789\n \n \n \n \n \n \n POFICHBEXXX\n POSTFINANCE AG\n \n MINGERSTRASSE 20\n 3030 BERNE\n \n \n \n \n \n \n \n \n \n ISR Reference\n \n \n 302388292000011111111111111\n \n ?REJECT?0\n \n \n \n 2017-03-22T20:00:00\n \n \n ', 'date': '2017-03-22', - 'execution_date': '2017-03-22', 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', - 'partner_country': 'CH1', 'partner_name': 'Banque Cantonale Vaudoise', - 'ref': '302388292000011111111111111', - 'value_date': '2017-03-23'}, + 'ref': '302388292000011111111111111'}, {'account_number': 'CH3333000000123456789', 'amount': 1296.0, - 'data': '\n \n 123456CHCAFEBABE\n \n 01\n 123456CHCAFEBABE\n \n \n 1296.00\n CRDT\n \n \n PMNT\n \n RCDT\n AUTT\n \n \n \n \n \n Banque Cantonale Vaudoise\n \n Place Saint-François\n 14\n 1003\n Lausanne\n CH2\n \n \n \n \n CH3333000000123456789\n \n \n \n \n \n \n POFICHBEYYY\n POSTFINANCE AG\n \n MINGERSTRASSE 20\n 3030 BERNE\n \n \n \n \n \n \n \n \n \n ISR Reference\n \n \n 302388292000022222222222222\n \n ?REJECT?0\n \n \n \n 2017-03-22T20:00:00\n \n \n ', 'date': '2017-03-22', - 'execution_date': '2017-03-22', 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', - 'partner_country': 'CH2', 'partner_name': 'Banque Cantonale Vaudoise', - 'ref': '302388292000022222222222222', - 'value_date': '2017-03-23'}]}]) + 'ref': '302388292000022222222222222'}]}]) diff --git a/account_bank_statement_import_camt/test_files/golden-camt053.pydata b/account_bank_statement_import_camt/test_files/golden-camt053.pydata index da29c8da..ba7cb951 100644 --- a/account_bank_statement_import_camt/test_files/golden-camt053.pydata +++ b/account_bank_statement_import_camt/test_files/golden-camt053.pydata @@ -4,42 +4,24 @@ 'balance_start': 15568.27, 'date': '2014-01-05', 'name': '1234Test/1', - 'transactions': [{'account_bic': 'ABNANL2A', - 'account_number': 'NL46ABNA0499998748', + 'transactions': [{'account_number': 'NL46ABNA0499998748', 'amount': -754.25, - 'data': '\n \n INNDNL2U20141231000142300002844\n 435005714488-ABNO33052620\n 1880000341866\n \n \n \n 754.25\n \n \n \n \n INSURANCE COMPANY TESTX\n \n TEST STREET 20\n 1234 AB TESTCITY\n NL\n \n \n \n \n NL46ABNA0499998748\n \n \n \n \n \n \n ABNANL2A\n \n \n \n \n Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014\n \n MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014\n \n ', 'date': '2014-01-05', - 'execution_date': '2014-01-05', 'name': 'MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014', 'note': 'Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014', - 'partner_country': 'NL', 'partner_name': 'INSURANCE COMPANY TESTX', - 'ref': '435005714488-ABNO33052620', - 'transfer_type': 'EI', - 'value_date': '2014-01-05'}, - {'account_bic': 'ABNANL2A', - 'account_number': 'NL46ABNA0499998748', + 'ref': '435005714488-ABNO33052620'}, + {'account_number': 'NL46ABNA0499998748', 'amount': -594.05, - 'data': '\n \n TESTBANK/NL/20141229/01206408\n TESTBANK/NL/20141229/01206408\n NL22ZZZ524885430000-C0125.1\n \n \n \n 564.05\n \n \n \n \n Test Customer\n \n NL\n \n \n \n \n NL46ABNA0499998748\n \n \n \n \n \n \n ABNANL2A\n \n \n \n \n Direct Debit S14 0410\n \n \n \n AC06\n \n \n Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408\n \n ', 'date': '2014-01-05', - 'execution_date': '2014-01-05', 'name': 'Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408', 'note': 'Direct Debit S14 0410', - 'partner_country': 'NL', 'partner_name': 'Test Customer', - 'ref': 'TESTBANK/NL/20141229/01206408', - 'transfer_type': 'EIST', - 'value_date': '2014-01-05'}, - {'account_bic': 'ABNANL2A', - 'account_number': 'NL69ABNA0522123643', + 'ref': 'TESTBANK/NL/20141229/01206408'}, + {'account_number': 'NL69ABNA0522123643', 'amount': 1405.31, - 'data': '\n \n INNDNL2U20140105000217200000708\n 115\n \n \n \n 1405.31\n \n \n \n \n 3rd party Media\n \n SOMESTREET 570-A\n 1276 ML HOUSCITY\n NL\n \n \n \n \n NL69ABNA0522123643\n \n \n \n \n \n \n ABNANL2A\n \n \n \n #RD PARTY MEDIA CUSNO 90782 4210773\n \n ', 'date': '2014-01-05', - 'execution_date': '2014-01-05', 'name': '#RD PARTY MEDIA CUSNO 90782 4210773', 'note': 'INNDNL2U20140105000217200000708', - 'partner_country': 'NL', 'partner_name': '3rd party Media', - 'ref': '115', - 'transfer_type': 'ET', - 'value_date': '2014-01-05'}]}]) + 'ref': '115'}]}]) From 433f8240abd5cef2a4be034fb525905d894d06ac Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 24 Feb 2018 05:01:52 +0100 Subject: [PATCH 26/28] OCA Transbot updated translations from Transifex --- account_bank_statement_import_camt/i18n/es.po | 13 ++--- account_bank_statement_import_camt/i18n/hr.po | 54 +++++++++++++++++++ 2 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 account_bank_statement_import_camt/i18n/hr.po diff --git a/account_bank_statement_import_camt/i18n/es.po b/account_bank_statement_import_camt/i18n/es.po index c198351c..b5f508d0 100644 --- a/account_bank_statement_import_camt/i18n/es.po +++ b/account_bank_statement_import_camt/i18n/es.po @@ -4,13 +4,14 @@ # # Translators: # OCA Transbot , 2017 +# enjolras , 2018 msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-11-21 01:42+0000\n" -"PO-Revision-Date: 2017-11-21 01:42+0000\n" -"Last-Translator: OCA Transbot , 2017\n" +"POT-Creation-Date: 2018-02-21 01:41+0000\n" +"PO-Revision-Date: 2018-02-21 01:41+0000\n" +"Last-Translator: enjolras , 2018\n" "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -21,7 +22,7 @@ msgstr "" #. module: account_bank_statement_import_camt #: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view msgid "CAMT" -msgstr "" +msgstr "CAMT" #. module: account_bank_statement_import_camt #: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_display_name @@ -46,9 +47,9 @@ msgstr "Última modificación en" #. module: account_bank_statement_import_camt #: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import_camt_parser msgid "account.bank.statement.import.camt.parser" -msgstr "" +msgstr "account.bank.statement.import.camt.parser" #. module: account_bank_statement_import_camt #: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view msgid "zipped CAMT" -msgstr "" +msgstr "CAMT en .zip" diff --git a/account_bank_statement_import_camt/i18n/hr.po b/account_bank_statement_import_camt/i18n/hr.po new file mode 100644 index 00000000..967d3a9a --- /dev/null +++ b/account_bank_statement_import_camt/i18n/hr.po @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_bank_statement_import_camt +# +# Translators: +# Bole , 2018 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-02-21 01:41+0000\n" +"PO-Revision-Date: 2018-02-21 01:41+0000\n" +"Last-Translator: Bole , 2018\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: hr\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "CAMT" +msgstr "CAMT" + +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_display_name +msgid "Display Name" +msgstr "Naziv" + +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_id +msgid "ID" +msgstr "ID" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +msgid "Import Bank Statement" +msgstr "Uvoz bankovnog izvoda" + +#. module: account_bank_statement_import_camt +#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser___last_update +msgid "Last Modified on" +msgstr "Zadnje modificirano" + +#. module: account_bank_statement_import_camt +#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import_camt_parser +msgid "account.bank.statement.import.camt.parser" +msgstr "account.bank.statement.import.camt.parser" + +#. module: account_bank_statement_import_camt +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +msgid "zipped CAMT" +msgstr "kompresirani CAMT" From 8c038807fc4e65b3c6b332f1a556385a1b54f55f Mon Sep 17 00:00:00 2001 From: Maxence Groine Date: Fri, 1 Jun 2018 14:31:27 +0200 Subject: [PATCH 27/28] [11.0][MIG] account_bank_statement_import_camt --- account_bank_statement_import_camt/README.rst | 20 +++--- .../__init__.py | 1 - .../__manifest__.py | 3 +- .../models/__init__.py | 1 - .../models/account_bank_statement_import.py | 5 +- .../models/parser.py | 7 +- .../test_files/golden-camt053-txdtls.pydata | 4 +- .../tests/__init__.py | 1 - .../tests/test_import_bank_statement.py | 72 ++++++++++++------- 9 files changed, 65 insertions(+), 49 deletions(-) diff --git a/account_bank_statement_import_camt/README.rst b/account_bank_statement_import_camt/README.rst index 92aaeaa5..327bd473 100644 --- a/account_bank_statement_import_camt/README.rst +++ b/account_bank_statement_import_camt/README.rst @@ -1,6 +1,8 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: https://www.gnu.com/licenses/agpl :alt: License: AGPL-3 +========================= Bank Statement Parse Camt ========================= @@ -8,18 +10,16 @@ Module to import SEPA CAMT.053 and CAMT.054 Format bank statement files. Based on the Banking addons framework. -Known issues / Roadmap -====================== +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/174/11.0 -* None Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. +In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smash it by providing a detailed and welcomed feedback. Credits @@ -31,6 +31,10 @@ Contributors * Holger Brunn * Stefan Rijnhart * Ronald Portier +* Andrea Stirpe +* Maxence Groine + +Do not contact contributors directly about support or help with technical issues. Maintainer ---------- @@ -46,5 +50,3 @@ mission is to support the collaborative development of Odoo features and promote its widespread use. To contribute to this module, please visit http://odoo-community.org. -This module should make it easy to migrate bank statement import -modules written for earlies versions of Odoo/OpenERP. diff --git a/account_bank_statement_import_camt/__init__.py b/account_bank_statement_import_camt/__init__.py index 1eb5270e..867022b6 100644 --- a/account_bank_statement_import_camt/__init__.py +++ b/account_bank_statement_import_camt/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt/__manifest__.py index 1a4d5122..f2ca11ab 100644 --- a/account_bank_statement_import_camt/__manifest__.py +++ b/account_bank_statement_import_camt/__manifest__.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- # © 2013-2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'CAMT Format Bank Statements Import', - 'version': '10.0.1.1.1', + 'version': '11.0.1.0.0', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Therp BV', 'website': 'https://github.com/OCA/bank-statement-import', diff --git a/account_bank_statement_import_camt/models/__init__.py b/account_bank_statement_import_camt/models/__init__.py index 0251c8f1..8b7d2c68 100644 --- a/account_bank_statement_import_camt/models/__init__.py +++ b/account_bank_statement_import_camt/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import parser diff --git a/account_bank_statement_import_camt/models/account_bank_statement_import.py b/account_bank_statement_import_camt/models/account_bank_statement_import.py index 4490f167..27b26afc 100644 --- a/account_bank_statement_import_camt/models/account_bank_statement_import.py +++ b/account_bank_statement_import_camt/models/account_bank_statement_import.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- """Add process_camt method to account.bank.statement.import.""" # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import logging -import StringIO +from io import BytesIO import zipfile from odoo import api, models @@ -23,7 +22,7 @@ class AccountBankStatementImport(models.TransientModel): return parser.parse(data_file) except ValueError: try: - with zipfile.ZipFile(StringIO.StringIO(data_file)) as data: + with zipfile.ZipFile(BytesIO(data_file)) as data: currency = None account_number = None transactions = [] diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt/models/parser.py index c98e7155..06684224 100644 --- a/account_bank_statement_import_camt/models/parser.py +++ b/account_bank_statement_import_camt/models/parser.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Class to parse camt files.""" # © 2013-2016 Therp BV # Copyright 2017 Open Net Sàrl @@ -10,8 +9,8 @@ from odoo import models class CamtParser(models.AbstractModel): - _name = 'account.bank.statement.import.camt.parser' """Parser for camt bank statement import files.""" + _name = 'account.bank.statement.import.camt.parser' def parse_amount(self, ns, node): """Parse element that contains Amount and CreditDebitIndicator.""" @@ -190,14 +189,14 @@ class CamtParser(models.AbstractModel): def check_version(self, ns, root): """Validate validity of camt file.""" - # Check wether it is camt at all: + # Check whether it is camt at all: re_camt = re.compile( r'(^urn:iso:std:iso:20022:tech:xsd:camt.' r'|^ISO:camt.)' ) if not re_camt.search(ns): raise ValueError('no camt: ' + ns) - # Check wether version 052 ,053 or 054: + # Check whether version 052 ,053 or 054: re_camt_version = re.compile( r'(^urn:iso:std:iso:20022:tech:xsd:camt.054.' r'|^urn:iso:std:iso:20022:tech:xsd:camt.053.' diff --git a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata index 7d1755f4..9b73d97f 100644 --- a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata +++ b/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata @@ -7,12 +7,12 @@ 'transactions': [{'account_number': 'CH2222000000123456789', 'amount': 2187.0, 'date': '2017-03-22', - 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', + 'name': 'CRÉDIT GROUPÉ BVR TRAITEMENT DU 22.03.2017 NUMÉRO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', 'partner_name': 'Banque Cantonale Vaudoise', 'ref': '302388292000011111111111111'}, {'account_number': 'CH3333000000123456789', 'amount': 1296.0, 'date': '2017-03-22', - 'name': u'CR\xc9DIT GROUP\xc9 BVR TRAITEMENT DU 22.03.2017 NUM\xc9RO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', + 'name': 'CRÉDIT GROUPÉ BVR TRAITEMENT DU 22.03.2017 NUMÉRO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE', 'partner_name': 'Banque Cantonale Vaudoise', 'ref': '302388292000022222222222222'}]}]) diff --git a/account_bank_statement_import_camt/tests/__init__.py b/account_bank_statement_import_camt/tests/__init__.py index 06d3af2f..5198b77d 100644 --- a/account_bank_statement_import_camt/tests/__init__.py +++ b/account_bank_statement_import_camt/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- """Test import of bank statement for camt.053.""" # © 2013-2016 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py index 840f005b..07c2de8a 100644 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ b/account_bank_statement_import_camt/tests/test_import_bank_statement.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Run test to import camt.053 import.""" # © 2013-2016 Therp BV # Copyright 2017 Open Net Sàrl @@ -8,11 +7,10 @@ import difflib import pprint import tempfile +from io import StringIO + from odoo.tests.common import TransactionCase -from odoo.tools.misc import file_open - - -DATA_DIR = 'account_bank_statement_import_camt/test_files/' +from odoo.modules.module import get_module_resource class TestParser(TransactionCase): @@ -22,30 +20,41 @@ class TestParser(TransactionCase): self.parser = self.env['account.bank.statement.import.camt.parser'] def _do_parse_test(self, inputfile, goldenfile): - with file_open(inputfile) as testfile: - data = testfile.read() + print("\n\ninputfile = {} / goldenfile = {}".format(inputfile, goldenfile)) + testfile = get_module_resource( + 'account_bank_statement_import_camt', + 'test_files', + inputfile, + ) + data = open(testfile, 'rb').read() res = self.parser.parse(data) - with tempfile.NamedTemporaryFile(suffix='.pydata') as temp: - pprint.pprint(res, temp) - with file_open(goldenfile) as golden: + with tempfile.NamedTemporaryFile(mode='w+', suffix='.pydata') as temp: + import ipdb; ipdb.set_trace(context=10) + pprint.pprint(res, temp, width=160) + goldenfile_res = get_module_resource( + 'account_bank_statement_import_camt', + 'test_files', + goldenfile, + ) + with open(goldenfile_res, 'r') as golden: temp.seek(0) diff = list( difflib.unified_diff(golden.readlines(), temp.readlines(), golden.name, temp.name)) if len(diff) > 2: self.fail( - "actual output doesn't match exptected output:\n%s" % + "actual output doesn't match expected output:\n%s" % "".join(diff)) def test_parse(self): self._do_parse_test( - DATA_DIR + 'test-camt053', - DATA_DIR + 'golden-camt053.pydata') + 'test-camt053', + 'golden-camt053.pydata') def test_parse_txdtls(self): self._do_parse_test( - DATA_DIR + 'test-camt053-txdtls', - DATA_DIR + 'golden-camt053-txdtls.pydata') + 'test-camt053-txdtls', + 'golden-camt053-txdtls.pydata') class TestImport(TransactionCase): @@ -76,11 +85,17 @@ class TestImport(TransactionCase): def test_statement_import(self): """Test correct creation of single statement.""" - action = {} - with file_open(DATA_DIR + 'test-camt053') as testfile: - action = self.env['account.bank.statement.import'].create({ - 'data_file': base64.b64encode(testfile.read()), - }).import_file() + testfile = get_module_resource( + 'account_bank_statement_import_camt', + 'test_files', + 'test-camt053', + ) + datafile = open(testfile, 'rb').read() + + action = self.env['account.bank.statement.import'].create({ + 'data_file': base64.b64encode(datafile) + }).import_file() + for statement in self.env['account.bank.statement'].browse( action['context']['statement_ids'] ): @@ -96,12 +111,17 @@ class TestImport(TransactionCase): def test_zip_import(self): """Test import of multiple statements from zip file.""" - with file_open( - 'account_bank_statement_import_camt/test_files/test-camt053.zip' - ) as testfile: - action = self.env['account.bank.statement.import'].create({ - 'data_file': base64.b64encode(testfile.read()), - }).import_file() + testfile = get_module_resource( + 'account_bank_statement_import_camt', + 'test_files', + 'test-camt053.zip', + ) + datafile = open(testfile, 'rb').read() + + action = self.env['account.bank.statement.import'].create({ + 'data_file': base64.b64encode(datafile), + }).import_file() + for statement in self.env['account.bank.statement'].browse( action['context']['statement_ids'] ): From cc37448d5ddfff2c2858896b037870f9914464de Mon Sep 17 00:00:00 2001 From: Maxence Groine Date: Fri, 1 Jun 2018 15:10:44 +0200 Subject: [PATCH 28/28] Rename module Also: - Use context managers for file opening/closing in tests - Changed use of deprecated `BadZipfile` exception - Removed debugging code left by mistake --- .../tests/test_import_bank_statement.py | 128 ------------------ .../README.rst | 0 .../__init__.py | 0 .../__manifest__.py | 0 .../i18n/de.po | 6 +- .../i18n/es.po | 32 ++--- .../i18n/fi.po | 16 +-- .../i18n/fr.po | 32 ++--- .../i18n/fr_CH.po | 16 +-- .../i18n/gl.po | 16 +-- .../i18n/hr.po | 32 ++--- .../i18n/lt_LT.po | 8 +- .../i18n/nb_NO.po | 16 +-- .../i18n/nl.po | 8 +- .../i18n/pt_BR.po | 8 +- .../i18n/pt_PT.po | 8 +- .../i18n/sl.po | 8 +- .../models/__init__.py | 0 .../models/account_bank_statement_import.py | 2 +- .../models/parser.py | 0 .../test_files/golden-camt053-txdtls.pydata | 0 .../test_files/golden-camt053.pydata | 0 .../test_files/test-camt053 | 0 .../test_files/test-camt053-txdtls | 0 .../test_files/test-camt053.zip | Bin .../tests/__init__.py | 0 .../tests/test_import_bank_statement.py | 127 +++++++++++++++++ .../views/account_bank_statement_import.xml | 0 28 files changed, 231 insertions(+), 232 deletions(-) delete mode 100644 account_bank_statement_import_camt/tests/test_import_bank_statement.py rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/README.rst (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/__init__.py (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/__manifest__.py (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/de.po (78%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/es.po (54%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/fi.po (60%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/fr.po (53%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/fr_CH.po (60%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/gl.po (60%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/hr.po (53%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/lt_LT.po (79%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/nb_NO.po (61%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/nl.po (79%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/pt_BR.po (78%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/pt_PT.po (77%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/i18n/sl.po (79%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/models/__init__.py (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/models/account_bank_statement_import.py (96%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/models/parser.py (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/test_files/golden-camt053-txdtls.pydata (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/test_files/golden-camt053.pydata (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/test_files/test-camt053 (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/test_files/test-camt053-txdtls (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/test_files/test-camt053.zip (100%) rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/tests/__init__.py (100%) create mode 100644 account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py rename {account_bank_statement_import_camt => account_bank_statement_import_camt_oca}/views/account_bank_statement_import.xml (100%) diff --git a/account_bank_statement_import_camt/tests/test_import_bank_statement.py b/account_bank_statement_import_camt/tests/test_import_bank_statement.py deleted file mode 100644 index 07c2de8a..00000000 --- a/account_bank_statement_import_camt/tests/test_import_bank_statement.py +++ /dev/null @@ -1,128 +0,0 @@ -"""Run test to import camt.053 import.""" -# © 2013-2016 Therp BV -# Copyright 2017 Open Net Sàrl -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -import base64 -import difflib -import pprint -import tempfile - -from io import StringIO - -from odoo.tests.common import TransactionCase -from odoo.modules.module import get_module_resource - - -class TestParser(TransactionCase): - """Tests for the camt parser itself.""" - def setUp(self): - super(TestParser, self).setUp() - self.parser = self.env['account.bank.statement.import.camt.parser'] - - def _do_parse_test(self, inputfile, goldenfile): - print("\n\ninputfile = {} / goldenfile = {}".format(inputfile, goldenfile)) - testfile = get_module_resource( - 'account_bank_statement_import_camt', - 'test_files', - inputfile, - ) - data = open(testfile, 'rb').read() - res = self.parser.parse(data) - with tempfile.NamedTemporaryFile(mode='w+', suffix='.pydata') as temp: - import ipdb; ipdb.set_trace(context=10) - pprint.pprint(res, temp, width=160) - goldenfile_res = get_module_resource( - 'account_bank_statement_import_camt', - 'test_files', - goldenfile, - ) - with open(goldenfile_res, 'r') as golden: - temp.seek(0) - diff = list( - difflib.unified_diff(golden.readlines(), temp.readlines(), - golden.name, temp.name)) - if len(diff) > 2: - self.fail( - "actual output doesn't match expected output:\n%s" % - "".join(diff)) - - def test_parse(self): - self._do_parse_test( - 'test-camt053', - 'golden-camt053.pydata') - - def test_parse_txdtls(self): - self._do_parse_test( - 'test-camt053-txdtls', - 'golden-camt053-txdtls.pydata') - - -class TestImport(TransactionCase): - """Run test to import camt import.""" - transactions = [ - { - 'account_number': 'NL46ABNA0499998748', - 'amount': -754.25, - 'date': '2014-01-05', - 'ref': '435005714488-ABNO33052620', - }, - ] - - def setUp(self): - super(TestImport, self).setUp() - bank = self.env['res.partner.bank'].create({ - 'acc_number': 'NL77ABNA0574908765', - 'partner_id': self.env.ref('base.main_partner').id, - 'company_id': self.env.ref('base.main_company').id, - 'bank_id': self.env.ref('base.res_bank_1').id, - }) - self.env['account.journal'].create({ - 'name': 'Bank Journal - (test camt)', - 'code': 'TBNKCAMT', - 'type': 'bank', - 'bank_account_id': bank.id, - }) - - def test_statement_import(self): - """Test correct creation of single statement.""" - testfile = get_module_resource( - 'account_bank_statement_import_camt', - 'test_files', - 'test-camt053', - ) - datafile = open(testfile, 'rb').read() - - action = self.env['account.bank.statement.import'].create({ - 'data_file': base64.b64encode(datafile) - }).import_file() - - for statement in self.env['account.bank.statement'].browse( - action['context']['statement_ids'] - ): - self.assertTrue(any( - all( - line[key] == self.transactions[0][key] - for key in ['amount', 'date', 'ref'] - ) and - line.bank_account_id.acc_number == - self.transactions[0]['account_number'] - for line in statement.line_ids - )) - - def test_zip_import(self): - """Test import of multiple statements from zip file.""" - testfile = get_module_resource( - 'account_bank_statement_import_camt', - 'test_files', - 'test-camt053.zip', - ) - datafile = open(testfile, 'rb').read() - - action = self.env['account.bank.statement.import'].create({ - 'data_file': base64.b64encode(datafile), - }).import_file() - - for statement in self.env['account.bank.statement'].browse( - action['context']['statement_ids'] - ): - self.assertTrue(statement.line_ids) diff --git a/account_bank_statement_import_camt/README.rst b/account_bank_statement_import_camt_oca/README.rst similarity index 100% rename from account_bank_statement_import_camt/README.rst rename to account_bank_statement_import_camt_oca/README.rst diff --git a/account_bank_statement_import_camt/__init__.py b/account_bank_statement_import_camt_oca/__init__.py similarity index 100% rename from account_bank_statement_import_camt/__init__.py rename to account_bank_statement_import_camt_oca/__init__.py diff --git a/account_bank_statement_import_camt/__manifest__.py b/account_bank_statement_import_camt_oca/__manifest__.py similarity index 100% rename from account_bank_statement_import_camt/__manifest__.py rename to account_bank_statement_import_camt_oca/__manifest__.py diff --git a/account_bank_statement_import_camt/i18n/de.po b/account_bank_statement_import_camt_oca/i18n/de.po similarity index 78% rename from account_bank_statement_import_camt/i18n/de.po rename to account_bank_statement_import_camt_oca/i18n/de.po index b503264c..f4d4e715 100644 --- a/account_bank_statement_import_camt/i18n/de.po +++ b/account_bank_statement_import_camt_oca/i18n/de.po @@ -1,6 +1,6 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt +# * account_bank_statement_import_camt_oca # # Translators: msgid "" @@ -18,7 +18,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Generator: Poedit 1.8.3\n" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Kontoauszug importieren" diff --git a/account_bank_statement_import_camt/i18n/es.po b/account_bank_statement_import_camt_oca/i18n/es.po similarity index 54% rename from account_bank_statement_import_camt/i18n/es.po rename to account_bank_statement_import_camt_oca/i18n/es.po index b5f508d0..e56d7f80 100644 --- a/account_bank_statement_import_camt/i18n/es.po +++ b/account_bank_statement_import_camt_oca/i18n/es.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # OCA Transbot , 2017 # enjolras , 2018 @@ -19,37 +19,37 @@ msgstr "" "Language: es\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "CAMT" msgstr "CAMT" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_display_name +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser_display_name msgid "Display Name" msgstr "Nombre a mostrar" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_id +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser_id msgid "ID" msgstr "ID" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importar extracto bancario" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser___last_update +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser___last_update msgid "Last Modified on" msgstr "Última modificación en" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import_camt_parser +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import_camt_oca_parser msgid "account.bank.statement.import.camt.parser" msgstr "account.bank.statement.import.camt.parser" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "zipped CAMT" msgstr "CAMT en .zip" diff --git a/account_bank_statement_import_camt/i18n/fi.po b/account_bank_statement_import_camt_oca/i18n/fi.po similarity index 60% rename from account_bank_statement_import_camt/i18n/fi.po rename to account_bank_statement_import_camt_oca/i18n/fi.po index 09b901e0..f91f6c9e 100644 --- a/account_bank_statement_import_camt/i18n/fi.po +++ b/account_bank_statement_import_camt_oca/i18n/fi.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # Jarmo Kortetjärvi , 2017 msgid "" @@ -18,17 +18,17 @@ msgstr "" "Language: fi\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "CAMT" msgstr "" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Tuo pankkiaineisto" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "zipped CAMT" msgstr "" diff --git a/account_bank_statement_import_camt/i18n/fr.po b/account_bank_statement_import_camt_oca/i18n/fr.po similarity index 53% rename from account_bank_statement_import_camt/i18n/fr.po rename to account_bank_statement_import_camt_oca/i18n/fr.po index 96f6d639..11f802fe 100644 --- a/account_bank_statement_import_camt/i18n/fr.po +++ b/account_bank_statement_import_camt_oca/i18n/fr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # Quentin THEURET , 2017 # OCA Transbot , 2017 @@ -19,37 +19,37 @@ msgstr "" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "CAMT" msgstr "CAMT" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_display_name +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser_display_name msgid "Display Name" msgstr "Nom affiché" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_id +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser_id msgid "ID" msgstr "ID" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importer Relevé Bancaire" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser___last_update +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser___last_update msgid "Last Modified on" msgstr "Dernière modification le" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import_camt_parser +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import_camt_oca_parser msgid "account.bank.statement.import.camt.parser" msgstr "" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "zipped CAMT" msgstr "CAMT zippé" diff --git a/account_bank_statement_import_camt/i18n/fr_CH.po b/account_bank_statement_import_camt_oca/i18n/fr_CH.po similarity index 60% rename from account_bank_statement_import_camt/i18n/fr_CH.po rename to account_bank_statement_import_camt_oca/i18n/fr_CH.po index 3b8e8135..4a5d5877 100644 --- a/account_bank_statement_import_camt/i18n/fr_CH.po +++ b/account_bank_statement_import_camt_oca/i18n/fr_CH.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # OCA Transbot , 2016 msgid "" @@ -18,17 +18,17 @@ msgstr "" "Language: fr_CH\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "CAMT" msgstr "" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importer Relevé" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "zipped CAMT" msgstr "" diff --git a/account_bank_statement_import_camt/i18n/gl.po b/account_bank_statement_import_camt_oca/i18n/gl.po similarity index 60% rename from account_bank_statement_import_camt/i18n/gl.po rename to account_bank_statement_import_camt_oca/i18n/gl.po index 7ac52f60..b8d5ab46 100644 --- a/account_bank_statement_import_camt/i18n/gl.po +++ b/account_bank_statement_import_camt_oca/i18n/gl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # Alejandro Santana , 2016 msgid "" @@ -18,17 +18,17 @@ msgstr "" "Language: gl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "CAMT" msgstr "" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importar extracto bancario" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "zipped CAMT" msgstr "" diff --git a/account_bank_statement_import_camt/i18n/hr.po b/account_bank_statement_import_camt_oca/i18n/hr.po similarity index 53% rename from account_bank_statement_import_camt/i18n/hr.po rename to account_bank_statement_import_camt_oca/i18n/hr.po index 967d3a9a..b8d38f58 100644 --- a/account_bank_statement_import_camt/i18n/hr.po +++ b/account_bank_statement_import_camt_oca/i18n/hr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # Bole , 2018 msgid "" @@ -18,37 +18,37 @@ msgstr "" "Language: hr\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "CAMT" msgstr "CAMT" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_display_name +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser_display_name msgid "Display Name" msgstr "Naziv" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser_id +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser_id msgid "ID" msgstr "ID" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Uvoz bankovnog izvoda" -#. module: account_bank_statement_import_camt -#: model:ir.model.fields,field_description:account_bank_statement_import_camt.field_account_bank_statement_import_camt_parser___last_update +#. module: account_bank_statement_import_camt_oca +#: model:ir.model.fields,field_description:account_bank_statement_import_camt_oca.field_account_bank_statement_import_camt_oca_parser___last_update msgid "Last Modified on" msgstr "Zadnje modificirano" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import_camt_parser +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import_camt_oca_parser msgid "account.bank.statement.import.camt.parser" msgstr "account.bank.statement.import.camt.parser" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "zipped CAMT" msgstr "kompresirani CAMT" diff --git a/account_bank_statement_import_camt/i18n/lt_LT.po b/account_bank_statement_import_camt_oca/i18n/lt_LT.po similarity index 79% rename from account_bank_statement_import_camt/i18n/lt_LT.po rename to account_bank_statement_import_camt_oca/i18n/lt_LT.po index 7207693b..08209661 100644 --- a/account_bank_statement_import_camt/i18n/lt_LT.po +++ b/account_bank_statement_import_camt_oca/i18n/lt_LT.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: msgid "" msgstr "" @@ -17,7 +17,7 @@ msgstr "" "Language: lt_LT\n" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importuoti banko išrašą" diff --git a/account_bank_statement_import_camt/i18n/nb_NO.po b/account_bank_statement_import_camt_oca/i18n/nb_NO.po similarity index 61% rename from account_bank_statement_import_camt/i18n/nb_NO.po rename to account_bank_statement_import_camt_oca/i18n/nb_NO.po index 8b0659a3..ad504a09 100644 --- a/account_bank_statement_import_camt/i18n/nb_NO.po +++ b/account_bank_statement_import_camt_oca/i18n/nb_NO.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # Imre Kristoffer Eilertsen , 2016 msgid "" @@ -18,17 +18,17 @@ msgstr "" "Language: nb_NO\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "CAMT" msgstr "" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importer bankutsagn" -#. module: account_bank_statement_import_camt -#: model:ir.ui.view,arch_db:account_bank_statement_import_camt.account_bank_statement_import_view +#. module: account_bank_statement_import_camt_oca +#: model:ir.ui.view,arch_db:account_bank_statement_import_camt_oca.account_bank_statement_import_view msgid "zipped CAMT" msgstr "" diff --git a/account_bank_statement_import_camt/i18n/nl.po b/account_bank_statement_import_camt_oca/i18n/nl.po similarity index 79% rename from account_bank_statement_import_camt/i18n/nl.po rename to account_bank_statement_import_camt_oca/i18n/nl.po index 408e305e..fa6dec91 100644 --- a/account_bank_statement_import_camt/i18n/nl.po +++ b/account_bank_statement_import_camt_oca/i18n/nl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: # Erwin van der Ploeg , 2015 msgid "" @@ -18,7 +18,7 @@ msgstr "" "Language: nl\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importeer bankafschrift" diff --git a/account_bank_statement_import_camt/i18n/pt_BR.po b/account_bank_statement_import_camt_oca/i18n/pt_BR.po similarity index 78% rename from account_bank_statement_import_camt/i18n/pt_BR.po rename to account_bank_statement_import_camt_oca/i18n/pt_BR.po index a56eec56..c27fa00a 100644 --- a/account_bank_statement_import_camt/i18n/pt_BR.po +++ b/account_bank_statement_import_camt_oca/i18n/pt_BR.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: msgid "" msgstr "" @@ -17,7 +17,7 @@ msgstr "" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importar Extrato Bancário" diff --git a/account_bank_statement_import_camt/i18n/pt_PT.po b/account_bank_statement_import_camt_oca/i18n/pt_PT.po similarity index 77% rename from account_bank_statement_import_camt/i18n/pt_PT.po rename to account_bank_statement_import_camt_oca/i18n/pt_PT.po index 7b0f8e8d..62f2b779 100644 --- a/account_bank_statement_import_camt/i18n/pt_PT.po +++ b/account_bank_statement_import_camt_oca/i18n/pt_PT.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: msgid "" msgstr "" @@ -17,7 +17,7 @@ msgstr "" "Language: pt_PT\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Importar Extrato Bancário" diff --git a/account_bank_statement_import_camt/i18n/sl.po b/account_bank_statement_import_camt_oca/i18n/sl.po similarity index 79% rename from account_bank_statement_import_camt/i18n/sl.po rename to account_bank_statement_import_camt_oca/i18n/sl.po index 4aa623da..fe1211d0 100644 --- a/account_bank_statement_import_camt/i18n/sl.po +++ b/account_bank_statement_import_camt_oca/i18n/sl.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_bank_statement_import_camt -# +# * account_bank_statement_import_camt_oca +# # Translators: msgid "" msgstr "" @@ -17,7 +17,7 @@ msgstr "" "Language: sl\n" "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" -#. module: account_bank_statement_import_camt -#: model:ir.model,name:account_bank_statement_import_camt.model_account_bank_statement_import +#. module: account_bank_statement_import_camt_oca +#: model:ir.model,name:account_bank_statement_import_camt_oca.model_account_bank_statement_import msgid "Import Bank Statement" msgstr "Uvoz bančnega izpiska" diff --git a/account_bank_statement_import_camt/models/__init__.py b/account_bank_statement_import_camt_oca/models/__init__.py similarity index 100% rename from account_bank_statement_import_camt/models/__init__.py rename to account_bank_statement_import_camt_oca/models/__init__.py diff --git a/account_bank_statement_import_camt/models/account_bank_statement_import.py b/account_bank_statement_import_camt_oca/models/account_bank_statement_import.py similarity index 96% rename from account_bank_statement_import_camt/models/account_bank_statement_import.py rename to account_bank_statement_import_camt_oca/models/account_bank_statement_import.py index 27b26afc..f3ec1a5d 100644 --- a/account_bank_statement_import_camt/models/account_bank_statement_import.py +++ b/account_bank_statement_import_camt_oca/models/account_bank_statement_import.py @@ -32,7 +32,7 @@ class AccountBankStatementImport(models.TransientModel): ) transactions.extend(new) return currency, account_number, transactions - except (zipfile.BadZipfile, ValueError): + except (zipfile.BadZipFile, ValueError): pass # Not a camt file, returning super will call next candidate: _logger.debug("Statement file was not a camt file.", diff --git a/account_bank_statement_import_camt/models/parser.py b/account_bank_statement_import_camt_oca/models/parser.py similarity index 100% rename from account_bank_statement_import_camt/models/parser.py rename to account_bank_statement_import_camt_oca/models/parser.py diff --git a/account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata b/account_bank_statement_import_camt_oca/test_files/golden-camt053-txdtls.pydata similarity index 100% rename from account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata rename to account_bank_statement_import_camt_oca/test_files/golden-camt053-txdtls.pydata diff --git a/account_bank_statement_import_camt/test_files/golden-camt053.pydata b/account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata similarity index 100% rename from account_bank_statement_import_camt/test_files/golden-camt053.pydata rename to account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata diff --git a/account_bank_statement_import_camt/test_files/test-camt053 b/account_bank_statement_import_camt_oca/test_files/test-camt053 similarity index 100% rename from account_bank_statement_import_camt/test_files/test-camt053 rename to account_bank_statement_import_camt_oca/test_files/test-camt053 diff --git a/account_bank_statement_import_camt/test_files/test-camt053-txdtls b/account_bank_statement_import_camt_oca/test_files/test-camt053-txdtls similarity index 100% rename from account_bank_statement_import_camt/test_files/test-camt053-txdtls rename to account_bank_statement_import_camt_oca/test_files/test-camt053-txdtls diff --git a/account_bank_statement_import_camt/test_files/test-camt053.zip b/account_bank_statement_import_camt_oca/test_files/test-camt053.zip similarity index 100% rename from account_bank_statement_import_camt/test_files/test-camt053.zip rename to account_bank_statement_import_camt_oca/test_files/test-camt053.zip diff --git a/account_bank_statement_import_camt/tests/__init__.py b/account_bank_statement_import_camt_oca/tests/__init__.py similarity index 100% rename from account_bank_statement_import_camt/tests/__init__.py rename to account_bank_statement_import_camt_oca/tests/__init__.py diff --git a/account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py b/account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py new file mode 100644 index 00000000..d96b051d --- /dev/null +++ b/account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py @@ -0,0 +1,127 @@ +"""Run test to import camt.053 import.""" +# © 2013-2016 Therp BV +# Copyright 2017 Open Net Sàrl +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +import base64 +import difflib +import pprint +import tempfile + + +from odoo.tests.common import TransactionCase +from odoo.modules.module import get_module_resource + + +class TestParser(TransactionCase): + """Tests for the camt parser itself.""" + def setUp(self): + super(TestParser, self).setUp() + self.parser = self.env['account.bank.statement.import.camt.parser'] + + def _do_parse_test(self, inputfile, goldenfile): + testfile = get_module_resource( + 'account_bank_statement_import_camt_oca', + 'test_files', + inputfile, + ) + with open(testfile, 'rb') as data: + res = self.parser.parse(data.read()) + with tempfile.NamedTemporaryFile(mode='w+', + suffix='.pydata') as temp: + pprint.pprint(res, temp, width=160) + goldenfile_res = get_module_resource( + 'account_bank_statement_import_camt_oca', + 'test_files', + goldenfile, + ) + with open(goldenfile_res, 'r') as golden: + temp.seek(0) + diff = list( + difflib.unified_diff(golden.readlines(), + temp.readlines(), + golden.name, + temp.name)) + if len(diff) > 2: + self.fail( + "actual output doesn't match expected " + + "output:\n%s" % + "".join(diff)) + + def test_parse(self): + self._do_parse_test( + 'test-camt053', + 'golden-camt053.pydata') + + def test_parse_txdtls(self): + self._do_parse_test( + 'test-camt053-txdtls', + 'golden-camt053-txdtls.pydata') + + +class TestImport(TransactionCase): + """Run test to import camt import.""" + transactions = [ + { + 'account_number': 'NL46ABNA0499998748', + 'amount': -754.25, + 'date': '2014-01-05', + 'ref': '435005714488-ABNO33052620', + }, + ] + + def setUp(self): + super(TestImport, self).setUp() + bank = self.env['res.partner.bank'].create({ + 'acc_number': 'NL77ABNA0574908765', + 'partner_id': self.env.ref('base.main_partner').id, + 'company_id': self.env.ref('base.main_company').id, + 'bank_id': self.env.ref('base.res_bank_1').id, + }) + self.env['account.journal'].create({ + 'name': 'Bank Journal - (test camt)', + 'code': 'TBNKCAMT', + 'type': 'bank', + 'bank_account_id': bank.id, + }) + + def test_statement_import(self): + """Test correct creation of single statement.""" + testfile = get_module_resource( + 'account_bank_statement_import_camt_oca', + 'test_files', + 'test-camt053', + ) + with open(testfile, 'rb') as datafile: + action = self.env['account.bank.statement.import'].create({ + 'data_file': base64.b64encode(datafile.read()) + }).import_file() + + for statement in self.env['account.bank.statement'].browse( + action['context']['statement_ids'] + ): + self.assertTrue(any( + all( + line[key] == self.transactions[0][key] + for key in ['amount', 'date', 'ref'] + ) and + line.bank_account_id.acc_number == + self.transactions[0]['account_number'] + for line in statement.line_ids + )) + + def test_zip_import(self): + """Test import of multiple statements from zip file.""" + testfile = get_module_resource( + 'account_bank_statement_import_camt_oca', + 'test_files', + 'test-camt053.zip', + ) + with open(testfile, 'rb') as datafile: + action = self.env['account.bank.statement.import'].create({ + 'data_file': base64.b64encode(datafile.read()), + }).import_file() + + for statement in self.env['account.bank.statement'].browse( + action['context']['statement_ids'] + ): + self.assertTrue(statement.line_ids) diff --git a/account_bank_statement_import_camt/views/account_bank_statement_import.xml b/account_bank_statement_import_camt_oca/views/account_bank_statement_import.xml similarity index 100% rename from account_bank_statement_import_camt/views/account_bank_statement_import.xml rename to account_bank_statement_import_camt_oca/views/account_bank_statement_import.xml