diff --git a/account_statement_import_coda/README.rst b/account_statement_import_coda/README.rst new file mode 100644 index 000000000..f302f78b0 --- /dev/null +++ b/account_statement_import_coda/README.rst @@ -0,0 +1,91 @@ +========================== +Import CODA Bank Statement +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fl10n--belgium-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-belgium/tree/14.0/account_statement_import_coda + :alt: OCA/l10n-belgium +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-belgium-14-0/l10n-belgium-14-0-account_statement_import_coda + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/119/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to import your bank transactions with a standard +**CODA** file (you'll find samples in the 'data' folder). + +This module was renamed in v14 to follow the behavior of the parent OCA module account_statement_module. + +This is an alternative to the l10n_be_coda module in Odoo Enterprise. +It uses the external python lib `pycoda `__ as parser. + +Expected benefits: + +* The pycoda parser is a better-tested external python lib. +* Better separation between file parsing and mapping of these data in Odoo. +* The module only depends of account_bank_statement_import. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +To install this module, you need to install the python library `pycoda `__. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Laurent Mignon +* Stéphane Bidoul `_ 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_coda/__init__.py b/account_statement_import_coda/__init__.py new file mode 100644 index 000000000..31233e87f --- /dev/null +++ b/account_statement_import_coda/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2015-2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from . import wizard diff --git a/account_statement_import_coda/__manifest__.py b/account_statement_import_coda/__manifest__.py new file mode 100644 index 000000000..1e71ad8a9 --- /dev/null +++ b/account_statement_import_coda/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2015-2021 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Import CODA Bank Statement", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-belgium", + "category": "Accounting & Finance", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "depends": ["account_statement_import_file"], + "data": ["wizard/account_statement_import_coda_view.xml"], + "external_dependencies": {"python": ["pycoda"]}, + "auto_install": False, + "installable": True, +} diff --git a/account_statement_import_coda/i18n/account_statement_import_coda.pot b/account_statement_import_coda/i18n/account_statement_import_coda.pot new file mode 100644 index 000000000..cd50ade90 --- /dev/null +++ b/account_statement_import_coda/i18n/account_statement_import_coda.pot @@ -0,0 +1,80 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_coda +# +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_coda +#: model_terms:ir.ui.view,arch_db:account_statement_import_coda.account_statement_import_form +msgid "Coded statement of account (.coda or .CD2)" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:0 +#, python-format +msgid "Communication" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:0 +#, python-format +msgid "Counter Party" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:0 +#, python-format +msgid "Counter Party Account" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:0 +#, python-format +msgid "Counter Party Address" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model.fields,field_description:account_statement_import_coda.field_account_journal__display_name +#: model:ir.model.fields,field_description:account_statement_import_coda.field_account_statement_import__display_name +msgid "Display Name" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model.fields,field_description:account_statement_import_coda.field_account_journal__id +#: model:ir.model.fields,field_description:account_statement_import_coda.field_account_statement_import__id +msgid "ID" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_statement_import +msgid "Import Bank Statement Files" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model.fields,field_description:account_statement_import_coda.field_account_journal____last_update +#: model:ir.model.fields,field_description:account_statement_import_coda.field_account_statement_import____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:0 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_statement_import_coda/i18n/ca_ES.po b/account_statement_import_coda/i18n/ca_ES.po new file mode 100644 index 000000000..305404ad2 --- /dev/null +++ b/account_statement_import_coda/i18n/ca_ES.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_coda +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-25 05:47+0000\n" +"PO-Revision-Date: 2017-03-25 05:47+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Catalan (Spain) (https://www.transifex.com/oca/teams/23907/" +"ca_ES/)\n" +"Language: ca_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" + +#. module: account_statement_import_coda +#: model_terms:ir.ui.view,arch_db:account_statement_import_coda.account_statement_import_view +msgid "Coded statement of account (.coda)" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:154 +#, python-format +msgid "Communication" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:139 +#, python-format +msgid "Counter Party" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:142 +#, python-format +msgid "Counter Party Account" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:145 +#, python-format +msgid "Counter Party Address" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_statement_import +msgid "Import Bank Statement" +msgstr "Importar extracte bancari" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:63 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_statement_import_coda/i18n/de.po b/account_statement_import_coda/i18n/de.po new file mode 100644 index 000000000..9271792d7 --- /dev/null +++ b/account_statement_import_coda/i18n/de.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_coda +# +# Translators: +# Akim Juillerat , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-10 03:20+0000\n" +"PO-Revision-Date: 2016-12-10 03:20+0000\n" +"Last-Translator: Akim Juillerat , 2016\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\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" + +#. module: account_statement_import_coda +#: model_terms:ir.ui.view,arch_db:account_statement_import_coda.account_statement_import_view +msgid "Coded statement of account (.coda)" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:154 +#, python-format +msgid "Communication" +msgstr "Kommunikation" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:139 +#, python-format +msgid "Counter Party" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:142 +#, python-format +msgid "Counter Party Account" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:145 +#, python-format +msgid "Counter Party Address" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_statement_import +msgid "Import Bank Statement" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:63 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_statement_import_coda/i18n/fi.po b/account_statement_import_coda/i18n/fi.po new file mode 100644 index 000000000..3d5d6dafa --- /dev/null +++ b/account_statement_import_coda/i18n/fi.po @@ -0,0 +1,67 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_coda +# +# Translators: +# Jarmo Kortetj??rvi , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-10 03:47+0000\n" +"PO-Revision-Date: 2017-01-10 03:47+0000\n" +"Last-Translator: Jarmo Kortetj??rvi , 2017\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\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" + +#. module: account_statement_import_coda +#: model_terms:ir.ui.view,arch_db:account_statement_import_coda.account_statement_import_view +msgid "Coded statement of account (.coda)" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:154 +#, python-format +msgid "Communication" +msgstr "Viestint??" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:139 +#, python-format +msgid "Counter Party" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:142 +#, python-format +msgid "Counter Party Account" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:145 +#, python-format +msgid "Counter Party Address" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_statement_import +msgid "Import Bank Statement" +msgstr "Tuo pankkiaineisto" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:63 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_statement_import_coda/i18n/fr.po b/account_statement_import_coda/i18n/fr.po new file mode 100644 index 000000000..f9e5f4692 --- /dev/null +++ b/account_statement_import_coda/i18n/fr.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_coda +# +# Translators: +# OCA Transbot , 2016 +# Hosni Hadj Taher , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-04 02:35+0000\n" +"PO-Revision-Date: 2017-02-04 02:35+0000\n" +"Last-Translator: Hosni Hadj Taher , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\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" + +#. module: account_statement_import_coda +#: model_terms:ir.ui.view,arch_db:account_statement_import_coda.account_statement_import_view +msgid "Coded statement of account (.coda or .CD2)" +msgstr "Relev?? de compte cod?? (.coda ou .CD2)" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:154 +#, python-format +msgid "Communication" +msgstr "Communication" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:139 +#, python-format +msgid "Counter Party" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:142 +#, python-format +msgid "Counter Party Account" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:145 +#, python-format +msgid "Counter Party Address" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_statement_import +msgid "Import Bank Statement" +msgstr "Import Relev?? bancaire" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:63 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_statement_import_coda/i18n/nl_NL.po b/account_statement_import_coda/i18n/nl_NL.po new file mode 100644 index 000000000..7dde374bc --- /dev/null +++ b/account_statement_import_coda/i18n/nl_NL.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_statement_import_coda +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-03 02:36+0000\n" +"PO-Revision-Date: 2017-06-03 02:36+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_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" + +#. module: account_statement_import_coda +#: model_terms:ir.ui.view,arch_db:account_statement_import_coda.account_statement_import_view +msgid "Coded statement of account (.coda)" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:154 +#, python-format +msgid "Communication" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:139 +#, python-format +msgid "Counter Party" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:142 +#, python-format +msgid "Counter Party Account" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:145 +#, python-format +msgid "Counter Party Address" +msgstr "" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_statement_import +msgid "Import Bank Statement" +msgstr "Importeer Bankafschrift" + +#. module: account_statement_import_coda +#: model:ir.model,name:account_statement_import_coda.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_statement_import_coda +#: code:addons/account_statement_import_coda/wizard/account_statement_import_coda.py:63 +#, python-format +msgid "" +"The following problem occurred during import. The file might not be valid.\n" +"\n" +" %s" +msgstr "" diff --git a/account_statement_import_coda/models/__init__.py b/account_statement_import_coda/models/__init__.py new file mode 100644 index 000000000..9f3dd7956 --- /dev/null +++ b/account_statement_import_coda/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2015-2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_journal diff --git a/account_statement_import_coda/models/account_journal.py b/account_statement_import_coda/models/account_journal.py new file mode 100644 index 000000000..49bd1b712 --- /dev/null +++ b/account_statement_import_coda/models/account_journal.py @@ -0,0 +1,10 @@ +from odoo import models + + +class AccountJournal(models.Model): + _inherit = "account.journal" + + def _get_bank_statements_available_import_formats(self): + formats_list = super()._get_bank_statements_available_import_formats() + formats_list.append("coda") + return formats_list diff --git a/account_statement_import_coda/readme/CONTRIBUTORS.rst b/account_statement_import_coda/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..cc24cc129 --- /dev/null +++ b/account_statement_import_coda/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Laurent Mignon +* Stéphane Bidoul `__ as parser. + +Expected benefits: + +* The pycoda parser is a better-tested external python lib. +* Better separation between file parsing and mapping of these data in Odoo. +* The module only depends of account_bank_statement_import. diff --git a/account_statement_import_coda/readme/INSTALL.rst b/account_statement_import_coda/readme/INSTALL.rst new file mode 100644 index 000000000..0b0261459 --- /dev/null +++ b/account_statement_import_coda/readme/INSTALL.rst @@ -0,0 +1 @@ +To install this module, you need to install the python library `pycoda `__. diff --git a/account_statement_import_coda/static/description/icon.png b/account_statement_import_coda/static/description/icon.png new file mode 100644 index 000000000..3f375149b Binary files /dev/null and b/account_statement_import_coda/static/description/icon.png differ diff --git a/account_statement_import_coda/static/description/index.html b/account_statement_import_coda/static/description/index.html new file mode 100644 index 000000000..35bc70456 --- /dev/null +++ b/account_statement_import_coda/static/description/index.html @@ -0,0 +1,435 @@ + + + + + + +Import CODA Bank Statement + + + +
+

Import CODA Bank Statement

+ + +

Beta License: AGPL-3 OCA/l10n-belgium Translate me on Weblate Try me on Runbot

+

This module allows you to import your bank transactions with a standard +CODA file (you’ll find samples in the ‘data’ folder).

+

This module was renamed in v14 to follow the behavior of the parent OCA module account_statement_module.

+

This is an alternative to the l10n_be_coda module in Odoo Enterprise. +It uses the external python lib pycoda as parser.

+

Expected benefits:

+
    +
  • The pycoda parser is a better-tested external python lib.
  • +
  • Better separation between file parsing and mapping of these data in Odoo.
  • +
  • The module only depends of account_bank_statement_import.
  • +
+

Table of contents

+ +
+

Installation

+

To install this module, you need to install the python library pycoda.

+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

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/l10n-belgium 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_coda/test_coda_file/Ontvangen_CODA.2012-01-11-18.59.15.txt b/account_statement_import_coda/test_coda_file/Ontvangen_CODA.2012-01-11-18.59.15.txt new file mode 100644 index 000000000..5fdcf509e --- /dev/null +++ b/account_statement_import_coda/test_coda_file/Ontvangen_CODA.2012-01-11-18.59.15.txt @@ -0,0 +1,24 @@ +0000011011272505 00178299 DE MEYER LUC KREDBEBB 00820512012 00000 2 +12135BE46737018594236 EUR0000000011812700270710NOVIAT NV KBC-Business Comfortrekening 003 +2100010000OL44483FW SCTOFBIONLO1000000000435000110112001010000MEDEDELING 11011213501 0 +2200010000 GKCCBEBB 1 0 +2300010000BE41063012345610 PARTNER 1 0 1 +3100010001OL44483FW SCTOFBIONLO001010001001PARTNER 1 0 0 +2100020000OL4414AC8BOVSOVSOVERS0000000003044450110112001500001101240283842818 11011213501 0 +2200020000 BBRUBEBB 1 0 +2300020000BE61310126985517 PARTNER 2 0 1 +3100020001OL4414AC8BOVSOVSOVERS001500001001PARTNER 2 1 0 +3200020001MOLENSTRAAT 60 9340 LEDE 0 0 +2100030000AFECA0BIS IKLINNINBIS1000000000479040110112313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011213510 0 +2100030001AFECA0BIS IKLINNINBIS1000000000419920120111813410660 11011213500 0 +2100030002AFECA0BIS IKLINNINBIS1000000000059120120111813410020 11011213510 0 +2100040000AFECA0CVA IKLINNINNIG1000000000479040110112313410000 KBC-INVESTERINGSKREDIET 737-6543210-21 11011213510 0 +2100040001AFECA0CVA IKLINNINNIG1000000000419920120111813410660 11011213500 0 +2100040002AFECA0CVA IKLINNINNIG1000000000059120120111813410020 11011213510 0 +2100050000AOGM00160BSCTOBOGOVER0000000000063740110112001500000TERUGGAVE 37232481 8400083296 . 11011213501 0 +2200050000 362/363 KREDBEBB 1 0 +2300050000BE43730004200601 KBC VERZEKERINGEN NV 0 1 +3100050001AOGM00160BSCTOBOGOVER001500001001KBC VERZEKERINGEN NV 1 0 +3200050001VAN OVERSTRAETENPLEIN 2 3000 LEUVEN 0 0 +8135BE44734024486445 EUR0000000013646050110112 0 +9 000022000000001393080000000003108190 2 diff --git a/account_statement_import_coda/tests/__init__.py b/account_statement_import_coda/tests/__init__.py new file mode 100644 index 000000000..48234bd01 --- /dev/null +++ b/account_statement_import_coda/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2015-2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_import_statement diff --git a/account_statement_import_coda/tests/test_import_statement.py b/account_statement_import_coda/tests/test_import_statement.py new file mode 100644 index 000000000..3fac850c9 --- /dev/null +++ b/account_statement_import_coda/tests/test_import_statement.py @@ -0,0 +1,95 @@ +# Copyright 2015-2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import base64 + +from markupsafe import Markup + +from odoo.exceptions import UserError +from odoo.modules.module import get_module_resource +from odoo.tests.common import TransactionCase +from odoo.tools import float_compare + + +class TestCodaFile(TransactionCase): + """Tests for import bank statement coda file format + (account.statement.import) + """ + + def setUp(self): + super().setUp() + bank_account = self.env["res.partner.bank"].create( + { + "acc_number": "BE46737018594236", + "bank_bic": "KREDBEBB", + "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, + } + ) + eur = self.env.ref("base.EUR") + journal_vals = { + "name": "Bank Journal - (test coda)", + "code": "TBNK", + "type": "bank", + "bank_account_id": bank_account.id, + } + if self.env.company.currency_id != eur: + # coda files are in EUR + journal_vals.update({"currency_id": eur.id}) + self.journal = self.env["account.journal"].create(journal_vals) + self.statement_import_model = self.env["account.statement.import"] + self.bank_statement_model = self.env["account.bank.statement"] + coda_file_path = get_module_resource( + "account_statement_import_coda", + "test_coda_file", + "Ontvangen_CODA.2012-01-11-18.59.15.txt", + ) + self.coda_file = base64.b64encode(open(coda_file_path, "rb").read()) + + def test_coda_file_import(self): + bank_statement_import = self.statement_import_model.create( + { + "statement_file": self.coda_file, + "statement_filename": "Coda test file", + } + ) + bank_statement_import.import_file_button() + bank_st_record = self.bank_statement_model.search([("name", "=", "2012/135")])[ + 0 + ] + self.assertEqual( + float_compare(bank_st_record.balance_start, 11812.70, precision_digits=2), + 0, + ) + self.assertEqual( + float_compare( + bank_st_record.balance_end_real, 13646.05, precision_digits=2 + ), + 0, + ) + + # check the note + self.assertEqual( + Markup( + "

Counter Party: PARTNER 2\n" + "Counter Party Account: BE61310126985517\n" + "Communication: +++240/2838/42818+++ " + "001PARTNER 2MOLENSTRAAT 60 9340 LEDE

" + ), + bank_st_record.line_ids[1].narration, + "The note should contain informations on the counter part " + "but also the communication for the information records that " + "refer the movement record", + ) + + def test_coda_file_import_twice(self): + bank_statement_import = self.statement_import_model.create( + { + "statement_file": self.coda_file, + "statement_filename": "Coda test file", + } + ) + bank_statement_import.import_file_button() + with self.assertRaises(UserError): + bank_statement_import.import_file_button() diff --git a/account_statement_import_coda/wizard/__init__.py b/account_statement_import_coda/wizard/__init__.py new file mode 100644 index 000000000..f52f62a03 --- /dev/null +++ b/account_statement_import_coda/wizard/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2015-2016 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import account_statement_import_coda diff --git a/account_statement_import_coda/wizard/account_statement_import_coda.py b/account_statement_import_coda/wizard/account_statement_import_coda.py new file mode 100644 index 000000000..6b8616483 --- /dev/null +++ b/account_statement_import_coda/wizard/account_statement_import_coda.py @@ -0,0 +1,205 @@ +# Copyright 2015-2017 ACSONE SA/NV () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import datetime +import logging +import re + +from dateutil import parser as date_parser + +from odoo import _, api, models +from odoo.exceptions import Warning as UserError + +_logger = logging.getLogger(__name__) + +try: + from coda.parser import Parser + from coda.statement import AmountSign, MovementRecordType +except ImportError: + _logger.error( + "CODA parser unavailable because the `pycoda` Python library cannot " + "be found. It can be downloaded and installed from " + "`https://pypi.python.org/pypi/pycoda`." + ) + Parser = None + + +class AccountStatementImport(models.TransientModel): + _inherit = "account.statement.import" + + def _check_coda(self, data_file): + if Parser is None: + return False + try: + # Matches the first 24 characters of a CODA file, as defined by + # the febelfin specifications + return re.match(rb"0{5}\d{9}05[ D] {7}", data_file) is not None + except Exception: + return False + + def _get_acc_number(self, acc_number): + # fix for Triodos Bank coda file + # Check if we match the exact acc_number or the end of an acc number + # in order to return the iban number when the coda + journal = self.env["account.journal"].search( + [("bank_acc_number", "=like", "%" + acc_number)] + ) + # if not found or ambiguious + if not journal or len(journal) > 1: + return acc_number + + return journal.bank_acc_number + + @api.model + def _parse_file(self, data_file): + if not self._check_coda(data_file): + return super()._parse_file(data_file) + vals_bank_statements = [] + try: + statements = Parser().parse(data_file) + for statement in statements: + vals_bank_statements.append(self.get_st_vals(statement)) + except Exception as e: + _logger.exception("Error when parsing coda file") + raise UserError( + _( + "The following problem occurred during import. " + "The file might not be valid.\n\n %s" + ) + % e + ) from e + + acc_number = None + currency = None + if statements: + acc_number = statements[0].acc_number + currency = statement.currency + return currency, self._get_acc_number(acc_number), vals_bank_statements + + def get_st_vals(self, statement): + """ + This method return a dict of vals that can be passed to + create method of statement. + :return: dict of vals that represent additional infos for the statement + found in the file. + { + 'name': paper_seq_number + 'balance_start': balance_start, + 'balance_end_real': balance_end_real, + 'transactions': transactions + } + """ + balance_start = statement.old_balance + if statement.old_balance_amount_sign == AmountSign.DEBIT: + balance_start = -balance_start + balance_end_real = statement.new_balance + if statement.new_balance_amount_sign == AmountSign.DEBIT: + balance_end_real = -balance_end_real + transactions = [] + statement_date = statement.new_balance_date + vals = { + "balance_start": balance_start, + "balance_end_real": balance_end_real, + "date": statement_date, + "transactions": transactions, + } + name = statement.paper_seq_number + if name: + year = "" + if statement_date: + parsed_date = date_parser.parse(statement_date) + year = "%s/" % parsed_date.year + vals.update({"name": "{}{}".format(year, statement.paper_seq_number)}) + + globalisation_dict = { + st.ref_move: st + for st in statement.movements + if st.type == MovementRecordType.GLOBALISATION + } + information_dict = {} + # build a dict of information by transaction_ref. The transaction_ref + # refers to the transaction_ref of a movement record + for info_line in statement.informations: + infos = information_dict.setdefault(info_line.transaction_ref, []) + infos.append(info_line) + + for sequence, line in enumerate( + filter( + lambda l: l.type != MovementRecordType.GLOBALISATION, + statement.movements, + ) + ): + info = self.get_st_line_vals(line, globalisation_dict, information_dict) + info["sequence"] = sequence + info["unique_import_id"] = ( + statement.coda_seq_number + + "-" + + statement.old_balance_date + + "-" + + statement.new_balance_date + + "-" + + info["unique_import_id"] + ) + transactions.append(info) + return vals + + def get_st_line_note(self, line, information_dict): + """This method returns a formatted note from line information""" + note = [] + if line.counterparty_name: + note.append(_("Counter Party") + ": " + line.counterparty_name) + if line.counterparty_number: + note.append(_("Counter Party Account") + ": " + line.counterparty_number) + if line.counterparty_address: + note.append(_("Counter Party Address") + ": " + line.counterparty_address) + infos = information_dict.get(line.transaction_ref, []) + if line.communication or infos: + communications = [] + if line.communication: + communications.append(line.communication) + for info in infos: + communications.append(info.communication) + note.append(_("Communication") + ": " + " ".join(communications)) + return note and "\n".join(note) or None + + def get_st_line_vals(self, line, globalisation_dict, information_dict): + """ + This method must return a dict of vals that can be passed to create + method of statement line in order to record it. It is the + responsibility of every parser to give this dict of vals, + so each one can implement his own way of recording the lines. + :param: line: a dict of vals that represent a line of + result_row_list + :return: dict of values to give to the create method of + statement line, + it MUST contain at least: + { + 'date':value, + 'amount':value, + 'payment_ref':value, + } + """ + amount = line.transaction_amount + if line.transaction_amount_sign == AmountSign.DEBIT: + amount = -amount + return { + "date": line.entry_date or datetime.datetime.now().date(), + "amount": amount, + "payment_ref": line.communication or line.ref, + "ref": line.ref, + "partner_name": line.counterparty_name or None, + "account_number": line.counterparty_number or None, + "narration": self.get_st_line_note(line, information_dict), + "unique_import_id": line.ref + + "-" + + line.transaction_ref + + "-" + + line.transaction_date, + } + + @api.model + def _complete_statement(self, stmts_vals, journal_id, account_number): + stmts_vals = super()._complete_statement(stmts_vals, journal_id, account_number) + journal = self.env["account.journal"].browse(journal_id) + stmts_vals["name"] = "{}/{}".format(journal.code, stmts_vals["name"]) + return stmts_vals diff --git a/account_statement_import_coda/wizard/account_statement_import_coda_view.xml b/account_statement_import_coda/wizard/account_statement_import_coda_view.xml new file mode 100644 index 000000000..e638a901c --- /dev/null +++ b/account_statement_import_coda/wizard/account_statement_import_coda_view.xml @@ -0,0 +1,15 @@ + + + + account.statement.import + + + +
  • Coded statement of account (.coda or .CD2)
  • +
    +
    +
    +
    diff --git a/requirements.txt b/requirements.txt index a23257d63..28d399c07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ # generated from manifests external_dependencies +pycoda zeep diff --git a/setup/account_statement_import_coda/odoo/addons/account_statement_import_coda b/setup/account_statement_import_coda/odoo/addons/account_statement_import_coda new file mode 120000 index 000000000..97f9b90af --- /dev/null +++ b/setup/account_statement_import_coda/odoo/addons/account_statement_import_coda @@ -0,0 +1 @@ +../../../../account_statement_import_coda \ No newline at end of file diff --git a/setup/account_statement_import_coda/setup.py b/setup/account_statement_import_coda/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/account_statement_import_coda/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)