diff --git a/account_statement_import_camt54/README.rst b/account_statement_import_camt54/README.rst index 54f8f43d..91b1c21a 100644 --- a/account_statement_import_camt54/README.rst +++ b/account_statement_import_camt54/README.rst @@ -14,13 +14,13 @@ Bank Account Camt54 Import :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github - :target: https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_oca_camt54 + :target: https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_camt54 :alt: OCA/bank-statement-import .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/bank-statement-import-13-0/bank-statement-import-13-0-account_bank_statement_import_oca_camt54 + :target: https://translation.odoo-community.org/projects/bank-statement-import-14-0/bank-statement-import-14-0-account_statement_import_camt54 :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/174/13.0 + :target: https://runbot.odoo-community.org/runbot/174/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -31,6 +31,11 @@ Customer invoices will be reconciled/Paid. Payment entries will be posted into a After this first step, import normally your CAMT.053 (full bank statement) into the bank journal. You will be able to clear the internal transfer account to end up the accounting flow. +Optionally we can activate add generation of additional line in bank statement which will balance your bank statement total to 0. +This line can be consolidated later with different account. +To enable option of final statement line you need properly set flag on Account Journal +Configuration -> Journals -> tab Advanced Settings -> Bank statement configuration + Switzerland localisation ------------------------ @@ -54,7 +59,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -72,6 +77,11 @@ Contributors * Yannick Vaucher * Timon Tschanz +Other credits +~~~~~~~~~~~~~ + +* Digital4efficiency.ch + Maintainers ~~~~~~~~~~~ @@ -85,6 +95,6 @@ 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. -This module is part of the `OCA/bank-statement-import `_ project on GitHub. +This module is part of the `OCA/bank-statement-import `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_statement_import_camt54/i18n/account_statement_import_camt54.pot b/account_statement_import_camt54/i18n/account_statement_import_camt54.pot new file mode 100644 index 00000000..0a45b96e --- /dev/null +++ b/account_statement_import_camt54/i18n/account_statement_import_camt54.pot @@ -0,0 +1,81 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_camt54 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_statement_import_camt_parser +msgid "Account Bank Statement Import CAMT parser" +msgstr "" + +#. module: account_statement_import_camt54 +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_journal__transfer_line +msgid "Add balance Line" +msgstr "" + +#. module: account_statement_import_camt54 +#: code:addons/account_statement_import_camt54/models/parser.py:0 +#, python-format +msgid "" +"Config parameter `isr_partner_ref` is wrong.\n" +"It must be in format `i[,n]` \n" +"`i` and `n` must be integers.\n" +"e.g. \"13,6\"" +msgstr "" + +#. module: account_statement_import_camt54 +#: code:addons/account_statement_import_camt54/models/parser.py:0 +#, python-format +msgid "" +"Config parameter `isr_partner_ref` is wrong.\n" +"It must be in format `i[,n]` \n" +"where `i` is the position of the first digit and\n" +"`n` the number of digit in the reference, by default 6.\n" +"e.g. \"13,6\"" +msgstr "" + +#. module: account_statement_import_camt54 +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_journal__display_name +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_statement_import__display_name +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_statement_import_camt_parser__display_name +msgid "Display Name" +msgstr "" + +#. module: account_statement_import_camt54 +#: model:ir.model.fields,help:account_statement_import_camt54.field_account_journal__transfer_line +msgid "Generate balance line on total of bank statement import" +msgstr "" + +#. module: account_statement_import_camt54 +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_journal__id +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_statement_import__id +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_statement_import_camt_parser__id +msgid "ID" +msgstr "" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_statement_import +msgid "Import Bank Statement Files" +msgstr "" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_camt54 +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_journal____last_update +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_statement_import____last_update +#: model:ir.model.fields,field_description:account_statement_import_camt54.field_account_statement_import_camt_parser____last_update +msgid "Last Modified on" +msgstr "" diff --git a/account_statement_import_camt54/models/__init__.py b/account_statement_import_camt54/models/__init__.py index 11ac1bbc..7a228b17 100644 --- a/account_statement_import_camt54/models/__init__.py +++ b/account_statement_import_camt54/models/__init__.py @@ -1,2 +1,3 @@ from . import account_statement_import +from . import account_journal from . import parser diff --git a/account_statement_import_camt54/models/account_journal.py b/account_statement_import_camt54/models/account_journal.py new file mode 100644 index 00000000..752187a6 --- /dev/null +++ b/account_statement_import_camt54/models/account_journal.py @@ -0,0 +1,14 @@ +# Copyright 2020 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class AccountBankStatementImport(models.Model): + + _inherit = "account.journal" + + transfer_line = fields.Boolean( + string="Add balance Line", + help="Generate balance line on total of bank statement import", + ) diff --git a/account_statement_import_camt54/models/account_statement_import.py b/account_statement_import_camt54/models/account_statement_import.py index ae863028..6dc15ec3 100644 --- a/account_statement_import_camt54/models/account_statement_import.py +++ b/account_statement_import_camt54/models/account_statement_import.py @@ -12,18 +12,29 @@ class AccountStatementImport(models.TransientModel): _inherit = "account.statement.import" - def _create_bank_statements(self, stmts_vals): - """ Set balance_end_real if not already provided by the file.""" + def _create_bank_statements(self, stmts_vals, result): + """Create additional line in statement to set bank statement statement + to 0 balance""" - statement_line_ids, notifications = super()._create_bank_statements(stmts_vals) - statements = self.env["account.bank.statement"].search( - [("line_ids", "in", statement_line_ids)] - ) + super()._create_bank_statements(stmts_vals, result) + statements = self.env["account.bank.statement"].browse(result["statement_ids"]) for statement in statements: - if not statement.balance_end_real: - amount = sum(statement.line_ids.mapped("amount")) + amount = sum(statement.line_ids.mapped("amount")) + if statement.journal_id.transfer_line: + if amount != 0: + amount = -amount + statement.line_ids.create( + { + "name": statement.name, + "amount": amount, + "statement_id": statement.id, + "date": statement.date, + "payment_ref": "/", + } + ) + statement.balance_end_real = statement.balance_start + else: statement.balance_end_real = statement.balance_start + amount - return statement_line_ids, notifications def _complete_stmts_vals(self, stmts_vals, journal, account_number): """Search partner from partner reference""" diff --git a/account_statement_import_camt54/readme/CREDITS.rst b/account_statement_import_camt54/readme/CREDITS.rst new file mode 100644 index 00000000..5ee91fa4 --- /dev/null +++ b/account_statement_import_camt54/readme/CREDITS.rst @@ -0,0 +1 @@ +* Digital4efficiency.ch diff --git a/account_statement_import_camt54/readme/DESCRIPTION.rst b/account_statement_import_camt54/readme/DESCRIPTION.rst index 63b1f4cf..4b97b805 100644 --- a/account_statement_import_camt54/readme/DESCRIPTION.rst +++ b/account_statement_import_camt54/readme/DESCRIPTION.rst @@ -4,6 +4,11 @@ Customer invoices will be reconciled/Paid. Payment entries will be posted into a After this first step, import normally your CAMT.053 (full bank statement) into the bank journal. You will be able to clear the internal transfer account to end up the accounting flow. +Optionally we can activate add generation of additional line in bank statement which will balance your bank statement total to 0. +This line can be consolidated later with different account. +To enable option of final statement line you need properly set flag on Account Journal +Configuration -> Journals -> tab Advanced Settings -> Bank statement configuration + Switzerland localisation ------------------------ diff --git a/account_statement_import_camt54/static/description/index.html b/account_statement_import_camt54/static/description/index.html index fc09fe3d..05789f76 100644 --- a/account_statement_import_camt54/static/description/index.html +++ b/account_statement_import_camt54/static/description/index.html @@ -367,11 +367,15 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/bank-statement-import Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/bank-statement-import Translate me on Weblate Try me on Runbot

