Merge lp:~therp-nl/banking-addons/7.0_mt940_structured into lp:banking-addons

Proposed by Ronald Portier (Therp)
Status: Rejected
Rejected by: Holger Brunn (Therp)
Proposed branch: lp:~therp-nl/banking-addons/7.0_mt940_structured
Merge into: lp:banking-addons
Diff against target: 222 lines (+196/-0)
4 files modified
account_banking_mt940/mt940.py (+1/-0)
account_banking_nl_rabo_mt940/__init__.py (+21/-0)
account_banking_nl_rabo_mt940/__openerp__.py (+48/-0)
account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py (+126/-0)
To merge this branch: bzr merge lp:~therp-nl/banking-addons/7.0_mt940_structured
Reviewer Review Type Date Requested Status
Banking Addons Core Editors Pending
Review via email: mp+225805@code.launchpad.net

Description of the change

Support Dutch Rabobank MT940 structured format.

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks! We moved to GitHub, please duplicate here: https://github.com/OCA/banking

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Unmerged revisions

268. By Ronald Portier (Therp)

[ENH] Module account_banking_nl_rabo_mt940:
    - new name for module, similar to othet mt940 modules;
    - get bank account, partner name and partner address from import file;
    - merge fix to support fieldname value_date.

267. By Ronald Portier (Therp)

[ENH] Module account_banking_nl_rabo_mt940:
    - Renamed module for importing Rabo dialect of mt940 structured.
    - Applied flake8 recommendations.

266. By Holger Brunn (Therp)

[IMP] adapt to rabobank dialect

265. By Ronald Portier (Therp)

[WIP] Module account_banking_nl_mt940_structured:
    - Added new module to handle mt940 structured file for Rabobank.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_banking_mt940/mt940.py'
