diff --git a/account_statement_import_camt54/README.rst b/account_statement_import_camt54/README.rst new file mode 100644 index 000000000..f298a5a27 --- /dev/null +++ b/account_statement_import_camt54/README.rst @@ -0,0 +1,120 @@ +========================== +Bank Account Camt54 Import +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:423ab66deb35c8930b150cf71f0595cf124e40574ae9874935ac5291b19b9c04 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/17.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-17-0/bank-statement-import-17-0-account_statement_import_camt54 + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/bank-statement-import&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + + 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 QRR containing a partner reference, uses the config parameter key +qrr_partner_ref. Doing so will fill the partners on bank statement lines +and speed up the matches in the reconciliation process. + +Value to set in qrr_partner_ref defines the position of the partner +reference inside the QRR. The format is i[,n] For instance 13,6 to start +on position 13 with a 6 digit long reference. n is optional and it's +default value is 6. + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* camptocamp + +Contributors +------------ + +- Yannick Vaucher + +- Timon Tschanz + +- `Trobz `__: + + - Son Ho + +Other credits +------------- + +- Digital4efficiency.ch +- The migration of this module from 15.0 to 16.0 was financially + supported by Camptocamp +- The migration of this module from 16.0 to 17.0 was financially + supported by Camptocamp + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_statement_import_camt54/__init__.py b/account_statement_import_camt54/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_statement_import_camt54/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_statement_import_camt54/__manifest__.py b/account_statement_import_camt54/__manifest__.py new file mode 100644 index 000000000..246474115 --- /dev/null +++ b/account_statement_import_camt54/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Bank Account Camt54 Import", + "version": "17.0.1.0.0", + "category": "Account", + "website": "https://github.com/OCA/bank-statement-import", + "author": "camptocamp, " "Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["account_statement_import_camt"], + "data": ["views/account_journal_view.xml"], +} 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 000000000..ba3243abf --- /dev/null +++ b/account_statement_import_camt54/i18n/account_statement_import_camt54.pot @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_camt54 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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 +#. odoo-python +#: 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 +#. odoo-python +#: 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,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,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 "" diff --git a/account_statement_import_camt54/i18n/es.po b/account_statement_import_camt54/i18n/es.po new file mode 100644 index 000000000..b4eb53fe6 --- /dev/null +++ b/account_statement_import_camt54/i18n/es.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_camt54 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-07-29 12:10+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "Análisis de importación de extractos bancarios CAMT" + +#. 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 "Añadir línea de balance" + +#. module: account_statement_import_camt54 +#. odoo-python +#: 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 "" +"El parámetro de configuración `isr_partner_ref` es incorrecto.\n" +"Debe tener el formato `i[,n]`. \n" +"`i` y `n` deben ser enteros.\n" +"Por ejemplo, \"13,6\"" + +#. module: account_statement_import_camt54 +#. odoo-python +#: 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 "" +"El parámetro de configuración `isr_partner_ref` es incorrecto.\n" +"Debe tener el formato `i[,n]`. \n" +"donde `i` es la posición del primer dígito y\n" +"`n` el número de dígitos de la referencia, por defecto 6.\n" +"Por ejemplo, \"13,6\"" + +#. 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 "" +"Generar línea de saldo sobre el total de la importación de extractos " +"bancarios" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_statement_import +msgid "Import Bank Statement Files" +msgstr "Importar ficheros de extracto bancario" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_journal +msgid "Journal" +msgstr "Dario" diff --git a/account_statement_import_camt54/i18n/it.po b/account_statement_import_camt54/i18n/it.po new file mode 100644 index 000000000..875e269e2 --- /dev/null +++ b/account_statement_import_camt54/i18n/it.po @@ -0,0 +1,83 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_camt54 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-03 16:35+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "Parser CAMT importazione estratto conto bancario" + +#. 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 "Aggiungi riga saldo" + +#. module: account_statement_import_camt54 +#. odoo-python +#: 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 "" +"Il parametro `isr_partner_ref` è configurato in modo errato.\n" +"Deve essere nel formato `i[,n]` \n" +"`i` e `n` devono essere interi.\n" +"es. \"13,6\"" + +#. module: account_statement_import_camt54 +#. odoo-python +#: 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 "" +"Il parametro `isr_partner_ref` è configurato male.\n" +"Deve essere nel formato `i[,n]` \n" +"dove `i` è la posizione della prima cifra e\n" +"`n` il numero di cifre nel riferimento, predefinito 6.\n" +"es. \"13,6\"" + +#. 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 "Genera riga di saldo sul totale dell'importazione dell'estratto conto" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_statement_import +msgid "Import Bank Statement Files" +msgstr "Importazione file estratto conto bancario" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_journal +msgid "Journal" +msgstr "Registro" + +#~ msgid "Display Name" +#~ msgstr "Nome visualizzato" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Ultima modifica il" diff --git a/account_statement_import_camt54/i18n/nl.po b/account_statement_import_camt54/i18n/nl.po new file mode 100644 index 000000000..887f1fdcb --- /dev/null +++ b/account_statement_import_camt54/i18n/nl.po @@ -0,0 +1,74 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_camt54 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-19 14:30+0000\n" +"Last-Translator: Yung-Wa \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "Rekeningafschrift importeren CAMT ontleder" + +#. 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 "Saldolijn toevoegen" + +#. module: account_statement_import_camt54 +#. odoo-python +#: 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 "" +"Configuratieparameter `isr_partner_ref` is verkeerd.\n" +"Hij moet het formaat `i[,n]` hebben. \n" +"`i` en `n` moeten gehele getallen zijn.\n" +"Bijv. \"13,6\"" + +#. module: account_statement_import_camt54 +#. odoo-python +#: 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 "" +"Configuratieparameter `isr_partner_ref` is verkeerd.\n" +"Hij moet het formaat `i[,n]` hebben. \n" +"waarbij `i` de positie van het eerste cijfer is en\n" +"`n` het aantal cijfers in de verwijzing, standaard 6.\n" +"Bijv \"13,6\"" + +#. 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 "Genereer saldoregel op het totaal van geïmporteerde bankafschriften" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_statement_import +msgid "Import Bank Statement Files" +msgstr "Bankafschriften importeren" + +#. module: account_statement_import_camt54 +#: model:ir.model,name:account_statement_import_camt54.model_account_journal +msgid "Journal" +msgstr "Dagboek" diff --git a/account_statement_import_camt54/migrations/17.0.1.0.0/pre-migrate.py b/account_statement_import_camt54/migrations/17.0.1.0.0/pre-migrate.py new file mode 100644 index 000000000..e2f0f3e12 --- /dev/null +++ b/account_statement_import_camt54/migrations/17.0.1.0.0/pre-migrate.py @@ -0,0 +1,8 @@ +def migrate(cr, version): + cr.execute( + """ + UPDATE ir_config_parameter + SET key = 'qrr_partner_ref' + WHERE key = 'isr_partner_ref' + """ + ) diff --git a/account_statement_import_camt54/models/__init__.py b/account_statement_import_camt54/models/__init__.py new file mode 100644 index 000000000..7a228b174 --- /dev/null +++ b/account_statement_import_camt54/models/__init__.py @@ -0,0 +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 000000000..37e3256c8 --- /dev/null +++ b/account_statement_import_camt54/models/account_journal.py @@ -0,0 +1,13 @@ +# 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 new file mode 100644 index 000000000..536345cbf --- /dev/null +++ b/account_statement_import_camt54/models/account_statement_import.py @@ -0,0 +1,51 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +import logging + +from odoo import models + +_logger = logging.getLogger(__name__) + + +class AccountStatementImport(models.TransientModel): + """Add process_camt method to account.bank.statement.import.""" + + _inherit = "account.statement.import" + + def _create_bank_statements(self, stmts_vals, result): + """Create additional line in statement to set bank statement statement + to 0 balance""" + + res = super()._create_bank_statements(stmts_vals, result) + statements = self.env["account.bank.statement"].browse(result["statement_ids"]) + for statement in statements: + amount = sum(statement.line_ids.mapped("amount")) + if statement.journal_id.transfer_line: + if amount != 0: + amount = -amount + statement.line_ids.create( + { + "amount": amount, + "statement_id": statement.id, + "date": statement.date, + "payment_ref": statement.name, + } + ) + statement.balance_end_real = statement.balance_start + else: + statement.balance_end_real = statement.balance_start + amount + return res + + def _complete_stmts_vals(self, stmts_vals, journal, account_number): + """Search partner from partner reference""" + stmts_vals = super()._complete_stmts_vals(stmts_vals, journal, account_number) + for st_vals in stmts_vals: + for line_vals in st_vals["transactions"]: + if "partner_ref" in line_vals: + partner_ref = line_vals.pop("partner_ref") + partner = self.env["res.partner"].search( + [("ref", "=", partner_ref)], limit=1 + ) + line_vals["partner_id"] = partner.id + + return stmts_vals diff --git a/account_statement_import_camt54/models/parser.py b/account_statement_import_camt54/models/parser.py new file mode 100644 index 000000000..1e6e72cf3 --- /dev/null +++ b/account_statement_import_camt54/models/parser.py @@ -0,0 +1,101 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, models +from odoo.exceptions import UserError + + +class CamtParser(models.AbstractModel): + """Parser for camt bank statement import files.""" + + _inherit = "account.statement.import.camt.parser" + + def _get_partner_ref(self, isr): + ICP = self.env["ir.config_parameter"] + ref_format = ICP.sudo().get_param("qrr_partner_ref") + if not ref_format: + return + config = ref_format.split(",") + if len(config) == 2: + start, size = config + elif len(config) == 1: + start = config[0] + size = 6 + else: + raise UserError( + _( + "Config parameter `qrr_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"' + ) + ) + try: + start = int(start) - 1 # count from 1 instead of 0 + size = int(size) + end = start + size + except ValueError: + raise UserError( + _( + "Config parameter `qrr_partner_ref` is wrong.\n" + "It must be in format `i[,n]` \n" + "`i` and `n` must be integers.\n" + 'e.g. "13,6"' + ) + ) from None + return isr[start:end].lstrip("0") + + def parse_transaction_details(self, ns, node, transaction): + """Put ESR in label and add aditional information to label + if no esr is available + """ + super().parse_transaction_details(ns, node, transaction) + # put the esr in the label. odoo reconciles based on the label, + # if there is no esr it tries to use the information textfield + + qrr_number = node.xpath( + "./ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref", namespaces={"ns": ns} + ) + if len(qrr_number): + transaction["payment_ref"] = qrr_number[0].text + partner_ref = self._get_partner_ref(qrr_number[0].text) + if partner_ref: + transaction["partner_ref"] = partner_ref + else: + xpath_exprs = [ + "./ns:RmtInf/ns:Ustrd|./ns:RtrInf/ns:AddtlInf", + "./ns:AddtlNtryInf", + "/ns:Refs/ns:InstrId", + ] + payment_ref = transaction["payment_ref"] + for xpath_expr in xpath_exprs: + found_node = node.xpath(xpath_expr, namespaces={"ns": ns}) + if found_node: + payment_ref = found_node[0].text + break + trans_id_node = ( + node.getparent() + .getparent() + .xpath("./ns:AcctSvcrRef", namespaces={"ns": ns}) + ) + if trans_id_node: + payment_ref = f"{payment_ref} ({trans_id_node[0].text})" + if payment_ref: + transaction["payment_ref"] = payment_ref + # End add esr to the label. + + # add transaction id to ref + self.add_value_from_node( + ns, + node, + [ + "./../../ns:AcctSvcrRef", + "./ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref", + "./ns:Refs/ns:EndToEndId", + ], + transaction, + "ref", + ) + return True diff --git a/account_statement_import_camt54/pyproject.toml b/account_statement_import_camt54/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/account_statement_import_camt54/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_statement_import_camt54/readme/CONTRIBUTORS.md b/account_statement_import_camt54/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..7d370c6e9 --- /dev/null +++ b/account_statement_import_camt54/readme/CONTRIBUTORS.md @@ -0,0 +1,7 @@ +- Yannick Vaucher \<\> + +- Timon Tschanz \<\> + +- [Trobz](https://trobz.com): + + > - Son Ho \<\> diff --git a/account_statement_import_camt54/readme/CREDITS.md b/account_statement_import_camt54/readme/CREDITS.md new file mode 100644 index 000000000..50ea01074 --- /dev/null +++ b/account_statement_import_camt54/readme/CREDITS.md @@ -0,0 +1,3 @@ +- Digital4efficiency.ch +- The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp +- The migration of this module from 16.0 to 17.0 was financially supported by Camptocamp diff --git a/account_statement_import_camt54/readme/DESCRIPTION.md b/account_statement_import_camt54/readme/DESCRIPTION.md new file mode 100644 index 000000000..3073dc446 --- /dev/null +++ b/account_statement_import_camt54/readme/DESCRIPTION.md @@ -0,0 +1,29 @@ +> 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 QRR containing a partner reference, uses the config parameter key +qrr_partner_ref. Doing so will fill the partners on bank statement lines +and speed up the matches in the reconciliation process. + +Value to set in qrr_partner_ref defines the position of the partner +reference inside the QRR. The format is i\[,n\] For instance 13,6 to +start on position 13 with a 6 digit long reference. n is optional and +it's default value is 6. \ No newline at end of file diff --git a/account_statement_import_camt54/static/description/icon.png b/account_statement_import_camt54/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_statement_import_camt54/static/description/icon.png differ diff --git a/account_statement_import_camt54/static/description/index.html b/account_statement_import_camt54/static/description/index.html new file mode 100644 index 000000000..6ee6bd260 --- /dev/null +++ b/account_statement_import_camt54/static/description/index.html @@ -0,0 +1,463 @@ + + + + + +Bank Account Camt54 Import + + + +
+

