diff --git a/account_bank_statement_import_mt940_nl_mollie/README.rst b/account_bank_statement_import_mt940_nl_mollie/README.rst new file mode 100644 index 00000000..08410d5c --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/README.rst @@ -0,0 +1,78 @@ +===================================== +MT940 Bank Statements Import (Mollie) +===================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fbank--statement--import-lightgray.png?logo=github + :target: https://github.com/OCA/bank-statement-import/tree/10.0/account_bank_statement_import_mt940_nl_mollie + :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-10-0/bank-statement-import-10-0-account_bank_statement_import_mt940_nl_mollie + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/174/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to import MT940 statement files generated by `Mollie `_. + +**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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Therp BV + +Contributors +~~~~~~~~~~~~ + +* Holger Brunn + +Other credits +~~~~~~~~~~~~~ + +* Odoo Community Association: `Icon `_. + +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_bank_statement_import_mt940_nl_mollie/__init__.py b/account_bank_statement_import_mt940_nl_mollie/__init__.py new file mode 100644 index 00000000..cff20de5 --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/account_bank_statement_import_mt940_nl_mollie/__manifest__.py b/account_bank_statement_import_mt940_nl_mollie/__manifest__.py new file mode 100644 index 00000000..b60c6e3f --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/__manifest__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "MT940 Bank Statements Import (Mollie)", + "version": "10.0.1.0.0", + "author": "Therp BV,Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Banking Addons", + "website": "https://github.com/OCA/bank-statement-import", + "depends": [ + 'account_bank_statement_import_mt940_base', + ], + "data": [ + "views/account_bank_statement_import.xml", + ], +} diff --git a/account_bank_statement_import_mt940_nl_mollie/examples/Voorbeeld MT-940.mt940 b/account_bank_statement_import_mt940_nl_mollie/examples/Voorbeeld MT-940.mt940 new file mode 100644 index 00000000..03d2cec1 --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/examples/Voorbeeld MT-940.mt940 @@ -0,0 +1,48 @@ +:20:940A160901 +:25:NL30ABNA000000000000 +:28C:245/1 +:60F:C160901EUR0,00 +:61:1608310831C29,93NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL30ABNA000000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C42,93NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL30ABNA000000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C274,75NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C59,93NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C56,93NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/ABNANL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C40,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/ABNANL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C20,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/INGBNL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C19,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/INGBNL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C36,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/INGBNL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C68,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C12,00NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/INGBNL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C68,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C68,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C57,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/SNSBNL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C33,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/INGBNL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C32,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/ABNANL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C68,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C20,94NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/RABONL2U/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831C39,89NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/ABNANL2A/NAME/V. Oornaam/REMI/Order 123/EREF/tr_XXXXXXXXX +:61:1608310831D2392,21NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/INGBNL2A/NAME/V. Oornaam/REMI/REF 0000000.1608.01 UITBETALINGEN/EREF/000000.1608.01 +:61:1608310831D14,69NMSC +:86:/TRTP/SEPA OVERBOEKING/IBAN/NL80RABO0000000000/BIC/ABNANL2A/NAME/M +ollie B.V./REMI/Factuurnummer 2016.00000/EREF/NOTPROVIDED +:62F:D160901EUR1350,26 diff --git a/account_bank_statement_import_mt940_nl_mollie/models/__init__.py b/account_bank_statement_import_mt940_nl_mollie/models/__init__.py new file mode 100644 index 00000000..616ad71f --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import account_bank_statement_import diff --git a/account_bank_statement_import_mt940_nl_mollie/models/account_bank_statement_import.py b/account_bank_statement_import_mt940_nl_mollie/models/account_bank_statement_import.py new file mode 100644 index 00000000..a7caa15b --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/models/account_bank_statement_import.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +import logging +import re +from odoo import api, models +from odoo.addons.account_bank_statement_import_mt940_base.mt940 import\ + MT940, str2amount, get_subfields + + +_logger = logging.getLogger(__name__) + + +class MollieMT940(MT940): + + tag_61_regex = re.compile( + r'^(?P\d{6})(?P\d{4})(?P[CD])(?P\d+,\d{2})N' + r'(?P.{3})' + ) + + def __init__(self): + super(MollieMT940, self).__init__() + self.mt940_type = 'Mollie' + self.header_regex = '^:20:940' + self.header_lines = 0 + + def pre_process_data(self, data): + return [(data or '').replace('\r\n', '\n')] + + def is_mt940_statement(self, line): + if not line.startswith(':20:940'): + raise ValueError() + + def handle_tag_61(self, data): + """Handle tag 61: transaction data.""" + super(MollieMT940, self).handle_tag_61(data) + parsed_data = self.tag_61_regex.match(data).groupdict() + self.current_transaction['amount'] = str2amount( + parsed_data['sign'], parsed_data['amount'], + ) + + def handle_tag_86(self, data): + """Handle tag 86: transaction details""" + if not self.current_transaction: + return + codewords = ['TRTP', 'IBAN', 'BIC', 'NAME', 'REMI', 'EREF'] + subfields = get_subfields(data, codewords) + self.current_transaction['account_number'] = ''.join( + subfields.get('IBAN', []) + ) + self.current_transaction['partner_name'] = ''.join( + subfields.get('NAME', []) + ) + self.current_transaction['name'] = ''.join( + subfields.get('REMI', []) + ) + eref = ''.join(subfields.get('EREF', [])) + if eref != 'NOTPROVIDED': + self.current_transaction['ref'] = eref + + +class AccountBankStatementImport(models.TransientModel): + _inherit = 'account.bank.statement.import' + + @api.model + def _parse_file(self, data_file): + try: + _logger.debug('Try parsing as Mollie MT940 file') + return MollieMT940().parse(data_file) + except ValueError: + _logger.debug('Statement file was not a Mollie MT940 file') + return super(AccountBankStatementImport, self)._parse_file(data_file) diff --git a/account_bank_statement_import_mt940_nl_mollie/readme/CONTRIBUTORS.rst b/account_bank_statement_import_mt940_nl_mollie/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..b120a956 --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Holger Brunn diff --git a/account_bank_statement_import_mt940_nl_mollie/readme/CREDITS.rst b/account_bank_statement_import_mt940_nl_mollie/readme/CREDITS.rst new file mode 100644 index 00000000..cc056a80 --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/readme/CREDITS.rst @@ -0,0 +1 @@ +* Odoo Community Association: `Icon `_. diff --git a/account_bank_statement_import_mt940_nl_mollie/readme/DESCRIPTION.rst b/account_bank_statement_import_mt940_nl_mollie/readme/DESCRIPTION.rst new file mode 100644 index 00000000..c7e88b46 --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows you to import MT940 statement files generated by `Mollie `_. diff --git a/account_bank_statement_import_mt940_nl_mollie/static/description/icon.png b/account_bank_statement_import_mt940_nl_mollie/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/account_bank_statement_import_mt940_nl_mollie/static/description/icon.png differ diff --git a/account_bank_statement_import_mt940_nl_mollie/static/description/index.html b/account_bank_statement_import_mt940_nl_mollie/static/description/index.html new file mode 100644 index 00000000..b94b3bf7 --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +MT940 Bank Statements Import (Mollie) + + + +
+