--- account_banking_mt940/mt940.py 2014-06-19 14:14:11 +0000
+++ account_banking_mt940/mt940.py 2014-07-07 11:13:52 +0000
@@ -186,6 +186,7 @@
186 self.current_transaction = transaction186 self.current_transaction = transaction
187 transaction.execution_date = str2date(data[:6])187 transaction.execution_date = str2date(data[:6])
188 transaction.effective_date = str2date(data[:6])188 transaction.effective_date = str2date(data[:6])
189 transaction.value_date = str2date(data[:6])
189 '...and the rest already is highly bank dependent'190 '...and the rest already is highly bank dependent'
190191
191 def handle_tag_86(self, cr, data):192 def handle_tag_86(self, cr, data):
192193
=== added directory 'account_banking_nl_rabo_mt940'
=== added file 'account_banking_nl_rabo_mt940/__init__.py'
--- account_banking_nl_rabo_mt940/__init__.py 1970-01-01 00:00:00 +0000
+++ account_banking_nl_rabo_mt940/__init__.py 2014-07-07 11:13:52 +0000
@@ -0,0 +1,21 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21from . import account_banking_nl_rabo_mt940
022
=== added file 'account_banking_nl_rabo_mt940/__openerp__.py'
--- account_banking_nl_rabo_mt940/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_banking_nl_rabo_mt940/__openerp__.py 2014-07-07 11:13:52 +0000
@@ -0,0 +1,48 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{
22 "name": "MT940 import for dutch Rabobank",
23 "version": "1.1",
24 "author": "Therp BV",
25 "complexity": "normal",
26 "description": """
27This addon imports the structured MT940 format as offered by the dutch
28 Rabobank.
29 """,
30 "category": "Account Banking",
31 "depends": [
32 'account_banking_mt940',
33 ],
34 "data": [
35 ],
36 "js": [
37 ],
38 "css": [
39 ],
40 "qweb": [
41 ],
42 "auto_install": False,
43 "installable": True,
44 "application": False,
45 "external_dependencies": {
46 'python': [],
47 },
48}
049
=== added file 'account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py'
--- account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py 1970-01-01 00:00:00 +0000
+++ account_banking_nl_rabo_mt940/account_banking_nl_rabo_mt940.py 2014-07-07 11:13:52 +0000
@@ -0,0 +1,126 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2014 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21import re
22from openerp.tools.translate import _
23from openerp.addons.account_banking.parsers.models import parser,\
24 mem_bank_transaction
25from openerp.addons.account_banking_mt940.mt940 import MT940, str2float
26
27
28class transaction(mem_bank_transaction):
29 def is_valid(self):
30 '''allow transactions without remote account'''
31 return bool(self.execution_date) and bool(self.transferred_amount)
32
33
34class RaboMT940Parser(MT940, parser):
35 name = _('MT940 Rabobank structured')
36 country_code = 'NL'
37 code = 'MT940 Rabobank'
38 header_lines = 1
39
40 tag_61_regex = re.compile(
41 '^(?P<date>\d{6})(?P<sign>[CD])(?P<amount>\d+,\d{2})N(?P<type>.{3})'
42 '(?P<reference>\w{1,16})')
43
44 def parse(self, cr, data):
45 'implements account_banking.parsers.models.parser.parse()'
46 res = super(RaboMT940Parser, self).parse(cr, data + '\n-XXX')
47 return res
48
49 def handle_tag_25(self, cr, data):
50 '''get account owner information'''
51 self.current_statement.local_account = data.split(' ')[0]
52
53 def create_transaction(self, cr):
54 return transaction()
55
56 def handle_tag_60F(self, cr, data):
57 super(RaboMT940Parser, self).handle_tag_60F(cr, data)
58 self.current_statement.id = '%s-%s' % (
59 self.get_unique_account_identifier(
60 cr, self.current_statement.local_account),
61 self.current_statement.id)
62
63 def handle_tag_61(self, cr, data):
64 super(RaboMT940Parser, self).handle_tag_61(cr, data)
65 parsed_data = self.tag_61_regex.match(data).groupdict()
66 self.current_transaction.transferred_amount = \
67 (-1 if parsed_data['sign'] == 'D' else 1) * str2float(
68 parsed_data['amount'])
69 reference = parsed_data['reference']
70 self.current_transaction.reference = reference
71 # Bank account is last field, following reference. In some cases
72 # there might be a reference of the other bank. In that case the
73 # reference will be followed by '//' and the 16 positions for the
74 # other bank;
75 account_start = data.find(reference)
76 if account_start >= 0:
77 # If no reference found, we can not determine bank-account.
78 account_start += len(reference)
79 # check for other bank
80 other_start = data.find('//')
81 if other_start >= 0:
82 account_start = other_start + 18
83 if account_start < len(data):
84 self.current_transaction.remote_account = (
85 data[account_start:].strip())
86
87 def handle_tag_86(self, cr, data):
88 if not self.current_transaction:
89 return
90 super(RaboMT940Parser, self).handle_tag_86(cr, data)
91 codewords = ['MARF', 'EREF', 'PREF', 'RTRN', 'ACCW', 'BENM',
92 'ORDP', 'NAME', 'ID', 'ADDR', 'REMI', 'CDTRREFTP',
93 'CD', 'SCOR', 'ISSR', 'CUR', 'CDTRREF', 'CSID', 'ISDT',
94 'ULTD', 'ULTB', 'PURP']
95 subfields = {}
96 current_codeword = None
97 for word in data.split('/'):
98 if not word and not current_codeword:
99 continue
100 if word in codewords:
101 current_codeword = word
102 subfields[current_codeword] = []
103 continue
104 if current_codeword in subfields:
105 subfields[current_codeword].append(word)
106
107 if 'NAME' in subfields:
108 self.current_transaction.remote_owner = (
109 ' '.join(subfields['NAME']))
110
111 if 'ADDR' in subfields:
112 # Do NOT join address fields, array is expected on other code!
113 self.current_transaction.remote_owner_address = subfields['ADDR']
114
115 if 'REMI' in subfields:
116 self.current_transaction.message = '/'.join(
117 filter(lambda x: bool(x), subfields['REMI']))
118
119 if self.current_transaction.reference in subfields:
120 self.current_transaction.reference = ''.join(
121 subfields[self.current_transaction.reference])
122
123 if not subfields:
124 self.current_transaction.message = data
125
126 self.current_transaction = None

Subscribers

People subscribed via source and target branches

to status/vote changes: