From 41057b0e31f18e907691edb6cb9f7e1ab64c5b52 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 26 Feb 2014 16:42:31 +0100 Subject: [PATCH] [ADD] account_banking_nl_ing_mt940 --- account_banking_nl_ing_mt940/__init__.py | 21 +++++ account_banking_nl_ing_mt940/__openerp__.py | 47 ++++++++++ .../account_banking_nl_ing_mt940.py | 88 ++++++++++++++++++ .../static/src/img/icon.png | Bin 0 -> 1142 bytes 4 files changed, 156 insertions(+) create mode 100644 account_banking_nl_ing_mt940/__init__.py create mode 100644 account_banking_nl_ing_mt940/__openerp__.py create mode 100644 account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py create mode 100644 account_banking_nl_ing_mt940/static/src/img/icon.png diff --git a/account_banking_nl_ing_mt940/__init__.py b/account_banking_nl_ing_mt940/__init__.py new file mode 100644 index 000000000..3b6be506a --- /dev/null +++ b/account_banking_nl_ing_mt940/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import account_banking_nl_ing_mt940 diff --git a/account_banking_nl_ing_mt940/__openerp__.py b/account_banking_nl_ing_mt940/__openerp__.py new file mode 100644 index 000000000..2e5fa413d --- /dev/null +++ b/account_banking_nl_ing_mt940/__openerp__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name" : "MT940 import for Dutch ING", + "version" : "1.0", + "author" : "Therp BV", + "complexity": "normal", + "description": """ + This addons import the scructured MT940 format as offered by Dutch ING + """, + "category" : "Account Banking", + "depends" : [ + 'account_banking_mt940', + ], + "data" : [ + ], + "js": [ + ], + "css": [ + ], + "qweb": [ + ], + "auto_install": False, + "installable": True, + "application": False, + "external_dependencies" : { + 'python' : [], + }, +} diff --git a/account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py b/account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py new file mode 100644 index 000000000..de8f8c1fd --- /dev/null +++ b/account_banking_nl_ing_mt940/account_banking_nl_ing_mt940.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import re +from openerp.tools.translate import _ +from openerp.addons.account_banking.parsers.models import parser +from openerp.addons.account_banking_mt940.mt940 import MT940, str2float + + +class IngMT940Parser(MT940, parser): + name = _('ING MT940 (structured)') + country_code = 'NL' + code = 'INT_MT940_STRUC' + + tag_61_regex = re.compile( + '^(?P\d{6})(?P[CD])(?P\d+,\d{2})N(?P\d{3})' + '(?P\w{1,16})') + + def handle_tag_60F(self, cr, data): + super(IngMT940Parser, self).handle_tag_60F(cr, data) + self.current_statement.id = '%s-%s' % ( + self.get_unique_account_identifier( + cr, self.current_statement.local_account), + self.current_statement.id) + + def handle_tag_61(self, cr, data): + super(IngMT940Parser, self).handle_tag_61(cr, data) + parsed_data = self.tag_61_regex.match(data).groupdict() + self.current_transaction.transferred_amount = \ + (-1 if parsed_data['sign'] == 'D' else 1) * str2float( + parsed_data['amount']) + self.current_transaction.reference = parsed_data['reference'] + + def handle_tag_86(self, cr, data): + if not self.current_transaction: + return + super(IngMT940Parser, self).handle_tag_86(cr, data) + codewords = ['RTRN', 'BENM', 'ORDP', 'CSID', 'BUSP', 'MARF', 'EREF', + 'PREF', 'REMI', 'ID', 'PURP', 'ULTB', 'ULTD'] + subfields = {} + current_codeword = None + for word in data.split('/'): + if not word and not current_codeword: + continue + if word in codewords: + current_codeword = word + subfields[current_codeword] = [] + continue + subfields[current_codeword].append(word) + + if 'BENM' in subfields: + self.current_transaction.remote_account = subfields['BENM'][0] + self.current_transaction.remote_bank_bic = subfields['BENM'][1] + self.current_transaction.remote_owner = subfields['BENM'][2] + self.current_transaction.remote_owner_city = subfields['BENM'][3] + + if 'ORDP' in subfields: + self.current_transaction.remote_account = subfields['ORDP'][0] + self.current_transaction.remote_bank_bic = subfields['ORDP'][1] + self.current_transaction.remote_owner = subfields['ORDP'][2] + self.current_transaction.remote_owner_city = subfields['ORDP'][3] + + if 'REMI' in subfields: + self.current_transaction.message = '/'.join( + filter(lambda x: bool(x), subfields['REMI'])) + + if self.current_transaction.reference in subfields: + self.current_transaction.reference = ''.join( + subfields[self.current_transaction.reference]) + + self.current_transaction = None diff --git a/account_banking_nl_ing_mt940/static/src/img/icon.png b/account_banking_nl_ing_mt940/static/src/img/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4c7ab302908e114888446d84d3493fa726033c1f GIT binary patch literal 1142 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r53?z4+XPOVBSkfJR9T^xl_H+M9WCijWi-X*q z7}lMWc?skwBzpw;GB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZkpuXS$ zpAc7|0+Vy!%`Sd3J@*~Rz=H@Xz@vBMNCCrhU++~OAXQKjgnPb5^?zLm6yRy4l)f7mx|d; zx?*(k%?4)UEmyi0Ecrc2=k&YFn|8nX@qd4)(saLN%zo##oL4V9SpH%8W(I{5_Kby- zneS~VhopAyb6lBS&$U5E`gKppbdV7NQIC+SE zKe2ts8LoR*Hw$jqcIEDHSU_mi4;HoUDLTgOJMIHx zO|`@|q9i4;B-JXpC>2OC7#SEE>l#?<8d`)H8e5qfSQ#5>8yHy`7