Merge lp:~therp-nl/account-banking/account-banking-abnamro-triodos into lp:account-banking

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 60
Proposed branch: lp:~therp-nl/account-banking/account-banking-abnamro-triodos
Merge into: lp:account-banking
Diff against target: 1225 lines (+1158/-0)
12 files modified
account_banking_nl_abnamro/__init__.py (+31/-0)
account_banking_nl_abnamro/__openerp__.py (+53/-0)
account_banking_nl_abnamro/abnamro.py (+287/-0)
account_banking_nl_abnamro/i18n/account_banking_nl_abnamro.pot (+84/-0)
account_banking_nl_abnamro/i18n/en.po (+84/-0)
account_banking_nl_abnamro/i18n/nl.po (+84/-0)
account_banking_nl_triodos/__init__.py (+31/-0)
account_banking_nl_triodos/__openerp__.py (+58/-0)
account_banking_nl_triodos/i18n/account_banking_nl_triodos.pot (+78/-0)
account_banking_nl_triodos/i18n/en.po (+78/-0)
account_banking_nl_triodos/i18n/nl.po (+77/-0)
account_banking_nl_triodos/triodos.py (+213/-0)
To merge this branch: bzr merge lp:~therp-nl/account-banking/account-banking-abnamro-triodos
Reviewer Review Type Date Requested Status
Pieter J. Kersten (EduSense BV) Needs Fixing
Review via email: mp+59147@code.launchpad.net

Description of the change

Hi Pieter,

here are our filters for Abnamro and Triodos. As you can see from the presence of the __openerp__.py files, this merge anticipates the upgrade to 6.0 but I suspect the filters will otherwise work with the current version of the framework.

Regards,
Stefan.

To post a comment you must log in.
Revision history for this message
Pieter J. Kersten (EduSense BV) (pieterj) wrote :

Hi Stefan,

Thanks for this contribution. There are however a few remarks that I would like to see fixed before merging.

1. There is indeed no reason why v5 users should not benefit from this. Please add a link from __openerp__.py to __terp__.py as well. There is still an active user base.

2. Unless there is some out-of-sight mechanism in the ABNAMRO interface that I'm missing, my guess is that it will prove to be very easy to generate different ID's for the same ABNAMRO transactions using different files with overlapping periods. This will lead to double and/or unresolved transactions. Please either clarify this external mechanism, or choose a more robust algorithm.

3. The datetime code in both modules stays unused and is therefore unneeded. Please remove it.

review: Needs Fixing
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

On 27-04-11 09:02, Pieter J. Kersten (EduSense BV) wrote:
> Review: Needs Fixing
> Hi Stefan,
>
> Thanks for this contribution. There are however a few remarks that I would like to see fixed before merging.
>

Hi Pieter,

thanks for your rapid response.

> 1. There is indeed no reason why v5 users should not benefit from this. Please add a link from __openerp__.py to __terp__.py as well. There is still an active user base.
>
OK, good idea to use a link.

> 2. Unless there is some out-of-sight mechanism in the ABNAMRO interface that I'm missing, my guess is that it will prove to be very easy to generate different ID's for the same ABNAMRO transactions using different files with overlapping periods. This will lead to double and/or unresolved transactions. Please either clarify this external mechanism, or choose a more robust algorithm.

Actually, in the case of ABNAMRO, the downloaded files always cover
periods of two calendar weeks so this is not a problem. In the case of
Triodos however, this is indeed an issue. In both cases, the file layout
is underspecified in that it does not specify a statement id, nor a
transaction id nor the current account balance. That makes it impossible
to distinguish similar payments (same remote account, remote owner,
amount, date and reference) from doubly loaded statement files.

The problem of files covering overlapping periods is not unique to these
filters however and occur equally in the multibank filter. Statement
files downloaded from SNS bank do carry a statement id, but the
transactions are selected by a period of time and do not cover complete
statements unless by chance.

The framework flags statement files whose first transactions occur at
the same date as 'known', which prevents the same file from being
processed again.
This is useful, but as the multibank format includes the account
balance, a checksum of each line would provide a more robust method of
identifying duplicate imports. In the case of Triodos however, this is
not possible. It is simply a limitation of the file layout.

> 3. The datetime code in both modules stays unused and is therefore unneeded. Please remove it.

Fine.

Regards,
Stefan.

--
Therp - Maatwerk in open ontwikkeling

Stefan Rijnhart - Ontwerp en implementatie

mail: <email address hidden>
tel: +31 (0) 614478606
web: http://therp.nl

59. By Stefan Rijnhart (Opener)

[IMP] added __terp__.py links to __openerp__.py for backwards compatibility
[IMP] removed loading of unused library

Revision history for this message
Pieter J. Kersten (EduSense BV) (pieterj) wrote :
Download full text (3.5 KiB)

Hi Stefan,

On 04-27-11 12:13 Stefan Rijnhart (Therp) wrote:
> On 27-04-11 09:02, Pieter J. Kersten (EduSense BV) wrote:
>> Review: Needs Fixing
>> Hi Stefan,
>>
>> Thanks for this contribution. There are however a few remarks that I would like to see fixed before merging.
> Hi Pieter,
>
> thanks for your rapid response.

You're welcome.
>> 1. There is indeed no reason why v5 users should not benefit from this. Please add a link from __openerp__.py to __terp__.py as well. There is still an active user base.
> OK, good idea to use a link.
>
>> 2. Unless there is some out-of-sight mechanism in the ABNAMRO interface that I'm missing, my guess is that it will prove to be very easy to generate different ID's for the same ABNAMRO transactions using different files with overlapping periods. This will lead to double and/or unresolved transactions. Please either clarify this external mechanism, or choose a more robust algorithm.
> Actually, in the case of ABNAMRO, the downloaded files always cover
> periods of two calendar weeks so this is not a problem. In the case of
Many companies check their bank accounts on a daily basis. How do you do
that given this approach?

> Triodos however, this is indeed an issue. In both cases, the file layout
> is underspecified in that it does not specify a statement id, nor a
> transaction id nor the current account balance. That makes it impossible
> to distinguish similar payments (same remote account, remote owner,
> amount, date and reference) from doubly loaded statement files.
Hence the task for parsers to deal with it.
> The problem of files covering overlapping periods is not unique to these
> filters however and occur equally in the multibank filter. Statement
> files downloaded from SNS bank do carry a statement id, but the
> transactions are selected by a period of time and do not cover complete
> statements unless by chance.
Multibank keeps a tracer per bank statement id, which is bank supplied.
That greatly minimizes chances on double ID's. If you think it can be
done better, you are right. I'm considering changes. It may however not
break current applications.
> The framework flags statement files whose first transactions occur at
> the same date as 'known', which prevents the same file from being
> processed again.
> This is useful, but as the multibank format includes the account
> balance, a checksum of each line would provide a more robust method of
> identifying duplicate imports. In the case of Triodos however, this is
> not possible. It is simply a limitation of the file layout.
In absence of a bank supplied statement id, it is wise to use the
transaction date as a prefix and add a tracer in there. It is common
practice that new statements are added to the end of transaction files.
Previous loaded statements then keep their generated ID within a days
period. When things get foul, mix ups are limited to a single day.

I'm considering a design change, where bank statements are day bound and
stay "open" until a newer has been created, leaving room for semi-real
time applications like web shops. This might force a rethinking of
numbering schemes for generators. Perhaps I will drop them alto...

Read more...

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

On 27-04-11 15:09, Pieter J. Kersten (EduSense BV) wrote:
>> Actually, in the case of ABNAMRO, the downloaded files always cover
>> periods of two calendar weeks so this is not a problem. In the case of
> Many companies check their bank accounts on a daily basis. How do you do
> that given this approach?
>
Hi Pieter,