Bank Account Camt54 Import

+ + +

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

+
+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 QRR containing a partner reference, uses the config parameter key +qrr_partner_ref. Doing so will fill the partners on bank statement lines +and speed up the matches in the reconciliation process.

+

Value to set in qrr_partner_ref defines the position of the partner +reference inside the QRR. The format is i[,n] For instance 13,6 to start +on position 13 with a 6 digit long reference. n is optional and it’s +default value is 6.

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+ +
+
+

Authors

+
    +
  • camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+
    +
  • Digital4efficiency.ch
  • +
  • The migration of this module from 15.0 to 16.0 was financially +supported by Camptocamp
  • +
  • The migration of this module from 16.0 to 17.0 was financially +supported by Camptocamp
  • +
+
+
+

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.

+

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 new file mode 100644 index 000000000..002dfdbaf --- /dev/null +++ b/account_statement_import_camt54/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_get_partner_ref +from . import test_statement diff --git a/account_statement_import_camt54/tests/test_get_partner_ref.py b/account_statement_import_camt54/tests/test_get_partner_ref.py new file mode 100644 index 000000000..3fda00a30 --- /dev/null +++ b/account_statement_import_camt54/tests/test_get_partner_ref.py @@ -0,0 +1,66 @@ +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.exceptions import UserError +from odoo.tests import common + + +class TestGetPartnerRef(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.Parser = cls.env["account.statement.import.camt.parser"] + cls.ICP = cls.env["ir.config_parameter"] + + def test_no_ICP(self): + """Test no partner ref is read if param is not set""" + ref = "11 11111 11111 11111 11111 11111".replace(" ", "") + partner_ref = self.Parser._get_partner_ref(ref) + self.assertFalse(partner_ref) + + def test_ICP_empty(self): + self.ICP.set_param("qrr_partner_ref", "") + ref = "11 11111 11111 11111 11111 11111".replace(" ", "") + partner_ref = self.Parser._get_partner_ref(ref) + self.assertFalse(partner_ref) + + def test_ICP_no_len(self): + """Test a default len of 6 is set if not provided""" + self.ICP.set_param("qrr_partner_ref", "12") + ref = "11 11111 11112 34567 11111 11111".replace(" ", "") + partner_ref = self.Parser._get_partner_ref(ref) + self.assertEqual(partner_ref, "234567") + + def test_ICP_full(self): + """Test full format of partner ref definition""" + self.ICP.set_param("qrr_partner_ref", "12,6") + ref = "11 11111 11112 34567 11111 11111".replace(" ", "") + partner_ref = self.Parser._get_partner_ref(ref) + self.assertEqual(partner_ref, "234567") + + def test_zero_stripped(self): + """Test full format of partner ref definition""" + self.ICP.set_param("qrr_partner_ref", "12,6") + ref = "11 11111 11110 00560 11111 11111".replace(" ", "") + partner_ref = self.Parser._get_partner_ref(ref) + self.assertEqual(partner_ref, "560") + + def test_bad_ICP(self): + """Test ir config parameter validation""" + self.ICP.set_param("qrr_partner_ref", "") + ref = "11 11111 11111 11111 11111 11111".replace(" ", "") + + self.ICP.set_param("qrr_partner_ref", "A") + with self.assertRaises(UserError): + self.Parser._get_partner_ref(ref) + + self.ICP.set_param("qrr_partner_ref", "A,B") + with self.assertRaises(UserError): + self.Parser._get_partner_ref(ref) + + self.ICP.set_param("qrr_partner_ref", "1,X") + with self.assertRaises(UserError): + self.Parser._get_partner_ref(ref) + + self.ICP.set_param("qrr_partner_ref", "A,8") + with self.assertRaises(UserError): + self.Parser._get_partner_ref(ref) 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 000000000..a1569527f --- /dev/null +++ b/account_statement_import_camt54/tests/test_statement.py @@ -0,0 +1,66 @@ +# Copyright 2020 Camptocamp SA +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import base64 + +from odoo.tests.common import TransactionCase +from odoo.tools.misc import file_path + + +class TestGenerateBankStatement(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + eur_currency = cls.env.ref("base.EUR") + eur_currency.write({"active": True}) + 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": eur_currency.id, + } + ) + + def _load_statement(self): + testfile = file_path("account_statement_import_camt/test_files/test-camt054") + 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", "=", "20220120000000000000000")], 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), 2) + self.assertAlmostEqual(sum(lines.mapped("amount")), 0) + self.journal.transfer_line = False + lines = self._load_statement() + self.assertEqual(len(lines), 1) + self.assertAlmostEqual(sum(lines.mapped("amount")), 5.0) diff --git a/account_statement_import_camt54/views/account_journal_view.xml b/account_statement_import_camt54/views/account_journal_view.xml new file mode 100644 index 000000000..55486d2c5 --- /dev/null +++ b/account_statement_import_camt54/views/account_journal_view.xml @@ -0,0 +1,18 @@ + + + + + account.journal.form.inherited.bank.statement.import + account.journal + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt index 4ad8e0ece..cd90b53ef 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,2 @@ odoo-test-helper +odoo-addon-account_statement_import_camt @ git+https://github.com/OCA/bank-statement-import.git@refs/pull/684/head#subdirectory=account_statement_import_camt