This module allows you to import CAMT.054 file (details of customers payments batch) into a dedicated journal taking care of the start/end balance and the remittance reference number.

Customer invoices will be reconciled/Paid. Payment entries will be posted into an internal transfer account (that you have to create with a type current asset and set on the journal)

After this first step, import normally your CAMT.053 (full bank statement) into the bank journal. You will be able to clear the internal transfer account to end up the accounting flow.

+

Optionally we can activate add generation of additional line in bank statement which will balance your bank statement total to 0. +This line can be consolidated later with different account. +To enable option of final statement line you need properly set flag on Account Journal +Configuration -> Journals -> tab Advanced Settings -> Bank statement configuration

Switzerland localisation

For ISR containing a partner reference, uses the config parameter key isr_partner_ref. @@ -387,7 +391,8 @@ For instance 13,6 to start on position 13 with a 6 digit long refer

  • Credits
  • @@ -397,7 +402,7 @@ For instance 13,6 to start on position 13 with a 6 digit long refer

    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.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -415,14 +420,20 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Timon Tschanz <timon.tschanz@camptocamp.com>
  • +
    +

    Other credits

    +
      +
    • Digital4efficiency.ch
    • +
    +
    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association

    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.

    -

    This module is part of the OCA/bank-statement-import project on GitHub.

    +

    This module is part of the OCA/bank-statement-import project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/account_statement_import_camt54/tests/__init__.py b/account_statement_import_camt54/tests/__init__.py index c2592574..002dfdba 100644 --- a/account_statement_import_camt54/tests/__init__.py +++ b/account_statement_import_camt54/tests/__init__.py @@ -1 +1,2 @@ from . import test_get_partner_ref +from . import test_statement diff --git a/account_statement_import_camt54/tests/test_statement.py b/account_statement_import_camt54/tests/test_statement.py new file mode 100644 index 00000000..b7a16fd3 --- /dev/null +++ b/account_statement_import_camt54/tests/test_statement.py @@ -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)