MT940 Bank Statements Import (Mollie)

+ + +

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

+

This module allows you to import MT940 statement files generated by Mollie.

+

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

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Therp BV
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+
    +
  • Odoo Community Association: Icon.
  • +
+
+
+

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_bank_statement_import_mt940_nl_mollie/tests/__init__.py b/account_bank_statement_import_mt940_nl_mollie/tests/__init__.py new file mode 100644 index 00000000..dee7d56b --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import test_account_bank_statement_import_mt940_nl_mollie diff --git a/account_bank_statement_import_mt940_nl_mollie/tests/test_account_bank_statement_import_mt940_nl_mollie.py b/account_bank_statement_import_mt940_nl_mollie/tests/test_account_bank_statement_import_mt940_nl_mollie.py new file mode 100644 index 00000000..69c9301d --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/tests/test_account_bank_statement_import_mt940_nl_mollie.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.tools.misc import file_open +from odoo.tests.common import TransactionCase + + +class TestAccountBankStatementImportMt940NlMollie(TransactionCase): + def test_account_bank_statement_import_mt940_nl_mollie(self): + currency_code, account_number, statement_data = self.env[ + 'account.bank.statement.import' + ]._parse_file( + file_open( + 'account_bank_statement_import_mt940_nl_mollie/examples/' + 'Voorbeeld MT-940.mt940', + ).read(), + ) + self.assertEqual(currency_code, 'EUR') + self.assertEqual(account_number, 'NL30ABNA000000000000') + self.assertEqual(len(statement_data), 1) + statement = statement_data[0] + self.assertEqual(len(statement['transactions']), 21) + self.assertEqual(statement['balance_end_real'], -1350.26) + self.assertAlmostEqual( + statement['balance_end_real'], + sum(t['amount'] for t in statement['transactions']), + ) diff --git a/account_bank_statement_import_mt940_nl_mollie/views/account_bank_statement_import.xml b/account_bank_statement_import_mt940_nl_mollie/views/account_bank_statement_import.xml new file mode 100644 index 00000000..354c56c4 --- /dev/null +++ b/account_bank_statement_import_mt940_nl_mollie/views/account_bank_statement_import.xml @@ -0,0 +1,12 @@ + + + + account.bank.statement.import + + +
    +
  • MT940 (Mollie)
  • +
+
+
+