mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] add option to create addtional final line
This commit is contained in:
committed by
Maksym Yankin
parent
66f5316dfd
commit
47968a866b
73
account_statement_import_camt54/tests/test_statement.py
Normal file
73
account_statement_import_camt54/tests/test_statement.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Copyright 2020 Camptocamp SA
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import base64
|
||||
|
||||
import mock
|
||||
|
||||
from odoo.modules.module import get_module_resource
|
||||
from odoo.tests.common import SavepointCase
|
||||
|
||||
|
||||
class TestGenerateBankStatement(SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
bank = cls.env["res.partner.bank"].create(
|
||||
{
|
||||
"acc_number": "NL77ABNA0574908765",
|
||||
"partner_id": cls.env.ref("base.main_partner").id,
|
||||
"company_id": cls.env.ref("base.main_company").id,
|
||||
"bank_id": cls.env.ref("base.res_bank_1").id,
|
||||
}
|
||||
)
|
||||
cls.env["res.partner.bank"].create(
|
||||
{
|
||||
"acc_number": "NL46ABNA0499998748",
|
||||
"partner_id": cls.env.ref("base.main_partner").id,
|
||||
"company_id": cls.env.ref("base.main_company").id,
|
||||
"bank_id": cls.env.ref("base.res_bank_1").id,
|
||||
}
|
||||
)
|
||||
cls.journal = cls.env["account.journal"].create(
|
||||
{
|
||||
"name": "Bank Journal - (test camt)",
|
||||
"code": "TBNKCAMT",
|
||||
"type": "bank",
|
||||
"bank_account_id": bank.id,
|
||||
"currency_id": cls.env.ref("base.EUR").id,
|
||||
}
|
||||
)
|
||||
|
||||
@mock.patch(
|
||||
"odoo.addons.account.models.sequence_mixin."
|
||||
"SequenceMixin._constrains_date_sequence",
|
||||
side_effect=False,
|
||||
)
|
||||
def _load_statement(self, constraint):
|
||||
testfile = get_module_resource(
|
||||
"account_statement_import_camt", "test_files", "test-camt053"
|
||||
)
|
||||
with open(testfile, "rb") as datafile:
|
||||
camt_file = base64.b64encode(datafile.read())
|
||||
self.env["account.statement.import"].create(
|
||||
{
|
||||
"statement_filename": "test import",
|
||||
"statement_file": camt_file,
|
||||
}
|
||||
).import_file_button()
|
||||
bank_st_record = self.env["account.bank.statement"].search(
|
||||
[("name", "=", "1234Test/1")], limit=1
|
||||
)
|
||||
statement_lines = bank_st_record.line_ids
|
||||
return statement_lines
|
||||
|
||||
def test_statement_import(self):
|
||||
self.journal.transfer_line = True
|
||||
lines = self._load_statement()
|
||||
self.assertEqual(len(lines), 5)
|
||||
self.assertAlmostEqual(sum(lines.mapped("amount")), 0)
|
||||
self.journal.transfer_line = False
|
||||
lines = self._load_statement()
|
||||
self.assertEqual(len(lines), 4)
|
||||
self.assertAlmostEqual(sum(lines.mapped("amount")), -12.99)
|
||||
Reference in New Issue
Block a user