-
-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,103 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
:target: https://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
==================== | ||
Bank Statement MT940 | ||
==================== | ||
|
||
This module provides a generic parser for MT940 files. Given that MT940 is a | ||
non-open non-standard of pure evil in the way that every bank cooks up its own | ||
interpretation of it, this addon alone won't help you much. It is rather | ||
intended to be used by other addons to implement the dialect specific to a | ||
certain bank. | ||
|
||
See account_bank_statement_import_mt940_nl_ing for an example on how to use it. | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
* None | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
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. If you spotted it first, | ||
help us smash it by providing detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Stefan Rijnhart <srijnhart@therp.nl> | ||
* Ronald Portier <rportier@therp.nl> | ||
* Andrea Stirpe <a.stirpe@onestein.nl> | ||
* Fekete Mihai <mihai.fekete@gmail.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (C) 2013-2015 Therp BV <http://therp.nl> | ||
|
||
{ | ||
'name': 'MT940 Bank Statements Import', | ||
'version': '12.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': 'Odoo Community Association (OCA), Therp BV', | ||
'website': 'https://github.com/OCA/bank-statement-import', | ||
'category': 'Banking addons', | ||
'depends': [ | ||
'account_bank_statement_import', | ||
], | ||
'installable': True | ||
} |
14 changes: 14 additions & 0 deletions
14
account_bank_statement_import_mt940_base/i18n/account_bank_statement_import_mt940_base.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import account_bank_statement_import | ||
from . import account_journal | ||
from . import mt940 |
41 changes: 41 additions & 0 deletions
41
account_bank_statement_import_mt940_base/models/account_bank_statement_import.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2019 OdooERP Romania <https://odooerpromania.ro> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
import logging | ||
from io import BytesIO | ||
import zipfile | ||
from odoo import api, models | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class AccountBankStatementImport(models.TransientModel): | ||
_inherit = 'account.bank.statement.import' | ||
|
||
@api.model | ||
def _parse_file(self, data_file): | ||
"""Parse a MT940 file. | ||
For different type of MT940 statement add the type in the context. | ||
and check methods return depending on get_mt940_type() """ | ||
try: | ||
parser = self.env['account.bank.statement.import.mt940.parser'] | ||
_logger.debug("Try parsing with mt940.") | ||
parser = parser.with_context(type='mt940_general') | ||
return parser.parse(data_file) | ||
except ValueError: | ||
try: | ||
with zipfile.ZipFile(BytesIO(data_file)) as data: | ||
currency = None | ||
account_number = None | ||
transactions = [] | ||
for member in data.namelist(): | ||
currency, account_number, new = self._parse_file( | ||
data.open(member).read() | ||
) | ||
transactions.extend(new) | ||
return currency, account_number, transactions | ||
except (zipfile.BadZipFile, ValueError): | ||
pass | ||
# Not a mt940 file, returning super will call next candidate: | ||
_logger.debug("Statement file was not a mt940 file.", | ||
exc_info=True) | ||
return super(AccountBankStatementImport, self)._parse_file(data_file) |
14 changes: 14 additions & 0 deletions
14
account_bank_statement_import_mt940_base/models/account_journal.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2019 OdooERP Romania <https://odooerpromania.ro> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models, _ | ||
|
||
|
||
class AccountJournal(models.Model): | ||
_inherit = "account.journal" | ||
|
||
def _get_bank_statements_available_import_formats(self): | ||
res = super(AccountJournal, self).\ | ||
_get_bank_statements_available_import_formats() | ||
res.extend([_('mt940')]) | ||
return res |
Oops, something went wrong.