[IMP] add option to create addtional final line

This commit is contained in:
Iryna Vyshnevska
2021-01-14 13:38:05 +02:00
committed by sonhd91
parent 1a1e06179b
commit 4fa0cbcdc1
10 changed files with 227 additions and 19 deletions

View File

@@ -14,13 +14,13 @@ Bank Account Camt54 Import
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github .. |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 :alt: OCA/bank-statement-import
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |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. 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 Switzerland localisation
------------------------ ------------------------
@@ -54,7 +59,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-statement-import/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_bank_statement_import_oca_camt54%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_camt54%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@@ -72,6 +77,11 @@ Contributors
* Yannick Vaucher <yannick.vaucher@camptocamp.com> * Yannick Vaucher <yannick.vaucher@camptocamp.com>
* Timon Tschanz <timon.tschanz@camptocamp.com> * Timon Tschanz <timon.tschanz@camptocamp.com>
Other credits
~~~~~~~~~~~~~
* Digital4efficiency.ch
Maintainers 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_oca_camt54>`_ project on GitHub. This module is part of the `OCA/bank-statement-import <https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_camt54>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -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 ""

View File

@@ -1,2 +1,3 @@
from . import account_statement_import from . import account_statement_import
from . import account_journal
from . import parser from . import parser

View File

@@ -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",
)

View File

@@ -12,18 +12,29 @@ class AccountStatementImport(models.TransientModel):
_inherit = "account.statement.import" _inherit = "account.statement.import"
def _create_bank_statements(self, stmts_vals): def _create_bank_statements(self, stmts_vals, result):
""" Set balance_end_real if not already provided by the file.""" """Create additional line in statement to set bank statement statement
to 0 balance"""
statement_line_ids, notifications = super()._create_bank_statements(stmts_vals) super()._create_bank_statements(stmts_vals, result)
statements = self.env["account.bank.statement"].search( statements = self.env["account.bank.statement"].browse(result["statement_ids"])
[("line_ids", "in", statement_line_ids)]
)
for statement in statements: 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 statement.balance_end_real = statement.balance_start + amount
return statement_line_ids, notifications
def _complete_stmts_vals(self, stmts_vals, journal, account_number): def _complete_stmts_vals(self, stmts_vals, journal, account_number):
"""Search partner from partner reference""" """Search partner from partner reference"""

View File

@@ -0,0 +1 @@
* Digital4efficiency.ch

View File

@@ -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. 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 Switzerland localisation
------------------------ ------------------------

View File

@@ -367,11 +367,15 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_oca_camt54"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-statement-import-13-0/bank-statement-import-13-0-account_bank_statement_import_oca_camt54"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/174/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_camt54"><img alt="OCA/bank-statement-import" src="https://img.shields.io/badge/github-OCA%2Fbank--statement--import-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-statement-import-14-0/bank-statement-import-14-0-account_statement_import_camt54"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/174/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<blockquote> <blockquote>
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.</blockquote> 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.</blockquote>
<p>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)</p> <p>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)</p>
<p>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.</p> <p>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.</p>
<p>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 -&gt; Journals -&gt; tab Advanced Settings -&gt; Bank statement configuration</p>
<div class="section" id="switzerland-localisation"> <div class="section" id="switzerland-localisation">
<h1>Switzerland localisation</h1> <h1>Switzerland localisation</h1>
<p>For ISR containing a partner reference, uses the config parameter key <cite>isr_partner_ref</cite>. <p>For ISR containing a partner reference, uses the config parameter key <cite>isr_partner_ref</cite>.
@@ -387,7 +391,8 @@ For instance <cite>13,6</cite> to start on position 13 with a 6 digit long refer
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul> <li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li> <li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li> <li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li> <li><a class="reference internal" href="#other-credits" id="id5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@@ -397,7 +402,7 @@ For instance <cite>13,6</cite> to start on position 13 with a 6 digit long refer
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_bank_statement_import_oca_camt54%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/bank-statement-import/issues/new?body=module:%20account_statement_import_camt54%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -415,14 +420,20 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Timon Tschanz &lt;<a class="reference external" href="mailto:timon.tschanz&#64;camptocamp.com">timon.tschanz&#64;camptocamp.com</a>&gt;</li> <li>Timon Tschanz &lt;<a class="reference external" href="mailto:timon.tschanz&#64;camptocamp.com">timon.tschanz&#64;camptocamp.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#id5">Other credits</a></h3>
<ul class="simple">
<li>Digital4efficiency.ch</li>
</ul>
</div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h3><a class="toc-backref" href="#id5">Maintainers</a></h3> <h3><a class="toc-backref" href="#id6">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/13.0/account_bank_statement_import_oca_camt54">OCA/bank-statement-import</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-statement-import/tree/14.0/account_statement_import_camt54">OCA/bank-statement-import</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -1 +1,2 @@
from . import test_get_partner_ref from . import test_get_partner_ref
from . import test_statement

View 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)