In order to hook up to ABF, I would have thought that mimicing multibank
behaviour would result in an acceptable solution so I will again
emphasize the similarity between multibank and our approach. Like
multibank, you can import statements on a daily basis, and like
multibank this results in multiple statement files with the same id.
Only if the combination statement_id + date already exists does the
framework refuse to import this "known" statement. The only difference
is that for lack of a bank generated statement id, we generate our own
based on the weeknumbers derived per transaction from the transaction
date (we could also have chosen a two week span, as SNS bank statement
ids usually cover two weeks).

>
> In absence of a bank supplied statement id, it is wise to use the
> transaction date as a prefix and add a tracer in there. It is common
> practice that new statements are added to the end of transaction files.
> Previous loaded statements then keep their generated ID within a days
> period. When things get foul, mix ups are limited to a single day.

I can see that point. Although a small office we service already
complained about having to plough through the statements and confirm
them per week instead of the whole file covering several weeks at once ;-)

> I'm considering a design change, where bank statements are day bound and
> stay "open" until a newer has been created, leaving room for semi-real
> time applications like web shops. This might force a rethinking of
> numbering schemes for generators. Perhaps I will drop them altogether
> and generate them from within the ABF core instead.
Here again the needs of small and big 'shops' diverge. But I do think
that a solution should be implemented in the framework rather than the
parsers.

> Can you come up with some sort of numbering scheme that has a better
> resolution and is less file dependent? If you do, It will be my pleasure
> to add these modules to the ABF.
>
Can you please clarify what is file dependent in the current scheme?
Have you seen that any next transaction can trigger a new statement if
it is dated in a different calendar week?

Regards,
Stefan.

--
Therp - Maatwerk in open ontwikkeling

Stefan Rijnhart - Ontwerp en implementatie

mail: <email address hidden>
tel: +31 (0) 614478606
web: http://therp.nl

Revision history for this message
Pieter J. Kersten (EduSense BV) (pieterj) wrote :

Hmm, this is not a matter of "acceptable behavior" of some kind. Merely a matter of "getting the best possible, given current limitations". Please don't take this personally. Besides, the multibank parser is a bad comparison - it has its own limitations.

Ok, I can "accept" this as a workable solution given the problems at hand and similar limitations and solutions in the multibank module. Time to move on to SEPA.

Can you adapt points 1 and 3 I stated? If you do, I'll merge your modules into ABF.

Cheers,
--
Pieter J. Kersten

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

On 27-04-11 16:57, Pieter J. Kersten (EduSense BV) wrote:
> Hmm, this is not a matter of "acceptable behavior" of some kind. Merely a matter of "getting the best possible, given current limitations". Please don't take this personally. Besides, the multibank parser is a bad comparison - it has its own limitations.

Well, one of the limitations involved is my tunnel vision trying to make
something which is on a par with your code ;-)

> Ok, I can "accept" this as a workable solution given the problems at hand and similar limitations and solutions in the multibank module. Time to move on to SEPA.
>
> Can you adapt points 1 and 3 I stated? If you do, I'll merge your modules into ABF.
>
Thanks for the merge!

Regards,
Stefan.

--
Therp - Maatwerk in open ontwikkeling

Stefan Rijnhart - Ontwerp en implementatie

