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

Subscribers

People subscribed via source and target branches

to status/vote changes: