mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
Rename module
Also: - Use context managers for file opening/closing in tests - Changed use of deprecated `BadZipfile` exception - Removed debugging code left by mistake
This commit is contained in:
@@ -1,128 +0,0 @@
|
||||
"""Run test to import camt.053 import."""
|
||||
# © 2013-2016 Therp BV <http://therp.nl>
|
||||
# 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)
|
||||
@@ -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"
|
||||
@@ -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 <transbot@odoo-community.org>, 2017
|
||||
# enjolras <yo@miguelrevilla.com>, 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"
|
||||
@@ -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 <jarmo.kortetjarvi@gmail.com>, 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 ""
|
||||
@@ -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 <odoo@kerpeo.com>, 2017
|
||||
# OCA Transbot <transbot@odoo-community.org>, 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é"
|
||||
@@ -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 <transbot@odoo-community.org>, 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 ""
|
||||
@@ -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 <alejandrosantana@anubia.es>, 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 ""
|
||||
@@ -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 <bole@dajmi5.com>, 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"
|
||||
@@ -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šą"
|
||||
@@ -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 <imreeil42@gmail.com>, 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 ""
|
||||
@@ -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 <erwin@bas-solutions.nl>, 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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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.",
|
||||
@@ -0,0 +1,127 @@
|
||||
"""Run test to import camt.053 import."""
|
||||
# © 2013-2016 Therp BV <http://therp.nl>
|
||||
# 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)
|
||||
Reference in New Issue
Block a user