mail: <email address hidden>
tel: +31 (0) 614478606
web: http://therp.nl

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_banking_nl_abnamro'
2=== added file 'account_banking_nl_abnamro/__init__.py'
3--- account_banking_nl_abnamro/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_banking_nl_abnamro/__init__.py 2011-04-27 10:21:29 +0000
5@@ -0,0 +1,31 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
10+# and Therp BV (<http://therp.nl>)
11+# All Rights Reserved
12+#
13+# WARNING: This program as such is intended to be used by professional
14+# programmers who take the whole responsability of assessing all potential
15+# consequences resulting from its eventual inadequacies and bugs
16+# End users who are looking for a ready-to-use solution with commercial
17+# garantees and support are strongly adviced to contract EduSense BV
18+# or Therp BV
19+#
20+# This program is free software: you can redistribute it and/or modify
21+# it under the terms of the GNU General Public License as published by
22+# the Free Software Foundation, either version 3 of the License, or
23+# (at your option) any later version.
24+#
25+# This program is distributed in the hope that it will be useful,
26+# but WITHOUT ANY WARRANTY; without even the implied warranty of
27+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+# GNU General Public License for more details.
29+#
30+# You should have received a copy of the GNU General Public License
31+# along with this program. If not, see <http://www.gnu.org/licenses/>.
32+#
33+##############################################################################
34+import abnamro
35+
36+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
37
38=== added file 'account_banking_nl_abnamro/__openerp__.py'
39--- account_banking_nl_abnamro/__openerp__.py 1970-01-01 00:00:00 +0000
40+++ account_banking_nl_abnamro/__openerp__.py 2011-04-27 10:21:29 +0000
41@@ -0,0 +1,53 @@
42+##############################################################################
43+#
44+# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
45+# and Therp BV (<http://therp.nl>)
46+# All Rights Reserved
47+#
48+# WARNING: This program as such is intended to be used by professional
49+# programmers who take the whole responsability of assessing all potential
50+# consequences resulting from its eventual inadequacies and bugs
51+# End users who are looking for a ready-to-use solution with commercial
52+# garantees and support are strongly adviced to contract EduSense BV
53+# or Therp BV
54+#
55+# This program is free software: you can redistribute it and/or modify
56+# it under the terms of the GNU General Public License as published by
57+# the Free Software Foundation, either version 3 of the License, or
58+# (at your option) any later version.
59+#
60+# This program is distributed in the hope that it will be useful,
61+# but WITHOUT ANY WARRANTY; without even the implied warranty of
62+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63+# GNU General Public License for more details.
64+#
65+# You should have received a copy of the GNU General Public License
66+# along with this program. If not, see <http://www.gnu.org/licenses/>.
67+#
68+##############################################################################
69+{
70+ 'name': 'abnamro (NL) Bank Statements Import',
71+ 'version': '0.1',
72+ 'license': 'GPL-3',
73+ 'author': 'Therp BV / EduSense BV',
74+ 'website': 'https://launchpad.net/account-banking',
75+ 'category': 'Account Banking',
76+ 'depends': ['account_banking'],
77+ 'init_xml': [],
78+ 'update_xml': [
79+ #'security/ir.model.access.csv',
80+ ],
81+ 'demo_xml': [],
82+ 'description': '''
83+Import filter for abnamro (NL) bank transaction files (txt/tab format).
84+
85+No formal specifications of the file layout are released by abnamro. You can
86+help improve the performance of this import filter on
87+https://launchpad.net/account-banking.
88+
89+Imported bank transfers are organized in statements covering periods of one week,
90+even if the imported files cover a different period.
91+ ''',
92+ 'active': False,
93+ 'installable': True,
94+}
95
96=== added symlink 'account_banking_nl_abnamro/__terp__.py'
97=== target is u'__openerp__.py'
98=== added file 'account_banking_nl_abnamro/abnamro.py'
99--- account_banking_nl_abnamro/abnamro.py 1970-01-01 00:00:00 +0000
100+++ account_banking_nl_abnamro/abnamro.py 2011-04-27 10:21:29 +0000
101@@ -0,0 +1,287 @@
102+# -*- encoding: utf-8 -*-
103+##############################################################################
104+#
105+# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>)
106+# 2011 Therp BV (<http://therp.nl>)
107+# All Rights Reserved
108+#
109+# This program is free software: you can redistribute it and/or modify
110+# it under the terms of the GNU General Public License as published by
111+# the Free Software Foundation, either version 3 of the License, or
112+# (at your option) any later version.
113+#
114+# This program is distributed in the hope that it will be useful,
115+# but WITHOUT ANY WARRANTY; without even the implied warranty of
116+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117+# GNU General Public License for more details.
118+#
119+# You should have received a copy of the GNU General Public License
120+# along with this program. If not, see <http://www.gnu.org/licenses/>.
121+#
122+##############################################################################
123+
124+'''
125+This parser follows the Dutch Banking Tools specifications which are
126+empirically recreated in this module.
127+
128+Dutch Banking Tools uses the concept of 'Afschrift' or Bank Statement.
129+Every transaction is bound to a Bank Statement. As such, this module generates
130+Bank Statements along with Bank Transactions.
131+'''
132+from account_banking.parsers import models
133+from account_banking.parsers.convert import str2date
134+from account_banking.sepa import postalcode
135+from tools.translate import _
136+from osv import osv
137+
138+import re
139+import csv
140+
141+__all__ = ['parser']
142+
143+bt = models.mem_bank_transaction
144+
145+class transaction_message(object):
146+ '''
147+ A auxiliary class to validate and coerce read values
148+ '''
149+ attrnames = [
150+ 'local_account', 'local_currency', 'date', 'u1', 'u2', 'date2',
151+ 'transferred_amount', 'blob',
152+ ]
153+
154+ def __init__(self, values, subno):
155+ '''
156+ Initialize own dict with attributes and coerce values to right type
157+ '''
158+ if len(self.attrnames) != len(values):
159+ raise ValueError, \
160+ _('Invalid transaction line: expected %d columns, found '
161+ '%d') % (len(self.attrnames), len(values))
162+ ''' Strip all values except the blob '''
163+ for (key, val) in zip(self.attrnames, values):
164+ self.__dict__[key] = key == 'blob' and val or val.strip()
165+ # for lack of a standardized locale function to parse amounts
166+ self.local_account = self.local_account.zfill(10)
167+ self.transferred_amount = float(
168+ self.transferred_amount.replace(',', '.'))
169+ self.execution_date = str2date(self.date, '%Y%m%d')
170+ self.effective_date = str2date(self.date, '%Y%m%d')
171+ # Set statement_id based on week number
172+ self.statement_id = self.effective_date.strftime('%Yw%W')
173+ self.id = str(subno).zfill(4)
174+
175+class transaction(models.mem_bank_transaction):
176+ '''
177+ Implementation of transaction communication class for account_banking.
178+ '''
179+ attrnames = ['local_account', 'local_currency', 'transferred_amount',
180+ 'blob', 'execution_date', 'effective_date', 'id',
181+ ]
182+
183+ type_map = {
184+ # retrieved from online help in the Triodos banking application
185+ 'BEA': bt.PAYMENT_TERMINAL, # Pin
186+ 'GEA': bt.BANK_TERMINAL, # ATM
187+ 'COSTS': bt.BANK_COSTS,
188+ 'BANK': bt.ORDER,
189+ 'GIRO': bt.ORDER,
190+ 'INTL': bt.ORDER, # international order
191+ 'UNKN': bt.ORDER, # everything else
192+ }
193+
194+ def __init__(self, line, *args, **kwargs):
195+ '''
196+ Initialize own dict with read values.
197+ '''
198+ super(transaction, self).__init__(*args, **kwargs)
199+ # Copy attributes from auxiliary class to self.
200+ for attr in self.attrnames:
201+ setattr(self, attr, getattr(line, attr))
202+ # Initialize other attributes
203+ self.transfer_type = 'UNKN'
204+ self.remote_account = ''
205+ self.remote_owner = ''
206+ self.reference = ''
207+ self.message = ''
208+ # Decompose structured messages
209+ self.parse_message()
210+
211+ def is_valid(self):
212+ if not self.error_message:
213+ if not self.transferred_amount:
214+ self.error_message = "No transferred amount"
215+ elif not self.execution_date:
216+ self.error_message = "No execution date"
217+ elif not self.remote_account and self.transfer_type not in [
218+ 'BEA', 'GEA', 'COSTS', 'UNKN',
219+ ]:
220+ self.error_message = _('No remote account for transaction type '
221+ '%s') % self.transfer_type
222+ if self.error_message:
223+ raise osv.except_osv(_('Error !'), _(self.error_message))
224+ return not self.error_message
225+
226+ def parse_message(self):
227+ '''
228+ Parse structured message parts into appropriate attributes
229+ '''
230+ def split_blob(line):
231+ # here we split up the blob, which the last field in a tab
232+ # separated statement line the blob is a *space separated* fixed
233+ # field format with field length 32. Empty fields are ignored
234+ col = 0
235+ size = 33
236+ res = []
237+ while(len(line) > col * size):
238+ if line[col * size : (col + 1) * size - 1].strip():
239+ res.append(line[col * size : (col + 1) * size - 1])
240+ col += 1
241+ return res
242+
243+ def parse_type(field):
244+ # here we process the first field, which identifies the statement type
245+ # and in case of certain types contains additional information
246+ transfer_type = 'UNKN'
247+ remote_account = False
248+ remote_owner = False
249+ if field.startswith('GIRO '):
250+ transfer_type = 'GIRO'
251+ # columns 6 to 14 contain the left or right aligned account number
252+ remote_account = field[:15].strip().zfill(10)
253+ # column 15 contains a space
254+ # columns 16 to 31 contain remote owner
255+ remote_owner = field[16:32].strip() or False
256+ elif field.startswith('BEA '):
257+ transfer_type = 'BEA'
258+ # columns 6 to 16 contain the terminal identifier
259+ # column 17 contains a space
260+ # columns 18 to 31 contain date and time in DD.MM.YY/HH.MM format
261+ elif field.startswith('GEA '):
262+ transfer_type = 'GEA'
263+ # columns 6 to 16 contain the terminal identifier
264+ # column 17 contains a space
265+ # columns 18 to 31 contain date and time in DD.MM.YY/HH.MM format
266+ elif field.startswith('MAANDBIJDRAGE ABNAMRO'):
267+ transfer_type = 'COSTS'
268+ elif re.match("^\s([0-9]+\.){3}[0-9]+\s", field):
269+ transfer_type = 'BANK'
270+ remote_account = field[1:13].strip().replace('.', '').zfill(10)
271+ # column 14 to 31 is either empty or contains the remote owner
272+ remote_owner = field[14:32].strip()
273+ elif re.match("^EL[0-9]{13}I", field):
274+ transfer_type = 'INTL'
275+ return (transfer_type, remote_account, remote_owner)
276+
277+ fields = split_blob(self.blob)
278+ (self.transfer_type, self.remote_account, self.remote_owner) = parse_type(fields[0])
279+
280+ # extract other information depending on type
281+ if self.transfer_type == 'GIRO':
282+ self.message = ' '.join(field.strip() for field in fields[1:])
283+
284+ elif self.transfer_type == 'BEA':
285+ # second column contains remote owner and bank pass identification
286+ self.remote_owner = len(fields) > 1 and fields[1].split(',')[0].strip() or False
287+ # column 2 and up can contain additional messsages
288+ # (such as transaction costs or currency conversion)
289+ self.message = ' '.join(field.strip() for field in fields)
290+
291+ elif self.transfer_type == 'BANK':
292+ # second column contains the remote owner or the first message line
293+ if not self.remote_owner:
294+ self.remote_owner = len(fields) > 1 and fields[1].strip() or False
295+ self.message = ' '.join(field.strip() for field in fields[2:])
296+ else:
297+ self.message = ' '.join(field.strip() for field in fields[1:])
298+
299+ elif self.transfer_type == 'INTL':
300+ # first column seems to consist of some kind of international transaction id
301+ self.reference = fields[0].strip()
302+ # second column seems to contain remote currency and amount
303+ # to be processed in a later release of this module
304+ self.message = len(fields) > 1 and fields[1].strip() or False
305+ # third column contains iban, preceeded by a slash forward
306+ if len(fields) > 2:
307+ if fields[2].startswith('/'):
308+ self.remote_account = fields[2][1:].strip()
309+ else:
310+ self.message += ' ' + fields[2].strip()
311+ # fourth column contains remote owner
312+ self.remote_owner = (len(fields) > 3 and fields[3].strip() or
313+ False)
314+ self.message += ' ' + (
315+ ' '.join(field.strip() for field in fields[4:]))
316+
317+ else:
318+ self.message = ' '.join(field.strip() for field in fields)
319+
320+ if not self.reference:
321+ # the reference is sometimes flagged by the prefix "BETALINGSKENM."
322+ # but can be any numeric line really
323+ refexpr = re.compile("^\s*(BETALINGSKENM\.)?\s*([0-9]+ ?)+\s*$")
324+ for field in fields[1:]:
325+ m = refexpr.match(field)
326+ if m:
327+ self.reference = m.group(2)
328+ break
329+
330+class statement(models.mem_bank_statement):
331+ '''
332+ Implementation of bank_statement communication class of account_banking
333+ '''
334+ def __init__(self, msg, *args, **kwargs):
335+ '''
336+ Set decent start values based on first transaction read
337+ '''
338+ super(statement, self).__init__(*args, **kwargs)
339+ self.id = msg.statement_id
340+ self.local_account = msg.local_account
341+ self.date = str2date(msg.date, '%Y%m%d')
342+ self.start_balance = self.end_balance = 0 # msg.start_balance
343+ self.import_transaction(msg)
344+
345+ def import_transaction(self, msg):
346+ '''
347+ Import a transaction and keep some house holding in the mean time.
348+ '''
349+ trans = transaction(msg)
350+ self.end_balance += trans.transferred_amount
351+ self.transactions.append(trans)
352+
353+class parser(models.parser):
354+ code = 'ABNAM'
355+ country_code = 'NL'
356+ name = _('Abnamro (NL)')
357+ doc = _('''\
358+The Dutch Abnamro format is a tab separated text format. The last of these
359+fields is itself a fixed length array containing transaction type, remote
360+account and owner. The bank does not provide a formal specification of the
361+format. Transactions are not explicitely tied to bank statements, although
362+each file covers a period of two weeks.
363+''')
364+
365+ def parse(self, data):
366+ result = []
367+ stmnt = None
368+ lines = data.split('\n')
369+ # Transaction lines are not numbered, so keep a tracer
370+ subno = 0
371+ for line in csv.reader(lines, delimiter = '\t', quoting=csv.QUOTE_NONE):
372+ # Skip empty (last) lines
373+ if not line:
374+ continue
375+ subno += 1
376+ msg = transaction_message(line, subno)
377+ if stmnt and stmnt.id != msg.statement_id:
378+ result.append(stmnt)
379+ stmnt = None
380+ subno = 0
381+ if not stmnt:
382+ stmnt = statement(msg)
383+ else:
384+ stmnt.import_transaction(msg)
385+ result.append(stmnt)
386+ return result
387+
388+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
389
390=== added directory 'account_banking_nl_abnamro/i18n'
391=== added file 'account_banking_nl_abnamro/i18n/account_banking_nl_abnamro.pot'
392--- account_banking_nl_abnamro/i18n/account_banking_nl_abnamro.pot 1970-01-01 00:00:00 +0000
393+++ account_banking_nl_abnamro/i18n/account_banking_nl_abnamro.pot 2011-04-27 10:21:29 +0000
394@@ -0,0 +1,84 @@
395+# Translation of OpenERP Server.
396+# This file contains the translation of the following modules:
397+# * account_banking_nl_abnamro
398+#
399+msgid ""
400+msgstr ""
401+"Project-Id-Version: OpenERP Server 6.0.1\n"
402+"Report-Msgid-Bugs-To: support@openerp.com\n"
403+"POT-Creation-Date: 2011-04-26 18:01+0000\n"
404+"PO-Revision-Date: 2011-04-26 18:01+0000\n"
405+"Last-Translator: <>\n"
406+"Language-Team: \n"
407+"MIME-Version: 1.0\n"
408+"Content-Type: text/plain; charset=UTF-8\n"
409+"Content-Transfer-Encoding: \n"
410+"Plural-Forms: \n"
411+
412+#. module: account_banking_nl_abnamro
413+#: code:addons/account_banking_nl_abnamro/abnamro.py:125
414+#, python-format
415+msgid "No remote account for transaction type %s"
416+msgstr "No remote account for transaction type %s"
417+
418+#. module: account_banking_nl_abnamro
419+#: code:addons/account_banking_nl_abnamro/abnamro.py:261
420+#, python-format
421+msgid "Abnamro (NL)"
422+msgstr "Abnamro (NL)"
423+
424+#. module: account_banking_nl_abnamro
425+#: code:addons/account_banking_nl_abnamro/abnamro.py:128
426+#, python-format
427+msgid "Error !"
428+msgstr "Error !"
429+
430+#. module: account_banking_nl_abnamro
431+#: code:addons/account_banking_nl_abnamro/abnamro.py:65
432+#, python-format
433+msgid "Invalid transaction line: expected %d columns, found %d"
434+msgstr "Invalid transaction line: expected %d columns, found %d"
435+
436+#. module: account_banking_nl_abnamro
437+#: model:ir.module.module,description:account_banking_nl_abnamro.module_meta_information
438+msgid "\n"
439+"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n"
440+"\n"
441+"No formal specifications of the file layout are released by abnamro. You can\n"
442+"help improve the performance of this import filter on\n"
443+"https://launchpad.net/account-banking.\n"
444+"\n"
445+"Imported bank transfers are organized in statements covering periods of one week,\n"
446+"even if the imported files cover a different period.\n"
447+" "
448+msgstr "\n"
449+"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n"
450+"\n"
451+"No formal specifications of the file layout are released by abnamro. You can\n"
452+"help improve the performance of this import filter on\n"
453+"https://launchpad.net/account-banking.\n"
454+"\n"
455+"Imported bank transfers are organized in statements covering periods of one week,\n"
456+"even if the imported files cover a different period.\n"
457+" "
458+
459+#. module: account_banking_nl_abnamro
460+#: model:ir.module.module,shortdesc:account_banking_nl_abnamro.module_meta_information
461+msgid "abnamro (NL) Bank Statements Import"
462+msgstr "abnamro (NL) Bank Statements Import"
463+
464+#. module: account_banking_nl_abnamro
465+#: code:addons/account_banking_nl_abnamro/abnamro.py:262
466+#, python-format
467+msgid "The Dutch Abnamro format is a tab separated text format. The last of these\n"
468+"fields is itself a fixed length array containing transaction type, remote\n"
469+"account and owner. The bank does not provide a formal specification of the\n"
470+"format. Transactions are not explicitely tied to bank statements, although\n"
471+"each file covers a period of two weeks.\n"
472+""
473+msgstr "The Dutch Abnamro format is a tab separated text format. The last of these\n"
474+"fields is itself a fixed length array containing transaction type, remote\n"
475+"account and owner. The bank does not provide a formal specification of the\n"
476+"format. Transactions are not explicitely tied to bank statements, although\n"
477+"each file covers a period of two weeks.\n"
478+""
479
480=== added file 'account_banking_nl_abnamro/i18n/en.po'
481--- account_banking_nl_abnamro/i18n/en.po 1970-01-01 00:00:00 +0000
482+++ account_banking_nl_abnamro/i18n/en.po 2011-04-27 10:21:29 +0000
483@@ -0,0 +1,84 @@
484+# Translation of OpenERP Server.
485+# This file contains the translation of the following modules:
486+# * account_banking_nl_abnamro
487+#
488+msgid ""
489+msgstr ""
490+"Project-Id-Version: OpenERP Server 6.0.1\n"
491+"Report-Msgid-Bugs-To: support@openerp.com\n"
492+"POT-Creation-Date: 2011-04-26 18:01+0000\n"
493+"PO-Revision-Date: 2011-04-26 18:01+0000\n"
494+"Last-Translator: <>\n"
495+"Language-Team: \n"
496+"MIME-Version: 1.0\n"
497+"Content-Type: text/plain; charset=UTF-8\n"
498+"Content-Transfer-Encoding: \n"
499+"Plural-Forms: \n"
500+
501+#. module: account_banking_nl_abnamro
502+#: code:addons/account_banking_nl_abnamro/abnamro.py:125
503+#, python-format
504+msgid "No remote account for transaction type %s"
505+msgstr "No remote account for transaction type %s"
506+
507+#. module: account_banking_nl_abnamro
508+#: code:addons/account_banking_nl_abnamro/abnamro.py:261
509+#, python-format
510+msgid "Abnamro (NL)"
511+msgstr "Abnamro (NL)"
512+
513+#. module: account_banking_nl_abnamro
514+#: code:addons/account_banking_nl_abnamro/abnamro.py:128
515+#, python-format
516+msgid "Error !"
517+msgstr "Error !"
518+
519+#. module: account_banking_nl_abnamro
520+#: code:addons/account_banking_nl_abnamro/abnamro.py:65
521+#, python-format
522+msgid "Invalid transaction line: expected %d columns, found %d"
523+msgstr "Invalid transaction line: expected %d columns, found %d"
524+
525+#. module: account_banking_nl_abnamro
526+#: model:ir.module.module,description:account_banking_nl_abnamro.module_meta_information
527+msgid "\n"
528+"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n"
529+"\n"
530+"No formal specifications of the file layout are released by abnamro. You can\n"
531+"help improve the performance of this import filter on\n"
532+"https://launchpad.net/account-banking.\n"
533+"\n"
534+"Imported bank transfers are organized in statements covering periods of one week,\n"
535+"even if the imported files cover a different period.\n"
536+" "
537+msgstr "\n"
538+"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n"
539+"\n"
540+"No formal specifications of the file layout are released by abnamro. You can\n"
541+"help improve the performance of this import filter on\n"
542+"https://launchpad.net/account-banking.\n"
543+"\n"
544+"Imported bank transfers are organized in statements covering periods of one week,\n"
545+"even if the imported files cover a different period.\n"
546+" "
547+
548+#. module: account_banking_nl_abnamro
549+#: model:ir.module.module,shortdesc:account_banking_nl_abnamro.module_meta_information
550+msgid "abnamro (NL) Bank Statements Import"
551+msgstr "abnamro (NL) Bank Statements Import"
552+
553+#. module: account_banking_nl_abnamro
554+#: code:addons/account_banking_nl_abnamro/abnamro.py:262
555+#, python-format
556+msgid "The Dutch Abnamro format is a tab separated text format. The last of these\n"
557+"fields is itself a fixed length array containing transaction type, remote\n"
558+"account and owner. The bank does not provide a formal specification of the\n"
559+"format. Transactions are not explicitely tied to bank statements, although\n"
560+"each file covers a period of two weeks.\n"
561+""
562+msgstr "The Dutch Abnamro format is a tab separated text format. The last of these\n"
563+"fields is itself a fixed length array containing transaction type, remote\n"
564+"account and owner. The bank does not provide a formal specification of the\n"
565+"format. Transactions are not explicitely tied to bank statements, although\n"
566+"each file covers a period of two weeks.\n"
567+""
568
569=== added file 'account_banking_nl_abnamro/i18n/nl.po'
570--- account_banking_nl_abnamro/i18n/nl.po 1970-01-01 00:00:00 +0000
571+++ account_banking_nl_abnamro/i18n/nl.po 2011-04-27 10:21:29 +0000
572@@ -0,0 +1,84 @@
573+# Translation of OpenERP Server.
574+# This file contains the translation of the following modules:
575+# * account_banking_nl_abnamro
576+#
577+msgid ""
578+msgstr ""
579+"Project-Id-Version: OpenERP Server 6.0.1\n"
580+"Report-Msgid-Bugs-To: support@openerp.com\n"
581+"POT-Creation-Date: 2011-04-26 18:01+0000\n"
582+"PO-Revision-Date: 2011-04-26 18:01+0000\n"
583+"Last-Translator: <>\n"
584+"Language-Team: \n"
585+"MIME-Version: 1.0\n"
586+"Content-Type: text/plain; charset=UTF-8\n"
587+"Content-Transfer-Encoding: \n"
588+"Plural-Forms: \n"
589+
590+#. module: account_banking_nl_abnamro
591+#: code:addons/account_banking_nl_abnamro/abnamro.py:125
592+#, python-format
593+msgid "No remote account for transaction type %s"
594+msgstr "Geen tegenrekening bij transactietype %s"
595+
596+#. module: account_banking_nl_abnamro
597+#: code:addons/account_banking_nl_abnamro/abnamro.py:261
598+#, python-format
599+msgid "Abnamro (NL)"
600+msgstr "Abnamro (NL)"
601+
602+#. module: account_banking_nl_abnamro
603+#: code:addons/account_banking_nl_abnamro/abnamro.py:128
604+#, python-format
605+msgid "Error !"
606+msgstr "Fout !"
607+
608+#. module: account_banking_nl_abnamro
609+#: code:addons/account_banking_nl_abnamro/abnamro.py:65
610+#, python-format
611+msgid "Invalid transaction line: expected %d columns, found %d"
612+msgstr "Ongeldige transactieregel: %d kolommen verwacht, %d aangetroffen"
613+
614+#. module: account_banking_nl_abnamro
615+#: model:ir.module.module,description:account_banking_nl_abnamro.module_meta_information
616+msgid "\n"
617+"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n"
618+"\n"
619+"No formal specifications of the file layout are released by abnamro. You can\n"
620+"help improve the performance of this import filter on\n"
621+"https://launchpad.net/account-banking.\n"
622+"\n"
623+"Imported bank transfers are organized in statements covering periods of one week,\n"
624+"even if the imported files cover a different period.\n"
625+" "
626+msgstr "\n"
627+"Importfilter voor bankafschriften van abnamro (NL) in txt/tab formaat.\n"
628+"\n"
629+"De bank verstrekt geen formele specificaties van de bestandsindeling. Je kunt\n"
630+"meehelpen om de werking van dit importfilter te verbeteren op\n"
631+"https://launchpad.net/account-banking.\n"
632+"\n"
633+"Geïmpoteerde transacties worden samengevoegd tot bankafschriften in periodes\n"
634+"van een week, ook als de geïmporteerde bestanden een andere periode beslaan.\n"
635+" "
636+
637+#. module: account_banking_nl_abnamro
638+#: model:ir.module.module,shortdesc:account_banking_nl_abnamro.module_meta_information
639+msgid "abnamro (NL) Bank Statements Import"
640+msgstr "Inlezen bankafschriften abnamro (NL)"
641+
642+#. module: account_banking_nl_abnamro
643+#: code:addons/account_banking_nl_abnamro/abnamro.py:262
644+#, python-format
645+msgid "The Dutch Abnamro format is a tab separated text format. The last of these\n"
646+"fields is itself a fixed length array containing transaction type, remote\n"
647+"account and owner. The bank does not provide a formal specification of the\n"
648+"format. Transactions are not explicitely tied to bank statements, although\n"
649+"each file covers a period of two weeks.\n"
650+""
651+msgstr "The Dutch Abnamro format is a tab separated text format. The last of these\n"
652+"fields is itself a fixed length array containing transaction type, remote\n"
653+"account and owner. The bank does not provide a formal specification of the\n"
654+"format. Transactions are not explicitely tied to bank statements, although\n"
655+"each file covers a period of two weeks.\n"
656+""
657
658=== added directory 'account_banking_nl_triodos'
659=== added file 'account_banking_nl_triodos/__init__.py'
660--- account_banking_nl_triodos/__init__.py 1970-01-01 00:00:00 +0000
661+++ account_banking_nl_triodos/__init__.py 2011-04-27 10:21:29 +0000
662@@ -0,0 +1,31 @@
663+# -*- encoding: utf-8 -*-
664+##############################################################################
665+#
666+# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
667+# and Therp BV (<http://therp.nl>)
668+# All Rights Reserved
669+#
670+# WARNING: This program as such is intended to be used by professional
671+# programmers who take the whole responsability of assessing all potential
672+# consequences resulting from its eventual inadequacies and bugs
673+# End users who are looking for a ready-to-use solution with commercial
674+# garantees and support are strongly adviced to contract EduSense BV
675+# or Therp BV
676+#
677+# This program is free software: you can redistribute it and/or modify
678+# it under the terms of the GNU General Public License as published by
679+# the Free Software Foundation, either version 3 of the License, or
680+# (at your option) any later version.
681+#
682+# This program is distributed in the hope that it will be useful,
683+# but WITHOUT ANY WARRANTY; without even the implied warranty of
684+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
685+# GNU General Public License for more details.
686+#
687+# You should have received a copy of the GNU General Public License
688+# along with this program. If not, see <http://www.gnu.org/licenses/>.
689+#
690+##############################################################################
691+import triodos
692+
693+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
694
695=== added file 'account_banking_nl_triodos/__openerp__.py'
696--- account_banking_nl_triodos/__openerp__.py 1970-01-01 00:00:00 +0000
697+++ account_banking_nl_triodos/__openerp__.py 2011-04-27 10:21:29 +0000
698@@ -0,0 +1,58 @@
699+##############################################################################
700+#
701+# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
702+# and Therp BV (<http://therp.nl>)
703+# All Rights Reserved
704+#
705+# WARNING: This program as such is intended to be used by professional
706+# programmers who take the whole responsability of assessing all potential
707+# consequences resulting from its eventual inadequacies and bugs
708+# End users who are looking for a ready-to-use solution with commercial
709+# garantees and support are strongly adviced to contract EduSense BV
710+# or Therp BV
711+#
712+# This program is free software: you can redistribute it and/or modify
713+# it under the terms of the GNU General Public License as published by
714+# the Free Software Foundation, either version 3 of the License, or
715+# (at your option) any later version.
716+#
717+# This program is distributed in the hope that it will be useful,
718+# but WITHOUT ANY WARRANTY; without even the implied warranty of
719+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
720+# GNU General Public License for more details.
721+#
722+# You should have received a copy of the GNU General Public License
723+# along with this program. If not, see <http://www.gnu.org/licenses/>.
724+#
725+##############################################################################
726+{
727+ 'name': 'Triodos (NL) Bank Statements Import',
728+ 'version': '0.1',
729+ 'license': 'GPL-3',
730+ 'author': 'Therp BV / EduSense BV',
731+ 'website': 'https://launchpad.net/account-banking',
732+ 'category': 'Account Banking',
733+ 'depends': ['account_banking'],
734+ 'init_xml': [],
735+ 'update_xml': [
736+ #'security/ir.model.access.csv',
737+ ],
738+ 'demo_xml': [],
739+ 'description': '''
740+Module to import Dutch Triodos bank format transation files (CSV format).
741+
742+As the Triodos bank does not provide detailed specification concerning possible
743+values and their meaning for the fields in the CSV file format, the statements
744+are parsed according to an educated guess based on incomplete information.
745+You can contact the account-banking developers through their launchpad page and
746+help improve the performance of this import filter on
747+https://launchpad.net/account-banking.
748+
749+Note that imported bank transfers are organized in statements covering periods
750+of one week, even if the imported files cover a different period.
751+
752+This modules contains no logic, just an import filter for account_banking.
753+ ''',
754+ 'active': False,
755+ 'installable': True,
756+}
757
758=== added symlink 'account_banking_nl_triodos/__terp__.py'
759=== target is u'__openerp__.py'
760=== added directory 'account_banking_nl_triodos/i18n'
761=== added file 'account_banking_nl_triodos/i18n/account_banking_nl_triodos.pot'
762--- account_banking_nl_triodos/i18n/account_banking_nl_triodos.pot 1970-01-01 00:00:00 +0000
763+++ account_banking_nl_triodos/i18n/account_banking_nl_triodos.pot 2011-04-27 10:21:29 +0000
764@@ -0,0 +1,78 @@
765+# Translation of OpenERP Server.
766+# This file contains the translation of the following modules:
767+# * account_banking_nl_triodos
768+#
769+msgid ""
770+msgstr ""
771+"Project-Id-Version: OpenERP Server 6.0.1\n"
772+"Report-Msgid-Bugs-To: support@openerp.com\n"
773+"POT-Creation-Date: 2011-04-26 18:15+0000\n"
774+"PO-Revision-Date: 2011-04-26 18:15+0000\n"
775+"Last-Translator: <>\n"
776+"Language-Team: \n"
777+"MIME-Version: 1.0\n"
778+"Content-Type: text/plain; charset=UTF-8\n"
779+"Content-Transfer-Encoding: \n"
780+"Plural-Forms: \n"
781+
782+#. module: account_banking_nl_triodos
783+#: model:ir.module.module,description:account_banking_nl_triodos.module_meta_information
784+msgid "\n"
785+"Module to import Dutch Triodos bank format transation files (CSV format).\n"
786+"\n"
787+"As the Triodos bank does not provide detailed specification concerning possible\n"
788+"values and their meaning for the fields in the CSV file format, the statements\n"
789+"are parsed according to an educated guess based on incomplete information.\n"
790+"You can contact the account-banking developers through their launchpad page and\n"
791+"help improve the performance of this import filter on\n"
792+"https://launchpad.net/account-banking.\n"
793+"\n"
794+"Note that imported bank transfers are organized in statements covering periods\n"
795+"of one week, even if the imported files cover a different period.\n"
796+"\n"
797+"This modules contains no logic, just an import filter for account_banking.\n"
798+" "
799+msgstr "\n"
800+"Module to import Dutch Triodos bank format transation files (CSV format).\n"
801+"\n"
802+"As the Triodos bank does not provide detailed specification concerning possible\n"
803+"values and their meaning for the fields in the CSV file format, the statements\n"
804+"are parsed according to an educated guess based on incomplete information.\n"
805+"You can contact the account-banking developers through their launchpad page and\n"
806+"help improve the performance of this import filter on\n"
807+"https://launchpad.net/account-banking.\n"
808+"\n"
809+"Note that imported bank transfers are organized in statements covering periods\n"
810+"of one week, even if the imported files cover a different period.\n"
811+"\n"
812+"This modules contains no logic, just an import filter for account_banking.\n"
813+" "
814+
815+#. module: account_banking_nl_triodos
816+#: model:ir.module.module,shortdesc:account_banking_nl_triodos.module_meta_information
817+msgid "Triodos (NL) Bank Statements Import"
818+msgstr "Triodos (NL) Bank Statements Import"
819+
820+#. module: account_banking_nl_triodos
821+#: code:addons/account_banking_nl_triodos/triodos.py:185
822+#, python-format
823+msgid "Triodos Bank"
824+msgstr "Triodos Bank"
825+
826+#. module: account_banking_nl_triodos
827+#: code:addons/account_banking_nl_triodos/triodos.py:186
828+#, python-format
829+msgid "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n"
830+"distinct from the Dutch multibank format. Transactions are not tied to Bank\n"
831+"Statements.\n"
832+""
833+msgstr "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n"
834+"distinct from the Dutch multibank format. Transactions are not tied to Bank\n"
835+"Statements.\n"
836+""
837+
838+#. module: account_banking_nl_triodos
839+#: code:addons/account_banking_nl_triodos/triodos.py:63
840+#, python-format
841+msgid "Invalid transaction line: expected %d columns, found %d"
842+msgstr "Invalid transaction line: expected %d columns, found %d"
843
844=== added file 'account_banking_nl_triodos/i18n/en.po'
845--- account_banking_nl_triodos/i18n/en.po 1970-01-01 00:00:00 +0000
846+++ account_banking_nl_triodos/i18n/en.po 2011-04-27 10:21:29 +0000
847@@ -0,0 +1,78 @@
848+# Translation of OpenERP Server.
849+# This file contains the translation of the following modules:
850+# * account_banking_nl_triodos
851+#
852+msgid ""
853+msgstr ""
854+"Project-Id-Version: OpenERP Server 6.0.1\n"
855+"Report-Msgid-Bugs-To: support@openerp.com\n"
856+"POT-Creation-Date: 2011-04-26 18:15+0000\n"
857+"PO-Revision-Date: 2011-04-26 18:15+0000\n"
858+"Last-Translator: <>\n"
859+"Language-Team: \n"
860+"MIME-Version: 1.0\n"
861+"Content-Type: text/plain; charset=UTF-8\n"
862+"Content-Transfer-Encoding: \n"
863+"Plural-Forms: \n"
864+
865+#. module: account_banking_nl_triodos
866+#: model:ir.module.module,description:account_banking_nl_triodos.module_meta_information
867+msgid "\n"
868+"Module to import Dutch Triodos bank format transation files (CSV format).\n"
869+"\n"
870+"As the Triodos bank does not provide detailed specification concerning possible\n"
871+"values and their meaning for the fields in the CSV file format, the statements\n"
872+"are parsed according to an educated guess based on incomplete information.\n"
873+"You can contact the account-banking developers through their launchpad page and\n"
874+"help improve the performance of this import filter on\n"
875+"https://launchpad.net/account-banking.\n"
876+"\n"
877+"Note that imported bank transfers are organized in statements covering periods\n"
878+"of one week, even if the imported files cover a different period.\n"
879+"\n"
880+"This modules contains no logic, just an import filter for account_banking.\n"
881+" "
882+msgstr "\n"
883+"Module to import Dutch Triodos bank format transation files (CSV format).\n"
884+"\n"
885+"As the Triodos bank does not provide detailed specification concerning possible\n"
886+"values and their meaning for the fields in the CSV file format, the statements\n"
887+"are parsed according to an educated guess based on incomplete information.\n"
888+"You can contact the account-banking developers through their launchpad page and\n"
889+"help improve the performance of this import filter on\n"
890+"https://launchpad.net/account-banking.\n"
891+"\n"
892+"Note that imported bank transfers are organized in statements covering periods\n"
893+"of one week, even if the imported files cover a different period.\n"
894+"\n"
895+"This modules contains no logic, just an import filter for account_banking.\n"
896+" "
897+
898+#. module: account_banking_nl_triodos
899+#: model:ir.module.module,shortdesc:account_banking_nl_triodos.module_meta_information
900+msgid "Triodos (NL) Bank Statements Import"
901+msgstr "Triodos (NL) Bank Statements Import"
902+
903+#. module: account_banking_nl_triodos
904+#: code:addons/account_banking_nl_triodos/triodos.py:185
905+#, python-format
906+msgid "Triodos Bank"
907+msgstr "Triodos Bank"
908+
909+#. module: account_banking_nl_triodos
910+#: code:addons/account_banking_nl_triodos/triodos.py:186
911+#, python-format
912+msgid "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n"
913+"distinct from the Dutch multibank format. Transactions are not tied to Bank\n"
914+"Statements.\n"
915+""
916+msgstr "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n"
917+"distinct from the Dutch multibank format. Transactions are not tied to Bank\n"
918+"Statements.\n"
919+""
920+
921+#. module: account_banking_nl_triodos
922+#: code:addons/account_banking_nl_triodos/triodos.py:63
923+#, python-format
924+msgid "Invalid transaction line: expected %d columns, found %d"
925+msgstr "Invalid transaction line: expected %d columns, found %d"
926
927=== added file 'account_banking_nl_triodos/i18n/nl.po'
928--- account_banking_nl_triodos/i18n/nl.po 1970-01-01 00:00:00 +0000
929+++ account_banking_nl_triodos/i18n/nl.po 2011-04-27 10:21:29 +0000
930@@ -0,0 +1,77 @@
931+# Translation of OpenERP Server.
932+# This file contains the translation of the following modules:
933+# * account_banking_nl_triodos
934+#
935+msgid ""
936+msgstr ""
937+"Project-Id-Version: OpenERP Server 6.0.1\n"
938+"Report-Msgid-Bugs-To: support@openerp.com\n"
939+"POT-Creation-Date: 2011-04-26 18:15+0000\n"
940+"PO-Revision-Date: 2011-04-26 18:15+0000\n"
941+"Last-Translator: <>\n"
942+"Language-Team: \n"
943+"MIME-Version: 1.0\n"
944+"Content-Type: text/plain; charset=UTF-8\n"
945+"Content-Transfer-Encoding: \n"
946+"Plural-Forms: \n"
947+
948+#. module: account_banking_nl_triodos
949+#: model:ir.module.module,description:account_banking_nl_triodos.module_meta_information
950+msgid "\n"
951+"Module to import Dutch Triodos bank format transation files (CSV format).\n"
952+"\n"
953+"As the Triodos bank does not provide detailed specification concerning possible\n"
954+"values and their meaning for the fields in the CSV file format, the statements\n"
955+"are parsed according to an educated guess based on incomplete information.\n"
956+"You can contact the account-banking developers through their launchpad page and\n"
957+"help improve the performance of this import filter on\n"
958+"https://launchpad.net/account-banking.\n"
959+"\n"
960+"Note that imported bank transfers are organized in statements covering periods\n"
961+"of one week, even if the imported files cover a different period.\n"
962+"\n"
963+"This modules contains no logic, just an import filter for account_banking.\n"
964+" "
965+msgstr "\n"
966+"Module voor het inlezen van bankafschiften van de Nederlandse Triodosbank (CSV format).\n"
967+"\n"
968+"Aangezien de Triodosbank geen details vrijgeeft over de mogelijke waarden van\n"
969+"de verschillende velden en hun betekenis worden de transacties zo goed mogelijk\n"
970+"ontleed op basis van onvolledige informatie. Je kunt de werking van dit filter\n"
971+"helpen verbeteren op https://launchpad.net/account-banking.\n"
972+"\n"
973+"Geïmpoteerde transacties worden samengevoegd tot bankafschriften in periodes\n"
974+"van een week, ook als de geïmporteerde bestanden een andere periode beslaan.\n"
975+"\n"
976+"Deze module zelf bevat geen bedrijfslogica, alleen een importdefinitie voor \n"
977+"account_banking.\n"
978+" "
979+
980+#. module: account_banking_nl_triodos
981+#: model:ir.module.module,shortdesc:account_banking_nl_triodos.module_meta_information
982+msgid "Triodos (NL) Bank Statements Import"
983+msgstr "Inlezen bankafschriften Triodosbank (NL)"
984+
985+#. module: account_banking_nl_triodos
986+#: code:addons/account_banking_nl_triodos/triodos.py:185
987+#, python-format
988+msgid "Triodos Bank"
989+msgstr "Triodosbank"
990+
991+#. module: account_banking_nl_triodos
992+#: code:addons/account_banking_nl_triodos/triodos.py:186
993+#, python-format
994+msgid "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n"
995+"distinct from the Dutch multibank format. Transactions are not tied to Bank\n"
996+"Statements.\n"
997+""
998+msgstr "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n"
999+"distinct from the Dutch multibank format. Transactions are not tied to Bank\n"
1000+"Statements.\n"
1001+""
1002+
1003+#. module: account_banking_nl_triodos
1004+#: code:addons/account_banking_nl_triodos/triodos.py:63
1005+#, python-format
1006+msgid "Invalid transaction line: expected %d columns, found %d"
1007+msgstr "Ongeldige transactieregel: %d kolommen verwacht, %d aangetroffen"
1008
1009=== added file 'account_banking_nl_triodos/triodos.py'
1010--- account_banking_nl_triodos/triodos.py 1970-01-01 00:00:00 +0000
1011+++ account_banking_nl_triodos/triodos.py 2011-04-27 10:21:29 +0000
1012@@ -0,0 +1,213 @@
1013+# -*- encoding: utf-8 -*-
1014+##############################################################################
1015+#
1016+# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>),
1017+# 2011 Therp BV (<http://therp.nl>).
1018+# All Rights Reserved
1019+#
1020+# This program is free software: you can redistribute it and/or modify
1021+# it under the terms of the GNU General Public License as published by
1022+# the Free Software Foundation, either version 3 of the License, or
1023+# (at your option) any later version.
1024+#
1025+# This program is distributed in the hope that it will be useful,
1026+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1027+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1028+# GNU General Public License for more details.
1029+#
1030+# You should have received a copy of the GNU General Public License
1031+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1032+#
1033+##############################################################################
1034+
1035+'''
1036+This parser follows the Dutch Banking Tools specifications which are
1037+empirically recreated in this module.
1038+
1039+Dutch Banking Tools uses the concept of 'Afschrift' or Bank Statement.
1040+Every transaction is bound to a Bank Statement. As such, this module generates
1041+Bank Statements along with Bank Transactions.
1042+'''
1043+from account_banking.parsers import models
1044+from account_banking.parsers.convert import str2date
1045+from account_banking.sepa import postalcode
1046+from tools.translate import _
1047+
1048+import re
1049+import csv
1050+
1051+__all__ = ['parser']
1052+
1053+bt = models.mem_bank_transaction
1054+
1055+class transaction_message(object):
1056+ '''
1057+ A auxiliary class to validate and coerce read values
1058+ '''
1059+ attrnames = [
1060+ 'date', 'local_account', 'transferred_amount', 'debcred',
1061+ 'remote_owner', 'remote_account', 'transfer_type', 'reference',
1062+ ]
1063+
1064+ def __init__(self, values, subno):
1065+ '''
1066+ Initialize own dict with attributes and coerce values to right type
1067+ '''
1068+ if len(self.attrnames) != len(values):
1069+ raise ValueError(
1070+ _('Invalid transaction line: expected %d columns, found %d')
1071+ % (len(self.attrnames), len(values)))
1072+ self.__dict__.update(dict(zip(self.attrnames, values)))
1073+ # for lack of a standardized locale function to parse amounts
1074+ self.transferred_amount = float(
1075+ re.sub(',', '.', re.sub('\.', '', self.transferred_amount)))
1076+ if self.debcred == 'Debet':
1077+ self.transferred_amount = -self.transferred_amount
1078+ self.execution_date = str2date(self.date, '%d-%m-%Y')
1079+ self.effective_date = str2date(self.date, '%d-%m-%Y')
1080+ # Set statement_id based on week number
1081+ self.statement_id = self.effective_date.strftime('%Yw%W')
1082+ self.id = str(subno).zfill(4)
1083+
1084+class transaction(models.mem_bank_transaction):
1085+ '''
1086+ Implementation of transaction communication class for account_banking.
1087+ '''
1088+ attrnames = ['local_account', 'remote_account',
1089+ 'remote_owner', 'transferred_amount',
1090+ 'execution_date', 'effective_date', 'transfer_type',
1091+ 'reference', 'id',
1092+ ]
1093+
1094+ type_map = {
1095+ # retrieved from online help in the Triodos banking application
1096+ 'AC': bt.ORDER, # Acceptgiro gecodeerd
1097+ 'AN': bt.ORDER, # Acceptgiro ongecodeerd
1098+ 'AT': bt.ORDER, # Acceptgiro via internet
1099+ 'BA': bt.PAYMENT_TERMINAL, # Betaalautomaat
1100+ 'CHIP': bt.BANK_TERMINAL, # Chipknip
1101+ # 'CO': # Correctie
1102+ 'DB': bt.ORDER, # Diskettebetaling
1103+ # 'DV': # Dividend
1104+ 'EI': bt.DIRECT_DEBIT, # Europese Incasso
1105+ 'EICO': bt.DIRECT_DEBIT, # Europese Incasso Correctie
1106+ 'EIST': bt.ORDER, # Europese Incasso Storno
1107+ 'ET': bt.ORDER, # Europese Transactie
1108+ 'ETST': bt.ORDER, #Europese Transactie Storno
1109+ 'GA': bt.BANK_TERMINAL, # Geldautomaat
1110+ 'IB': bt.ORDER, # Interne Boeking
1111+ 'IC': bt.DIRECT_DEBIT, # Incasso
1112+ 'ID': bt.ORDER, # iDeal-betaling
1113+ 'IT': bt.ORDER, # Internet transactie
1114+ 'KN': bt.BANK_COSTS, # Kosten
1115+ 'KO': bt.BANK_TERMINAL, # Kasopname
1116+ # 'KS': # Kwaliteitsstoring
1117+ 'OV': bt.ORDER, # Overboeking. NB: can also be bt.BANK_COSTS
1118+ # when no remote_account specified!
1119+ 'PO': bt.ORDER, # Periodieke Overboeking
1120+ 'PR': bt.BANK_COSTS, # Provisie
1121+ # 'RE': # Rente
1122+ # 'RS': # Renteschenking
1123+ 'ST': bt.ORDER, # Storno
1124+ 'TG': bt.ORDER, # Telegiro
1125+ # 'VL': # Vaste Lening
1126+ 'VO': bt.DIRECT_DEBIT, # Vordering overheid
1127+ 'VV': bt.ORDER, # Vreemde valuta
1128+ }
1129+
1130+ def __init__(self, line, *args, **kwargs):
1131+ '''
1132+ Initialize own dict with read values.
1133+ '''
1134+ super(transaction, self).__init__(*args, **kwargs)
1135+ # Copy attributes from auxiliary class to self.
1136+ for attr in self.attrnames:
1137+ setattr(self, attr, getattr(line, attr))
1138+ self.message = ''
1139+ # Decompose structured messages
1140+ self.parse_message()
1141+ if (self.transfer_type == 'OV' and
1142+ not self.remote_account and
1143+ not self.remote_owner):
1144+ self.transfer_type = 'KN'
1145+
1146+ def is_valid(self):
1147+ if not self.error_message:
1148+ if not self.transferred_amount:
1149+ self.error_message = "No transferred amount"
1150+ elif not self.execution_date:
1151+ self.error_message = "No execution date"
1152+ elif not self.remote_account and self.transfer_type not in [
1153+ 'KN', 'TG', 'GA', 'BA', 'CHIP'
1154+ ]:
1155+ self.error_message = (
1156+ "No remote account for transaction type %s" %
1157+ self.transfer_type)
1158+ return not self.error_message
1159+
1160+ def parse_message(self):
1161+ '''
1162+ Parse structured message parts into appropriate attributes.
1163+ No processing done here for Triodos, maybe later.
1164+ '''
1165+
1166+class statement(models.mem_bank_statement):
1167+ '''
1168+ Implementation of bank_statement communication class of account_banking
1169+ '''
1170+ def __init__(self, msg, *args, **kwargs):
1171+ '''
1172+ Set decent start values based on first transaction read
1173+ '''
1174+ super(statement, self).__init__(*args, **kwargs)
1175+ self.id = msg.statement_id
1176+ self.local_account = msg.local_account
1177+ self.date = str2date(msg.date, '%d-%m-%Y')
1178+ self.start_balance = self.end_balance = 0 # msg.start_balance
1179+ self.import_transaction(msg)
1180+
1181+ def import_transaction(self, msg):
1182+ '''
1183+ Import a transaction and keep some house holding in the mean time.
1184+ '''
1185+ trans = transaction(msg)
1186+ self.end_balance += trans.transferred_amount
1187+ self.transactions.append(trans)
1188+
1189+class parser(models.parser):
1190+ code = 'TRIOD'
1191+ country_code = 'NL'
1192+ name = _('Triodos Bank')
1193+ doc = _('''\
1194+The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically
1195+distinct from the Dutch multibank format. Transactions are not tied to Bank
1196+Statements.
1197+''')
1198+
1199+ def parse(self, data):
1200+ result = []
1201+ stmnt = None
1202+ dialect = csv.excel()
1203+ dialect.quotechar = '"'
1204+ dialect.delimiter = ','
1205+ lines = data.split('\n')
1206+ # Transaction lines are not numbered, so keep a tracer
1207+ subno = 0
1208+ for line in csv.reader(lines, dialect=dialect):
1209+ # Skip empty (last) lines
1210+ if not line:
1211+ continue
1212+ subno += 1
1213+ msg = transaction_message(line, subno)
1214+ if stmnt and stmnt.id != msg.statement_id:
1215+ result.append(stmnt)
1216+ stmnt = None
1217+ subno = 0
1218+ if not stmnt:
1219+ stmnt = statement(msg)
1220+ else:
1221+ stmnt.import_transaction(msg)
1222+ result.append(stmnt)
1223+ return result
1224+
1225+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches