diff --git a/account_banking/__terp__.py b/account_banking/__terp__.py index 2e96a0ff6..8641db9c3 100644 --- a/account_banking/__terp__.py +++ b/account_banking/__terp__.py @@ -25,7 +25,7 @@ ############################################################################## { 'name': 'Account Banking', - 'version': '0.1.59', + 'version': '0.1.60', 'license': 'GPL-3', 'author': 'EduSense BV', 'website': 'http://www.edusense.nl', diff --git a/account_banking_fi_patu/__terp__.py b/account_banking_fi_patu/__terp__.py index 96bbdd0aa..a57dec14d 100644 --- a/account_banking_fi_patu/__terp__.py +++ b/account_banking_fi_patu/__terp__.py @@ -26,7 +26,7 @@ ############################################################################## { 'name': 'Account Banking PATU module', - 'version': '0.59', + 'version': '0.60', 'license': 'GPL-3', 'author': 'Sami Haahtinen', 'website': 'http://ressukka.net', diff --git a/account_banking_nl_abnamro/__init__.py b/account_banking_nl_abnamro/__init__.py new file mode 100644 index 000000000..ad5813105 --- /dev/null +++ b/account_banking_nl_abnamro/__init__.py @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2009 - 2011 EduSense BV () +# and Therp BV () +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# or Therp BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +import abnamro + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_banking_nl_abnamro/__openerp__.py b/account_banking_nl_abnamro/__openerp__.py new file mode 100644 index 000000000..bb028e645 --- /dev/null +++ b/account_banking_nl_abnamro/__openerp__.py @@ -0,0 +1,53 @@ +############################################################################## +# +# Copyright (C) 2009 - 2011 EduSense BV () +# and Therp BV () +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# or Therp BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'abnamro (NL) Bank Statements Import', + 'version': '0.1', + 'license': 'GPL-3', + 'author': 'Therp BV / EduSense BV', + 'website': 'https://launchpad.net/account-banking', + 'category': 'Account Banking', + 'depends': ['account_banking'], + 'init_xml': [], + 'update_xml': [ + #'security/ir.model.access.csv', + ], + 'demo_xml': [], + 'description': ''' +Import filter for abnamro (NL) bank transaction files (txt/tab format). + +No formal specifications of the file layout are released by abnamro. You can +help improve the performance of this import filter on +https://launchpad.net/account-banking. + +Imported bank transfers are organized in statements covering periods of one week, +even if the imported files cover a different period. + ''', + 'active': False, + 'installable': True, +} diff --git a/account_banking_nl_abnamro/__terp__.py b/account_banking_nl_abnamro/__terp__.py new file mode 100644 index 000000000..3b573468a --- /dev/null +++ b/account_banking_nl_abnamro/__terp__.py @@ -0,0 +1,53 @@ +############################################################################## +# +# Copyright (C) 2009 - 2011 EduSense BV () +# and Therp BV () +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# or Therp BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'abnamro (NL) Bank Statements Import', + 'version': '0.60', + 'license': 'GPL-3', + 'author': 'Therp BV / EduSense BV', + 'website': 'https://launchpad.net/account-banking', + 'category': 'Account Banking', + 'depends': ['account_banking'], + 'init_xml': [], + 'update_xml': [ + #'security/ir.model.access.csv', + ], + 'demo_xml': [], + 'description': ''' +Import filter for abnamro (NL) bank transaction files (txt/tab format). + +No formal specifications of the file layout are released by abnamro. You can +help improve the performance of this import filter on +https://launchpad.net/account-banking. + +Imported bank transfers are organized in statements covering periods of one week, +even if the imported files cover a different period. + ''', + 'active': False, + 'installable': True, +} diff --git a/account_banking_nl_abnamro/abnamro.py b/account_banking_nl_abnamro/abnamro.py new file mode 100644 index 000000000..1ff595637 --- /dev/null +++ b/account_banking_nl_abnamro/abnamro.py @@ -0,0 +1,287 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2009 EduSense BV () +# 2011 Therp BV () +# All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +''' +This parser follows the Dutch Banking Tools specifications which are +empirically recreated in this module. + +Dutch Banking Tools uses the concept of 'Afschrift' or Bank Statement. +Every transaction is bound to a Bank Statement. As such, this module generates +Bank Statements along with Bank Transactions. +''' +from account_banking.parsers import models +from account_banking.parsers.convert import str2date +from account_banking.sepa import postalcode +from tools.translate import _ +from osv import osv + +import re +import csv + +__all__ = ['parser'] + +bt = models.mem_bank_transaction + +class transaction_message(object): + ''' + A auxiliary class to validate and coerce read values + ''' + attrnames = [ + 'local_account', 'local_currency', 'date', 'u1', 'u2', 'date2', + 'transferred_amount', 'blob', + ] + + def __init__(self, values, subno): + ''' + Initialize own dict with attributes and coerce values to right type + ''' + if len(self.attrnames) != len(values): + raise ValueError, \ + _('Invalid transaction line: expected %d columns, found ' + '%d') % (len(self.attrnames), len(values)) + ''' Strip all values except the blob ''' + for (key, val) in zip(self.attrnames, values): + self.__dict__[key] = key == 'blob' and val or val.strip() + # for lack of a standardized locale function to parse amounts + self.local_account = self.local_account.zfill(10) + self.transferred_amount = float( + self.transferred_amount.replace(',', '.')) + self.execution_date = str2date(self.date, '%Y%m%d') + self.effective_date = str2date(self.date, '%Y%m%d') + # Set statement_id based on week number + self.statement_id = self.effective_date.strftime('%Yw%W') + self.id = str(subno).zfill(4) + +class transaction(models.mem_bank_transaction): + ''' + Implementation of transaction communication class for account_banking. + ''' + attrnames = ['local_account', 'local_currency', 'transferred_amount', + 'blob', 'execution_date', 'effective_date', 'id', + ] + + type_map = { + # retrieved from online help in the Triodos banking application + 'BEA': bt.PAYMENT_TERMINAL, # Pin + 'GEA': bt.BANK_TERMINAL, # ATM + 'COSTS': bt.BANK_COSTS, + 'BANK': bt.ORDER, + 'GIRO': bt.ORDER, + 'INTL': bt.ORDER, # international order + 'UNKN': bt.ORDER, # everything else + } + + def __init__(self, line, *args, **kwargs): + ''' + Initialize own dict with read values. + ''' + super(transaction, self).__init__(*args, **kwargs) + # Copy attributes from auxiliary class to self. + for attr in self.attrnames: + setattr(self, attr, getattr(line, attr)) + # Initialize other attributes + self.transfer_type = 'UNKN' + self.remote_account = '' + self.remote_owner = '' + self.reference = '' + self.message = '' + # Decompose structured messages + self.parse_message() + + def is_valid(self): + if not self.error_message: + if not self.transferred_amount: + self.error_message = "No transferred amount" + elif not self.execution_date: + self.error_message = "No execution date" + elif not self.remote_account and self.transfer_type not in [ + 'BEA', 'GEA', 'COSTS', 'UNKN', + ]: + self.error_message = _('No remote account for transaction type ' + '%s') % self.transfer_type + if self.error_message: + raise osv.except_osv(_('Error !'), _(self.error_message)) + return not self.error_message + + def parse_message(self): + ''' + Parse structured message parts into appropriate attributes + ''' + def split_blob(line): + # here we split up the blob, which the last field in a tab + # separated statement line the blob is a *space separated* fixed + # field format with field length 32. Empty fields are ignored + col = 0 + size = 33 + res = [] + while(len(line) > col * size): + if line[col * size : (col + 1) * size - 1].strip(): + res.append(line[col * size : (col + 1) * size - 1]) + col += 1 + return res + + def parse_type(field): + # here we process the first field, which identifies the statement type + # and in case of certain types contains additional information + transfer_type = 'UNKN' + remote_account = False + remote_owner = False + if field.startswith('GIRO '): + transfer_type = 'GIRO' + # columns 6 to 14 contain the left or right aligned account number + remote_account = field[:15].strip().zfill(10) + # column 15 contains a space + # columns 16 to 31 contain remote owner + remote_owner = field[16:32].strip() or False + elif field.startswith('BEA '): + transfer_type = 'BEA' + # columns 6 to 16 contain the terminal identifier + # column 17 contains a space + # columns 18 to 31 contain date and time in DD.MM.YY/HH.MM format + elif field.startswith('GEA '): + transfer_type = 'GEA' + # columns 6 to 16 contain the terminal identifier + # column 17 contains a space + # columns 18 to 31 contain date and time in DD.MM.YY/HH.MM format + elif field.startswith('MAANDBIJDRAGE ABNAMRO'): + transfer_type = 'COSTS' + elif re.match("^\s([0-9]+\.){3}[0-9]+\s", field): + transfer_type = 'BANK' + remote_account = field[1:13].strip().replace('.', '').zfill(10) + # column 14 to 31 is either empty or contains the remote owner + remote_owner = field[14:32].strip() + elif re.match("^EL[0-9]{13}I", field): + transfer_type = 'INTL' + return (transfer_type, remote_account, remote_owner) + + fields = split_blob(self.blob) + (self.transfer_type, self.remote_account, self.remote_owner) = parse_type(fields[0]) + + # extract other information depending on type + if self.transfer_type == 'GIRO': + self.message = ' '.join(field.strip() for field in fields[1:]) + + elif self.transfer_type == 'BEA': + # second column contains remote owner and bank pass identification + self.remote_owner = len(fields) > 1 and fields[1].split(',')[0].strip() or False + # column 2 and up can contain additional messsages + # (such as transaction costs or currency conversion) + self.message = ' '.join(field.strip() for field in fields) + + elif self.transfer_type == 'BANK': + # second column contains the remote owner or the first message line + if not self.remote_owner: + self.remote_owner = len(fields) > 1 and fields[1].strip() or False + self.message = ' '.join(field.strip() for field in fields[2:]) + else: + self.message = ' '.join(field.strip() for field in fields[1:]) + + elif self.transfer_type == 'INTL': + # first column seems to consist of some kind of international transaction id + self.reference = fields[0].strip() + # second column seems to contain remote currency and amount + # to be processed in a later release of this module + self.message = len(fields) > 1 and fields[1].strip() or False + # third column contains iban, preceeded by a slash forward + if len(fields) > 2: + if fields[2].startswith('/'): + self.remote_account = fields[2][1:].strip() + else: + self.message += ' ' + fields[2].strip() + # fourth column contains remote owner + self.remote_owner = (len(fields) > 3 and fields[3].strip() or + False) + self.message += ' ' + ( + ' '.join(field.strip() for field in fields[4:])) + + else: + self.message = ' '.join(field.strip() for field in fields) + + if not self.reference: + # the reference is sometimes flagged by the prefix "BETALINGSKENM." + # but can be any numeric line really + refexpr = re.compile("^\s*(BETALINGSKENM\.)?\s*([0-9]+ ?)+\s*$") + for field in fields[1:]: + m = refexpr.match(field) + if m: + self.reference = m.group(2) + break + +class statement(models.mem_bank_statement): + ''' + Implementation of bank_statement communication class of account_banking + ''' + def __init__(self, msg, *args, **kwargs): + ''' + Set decent start values based on first transaction read + ''' + super(statement, self).__init__(*args, **kwargs) + self.id = msg.statement_id + self.local_account = msg.local_account + self.date = str2date(msg.date, '%Y%m%d') + self.start_balance = self.end_balance = 0 # msg.start_balance + self.import_transaction(msg) + + def import_transaction(self, msg): + ''' + Import a transaction and keep some house holding in the mean time. + ''' + trans = transaction(msg) + self.end_balance += trans.transferred_amount + self.transactions.append(trans) + +class parser(models.parser): + code = 'ABNAM' + country_code = 'NL' + name = _('Abnamro (NL)') + doc = _('''\ +The Dutch Abnamro format is a tab separated text format. The last of these +fields is itself a fixed length array containing transaction type, remote +account and owner. The bank does not provide a formal specification of the +format. Transactions are not explicitely tied to bank statements, although +each file covers a period of two weeks. +''') + + def parse(self, data): + result = [] + stmnt = None + lines = data.split('\n') + # Transaction lines are not numbered, so keep a tracer + subno = 0 + for line in csv.reader(lines, delimiter = '\t', quoting=csv.QUOTE_NONE): + # Skip empty (last) lines + if not line: + continue + subno += 1 + msg = transaction_message(line, subno) + if stmnt and stmnt.id != msg.statement_id: + result.append(stmnt) + stmnt = None + subno = 0 + if not stmnt: + stmnt = statement(msg) + else: + stmnt.import_transaction(msg) + result.append(stmnt) + return result + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_banking_nl_abnamro/i18n/account_banking_nl_abnamro.pot b/account_banking_nl_abnamro/i18n/account_banking_nl_abnamro.pot new file mode 100644 index 000000000..ba0bedde5 --- /dev/null +++ b/account_banking_nl_abnamro/i18n/account_banking_nl_abnamro.pot @@ -0,0 +1,84 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_nl_abnamro +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.1\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-04-26 18:01+0000\n" +"PO-Revision-Date: 2011-04-26 18:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:125 +#, python-format +msgid "No remote account for transaction type %s" +msgstr "No remote account for transaction type %s" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:261 +#, python-format +msgid "Abnamro (NL)" +msgstr "Abnamro (NL)" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:128 +#, python-format +msgid "Error !" +msgstr "Error !" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:65 +#, python-format +msgid "Invalid transaction line: expected %d columns, found %d" +msgstr "Invalid transaction line: expected %d columns, found %d" + +#. module: account_banking_nl_abnamro +#: model:ir.module.module,description:account_banking_nl_abnamro.module_meta_information +msgid "\n" +"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n" +"\n" +"No formal specifications of the file layout are released by abnamro. You can\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Imported bank transfers are organized in statements covering periods of one week,\n" +"even if the imported files cover a different period.\n" +" " +msgstr "\n" +"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n" +"\n" +"No formal specifications of the file layout are released by abnamro. You can\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Imported bank transfers are organized in statements covering periods of one week,\n" +"even if the imported files cover a different period.\n" +" " + +#. module: account_banking_nl_abnamro +#: model:ir.module.module,shortdesc:account_banking_nl_abnamro.module_meta_information +msgid "abnamro (NL) Bank Statements Import" +msgstr "abnamro (NL) Bank Statements Import" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:262 +#, python-format +msgid "The Dutch Abnamro format is a tab separated text format. The last of these\n" +"fields is itself a fixed length array containing transaction type, remote\n" +"account and owner. The bank does not provide a formal specification of the\n" +"format. Transactions are not explicitely tied to bank statements, although\n" +"each file covers a period of two weeks.\n" +"" +msgstr "The Dutch Abnamro format is a tab separated text format. The last of these\n" +"fields is itself a fixed length array containing transaction type, remote\n" +"account and owner. The bank does not provide a formal specification of the\n" +"format. Transactions are not explicitely tied to bank statements, although\n" +"each file covers a period of two weeks.\n" +"" diff --git a/account_banking_nl_abnamro/i18n/en.po b/account_banking_nl_abnamro/i18n/en.po new file mode 100644 index 000000000..ba0bedde5 --- /dev/null +++ b/account_banking_nl_abnamro/i18n/en.po @@ -0,0 +1,84 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_nl_abnamro +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.1\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-04-26 18:01+0000\n" +"PO-Revision-Date: 2011-04-26 18:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:125 +#, python-format +msgid "No remote account for transaction type %s" +msgstr "No remote account for transaction type %s" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:261 +#, python-format +msgid "Abnamro (NL)" +msgstr "Abnamro (NL)" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:128 +#, python-format +msgid "Error !" +msgstr "Error !" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:65 +#, python-format +msgid "Invalid transaction line: expected %d columns, found %d" +msgstr "Invalid transaction line: expected %d columns, found %d" + +#. module: account_banking_nl_abnamro +#: model:ir.module.module,description:account_banking_nl_abnamro.module_meta_information +msgid "\n" +"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n" +"\n" +"No formal specifications of the file layout are released by abnamro. You can\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Imported bank transfers are organized in statements covering periods of one week,\n" +"even if the imported files cover a different period.\n" +" " +msgstr "\n" +"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n" +"\n" +"No formal specifications of the file layout are released by abnamro. You can\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Imported bank transfers are organized in statements covering periods of one week,\n" +"even if the imported files cover a different period.\n" +" " + +#. module: account_banking_nl_abnamro +#: model:ir.module.module,shortdesc:account_banking_nl_abnamro.module_meta_information +msgid "abnamro (NL) Bank Statements Import" +msgstr "abnamro (NL) Bank Statements Import" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:262 +#, python-format +msgid "The Dutch Abnamro format is a tab separated text format. The last of these\n" +"fields is itself a fixed length array containing transaction type, remote\n" +"account and owner. The bank does not provide a formal specification of the\n" +"format. Transactions are not explicitely tied to bank statements, although\n" +"each file covers a period of two weeks.\n" +"" +msgstr "The Dutch Abnamro format is a tab separated text format. The last of these\n" +"fields is itself a fixed length array containing transaction type, remote\n" +"account and owner. The bank does not provide a formal specification of the\n" +"format. Transactions are not explicitely tied to bank statements, although\n" +"each file covers a period of two weeks.\n" +"" diff --git a/account_banking_nl_abnamro/i18n/nl.po b/account_banking_nl_abnamro/i18n/nl.po new file mode 100644 index 000000000..7d9283e7a --- /dev/null +++ b/account_banking_nl_abnamro/i18n/nl.po @@ -0,0 +1,84 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_nl_abnamro +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.1\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-04-26 18:01+0000\n" +"PO-Revision-Date: 2011-04-26 18:01+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:125 +#, python-format +msgid "No remote account for transaction type %s" +msgstr "Geen tegenrekening bij transactietype %s" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:261 +#, python-format +msgid "Abnamro (NL)" +msgstr "Abnamro (NL)" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:128 +#, python-format +msgid "Error !" +msgstr "Fout !" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:65 +#, python-format +msgid "Invalid transaction line: expected %d columns, found %d" +msgstr "Ongeldige transactieregel: %d kolommen verwacht, %d aangetroffen" + +#. module: account_banking_nl_abnamro +#: model:ir.module.module,description:account_banking_nl_abnamro.module_meta_information +msgid "\n" +"Import filter for abnamro (NL) bank transaction files (txt/tab format).\n" +"\n" +"No formal specifications of the file layout are released by abnamro. You can\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Imported bank transfers are organized in statements covering periods of one week,\n" +"even if the imported files cover a different period.\n" +" " +msgstr "\n" +"Importfilter voor bankafschriften van abnamro (NL) in txt/tab formaat.\n" +"\n" +"De bank verstrekt geen formele specificaties van de bestandsindeling. Je kunt\n" +"meehelpen om de werking van dit importfilter te verbeteren op\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Geïmpoteerde transacties worden samengevoegd tot bankafschriften in periodes\n" +"van een week, ook als de geïmporteerde bestanden een andere periode beslaan.\n" +" " + +#. module: account_banking_nl_abnamro +#: model:ir.module.module,shortdesc:account_banking_nl_abnamro.module_meta_information +msgid "abnamro (NL) Bank Statements Import" +msgstr "Inlezen bankafschriften abnamro (NL)" + +#. module: account_banking_nl_abnamro +#: code:addons/account_banking_nl_abnamro/abnamro.py:262 +#, python-format +msgid "The Dutch Abnamro format is a tab separated text format. The last of these\n" +"fields is itself a fixed length array containing transaction type, remote\n" +"account and owner. The bank does not provide a formal specification of the\n" +"format. Transactions are not explicitely tied to bank statements, although\n" +"each file covers a period of two weeks.\n" +"" +msgstr "The Dutch Abnamro format is a tab separated text format. The last of these\n" +"fields is itself a fixed length array containing transaction type, remote\n" +"account and owner. The bank does not provide a formal specification of the\n" +"format. Transactions are not explicitely tied to bank statements, although\n" +"each file covers a period of two weeks.\n" +"" diff --git a/account_banking_nl_clieop/__terp__.py b/account_banking_nl_clieop/__terp__.py index 649353bed..8cecbf046 100644 --- a/account_banking_nl_clieop/__terp__.py +++ b/account_banking_nl_clieop/__terp__.py @@ -25,7 +25,7 @@ ############################################################################## { 'name': 'Account Banking NL ClieOp', - 'version': '0.59', + 'version': '0.60', 'license': 'GPL-3', 'author': 'EduSense BV', 'website': 'http://www.edusense.nl', diff --git a/account_banking_nl_girotel/__terp__.py b/account_banking_nl_girotel/__terp__.py index ef7520b67..f28ba42ec 100644 --- a/account_banking_nl_girotel/__terp__.py +++ b/account_banking_nl_girotel/__terp__.py @@ -25,7 +25,7 @@ ############################################################################## { 'name': 'Account Banking - Girotel', - 'version': '0.59', + 'version': '0.60', 'license': 'GPL-3', 'author': 'EduSense BV', 'website': 'http://www.edusense.nl', diff --git a/account_banking_nl_multibank/__terp__.py b/account_banking_nl_multibank/__terp__.py index f7436f201..1d43eb1f1 100644 --- a/account_banking_nl_multibank/__terp__.py +++ b/account_banking_nl_multibank/__terp__.py @@ -25,7 +25,7 @@ ############################################################################## { 'name': 'Account Banking', - 'version': '0.59', + 'version': '0.60', 'license': 'GPL-3', 'author': 'EduSense BV', 'website': 'http://www.edusense.nl', diff --git a/account_banking_nl_triodos/__init__.py b/account_banking_nl_triodos/__init__.py new file mode 100644 index 000000000..c9f181ca8 --- /dev/null +++ b/account_banking_nl_triodos/__init__.py @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2009 - 2011 EduSense BV () +# and Therp BV () +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# or Therp BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +import triodos + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_banking_nl_triodos/__openerp__.py b/account_banking_nl_triodos/__openerp__.py new file mode 100644 index 000000000..28d367294 --- /dev/null +++ b/account_banking_nl_triodos/__openerp__.py @@ -0,0 +1,58 @@ +############################################################################## +# +# Copyright (C) 2009 - 2011 EduSense BV () +# and Therp BV () +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# or Therp BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Triodos (NL) Bank Statements Import', + 'version': '0.1', + 'license': 'GPL-3', + 'author': 'Therp BV / EduSense BV', + 'website': 'https://launchpad.net/account-banking', + 'category': 'Account Banking', + 'depends': ['account_banking'], + 'init_xml': [], + 'update_xml': [ + #'security/ir.model.access.csv', + ], + 'demo_xml': [], + 'description': ''' +Module to import Dutch Triodos bank format transation files (CSV format). + +As the Triodos bank does not provide detailed specification concerning possible +values and their meaning for the fields in the CSV file format, the statements +are parsed according to an educated guess based on incomplete information. +You can contact the account-banking developers through their launchpad page and +help improve the performance of this import filter on +https://launchpad.net/account-banking. + +Note that imported bank transfers are organized in statements covering periods +of one week, even if the imported files cover a different period. + +This modules contains no logic, just an import filter for account_banking. + ''', + 'active': False, + 'installable': True, +} diff --git a/account_banking_nl_triodos/__terp__.py b/account_banking_nl_triodos/__terp__.py new file mode 100644 index 000000000..ce3680d38 --- /dev/null +++ b/account_banking_nl_triodos/__terp__.py @@ -0,0 +1,58 @@ +############################################################################## +# +# Copyright (C) 2009 - 2011 EduSense BV () +# and Therp BV () +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# or Therp BV +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Triodos (NL) Bank Statements Import', + 'version': '0.60', + 'license': 'GPL-3', + 'author': 'Therp BV / EduSense BV', + 'website': 'https://launchpad.net/account-banking', + 'category': 'Account Banking', + 'depends': ['account_banking'], + 'init_xml': [], + 'update_xml': [ + #'security/ir.model.access.csv', + ], + 'demo_xml': [], + 'description': ''' +Module to import Dutch Triodos bank format transation files (CSV format). + +As the Triodos bank does not provide detailed specification concerning possible +values and their meaning for the fields in the CSV file format, the statements +are parsed according to an educated guess based on incomplete information. +You can contact the account-banking developers through their launchpad page and +help improve the performance of this import filter on +https://launchpad.net/account-banking. + +Note that imported bank transfers are organized in statements covering periods +of one week, even if the imported files cover a different period. + +This modules contains no logic, just an import filter for account_banking. + ''', + 'active': False, + 'installable': True, +} diff --git a/account_banking_nl_triodos/i18n/account_banking_nl_triodos.pot b/account_banking_nl_triodos/i18n/account_banking_nl_triodos.pot new file mode 100644 index 000000000..6f762d575 --- /dev/null +++ b/account_banking_nl_triodos/i18n/account_banking_nl_triodos.pot @@ -0,0 +1,78 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_nl_triodos +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.1\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-04-26 18:15+0000\n" +"PO-Revision-Date: 2011-04-26 18:15+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_nl_triodos +#: model:ir.module.module,description:account_banking_nl_triodos.module_meta_information +msgid "\n" +"Module to import Dutch Triodos bank format transation files (CSV format).\n" +"\n" +"As the Triodos bank does not provide detailed specification concerning possible\n" +"values and their meaning for the fields in the CSV file format, the statements\n" +"are parsed according to an educated guess based on incomplete information.\n" +"You can contact the account-banking developers through their launchpad page and\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Note that imported bank transfers are organized in statements covering periods\n" +"of one week, even if the imported files cover a different period.\n" +"\n" +"This modules contains no logic, just an import filter for account_banking.\n" +" " +msgstr "\n" +"Module to import Dutch Triodos bank format transation files (CSV format).\n" +"\n" +"As the Triodos bank does not provide detailed specification concerning possible\n" +"values and their meaning for the fields in the CSV file format, the statements\n" +"are parsed according to an educated guess based on incomplete information.\n" +"You can contact the account-banking developers through their launchpad page and\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Note that imported bank transfers are organized in statements covering periods\n" +"of one week, even if the imported files cover a different period.\n" +"\n" +"This modules contains no logic, just an import filter for account_banking.\n" +" " + +#. module: account_banking_nl_triodos +#: model:ir.module.module,shortdesc:account_banking_nl_triodos.module_meta_information +msgid "Triodos (NL) Bank Statements Import" +msgstr "Triodos (NL) Bank Statements Import" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:185 +#, python-format +msgid "Triodos Bank" +msgstr "Triodos Bank" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:186 +#, python-format +msgid "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n" +"distinct from the Dutch multibank format. Transactions are not tied to Bank\n" +"Statements.\n" +"" +msgstr "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n" +"distinct from the Dutch multibank format. Transactions are not tied to Bank\n" +"Statements.\n" +"" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:63 +#, python-format +msgid "Invalid transaction line: expected %d columns, found %d" +msgstr "Invalid transaction line: expected %d columns, found %d" diff --git a/account_banking_nl_triodos/i18n/en.po b/account_banking_nl_triodos/i18n/en.po new file mode 100644 index 000000000..6f762d575 --- /dev/null +++ b/account_banking_nl_triodos/i18n/en.po @@ -0,0 +1,78 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_nl_triodos +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.1\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-04-26 18:15+0000\n" +"PO-Revision-Date: 2011-04-26 18:15+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_nl_triodos +#: model:ir.module.module,description:account_banking_nl_triodos.module_meta_information +msgid "\n" +"Module to import Dutch Triodos bank format transation files (CSV format).\n" +"\n" +"As the Triodos bank does not provide detailed specification concerning possible\n" +"values and their meaning for the fields in the CSV file format, the statements\n" +"are parsed according to an educated guess based on incomplete information.\n" +"You can contact the account-banking developers through their launchpad page and\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Note that imported bank transfers are organized in statements covering periods\n" +"of one week, even if the imported files cover a different period.\n" +"\n" +"This modules contains no logic, just an import filter for account_banking.\n" +" " +msgstr "\n" +"Module to import Dutch Triodos bank format transation files (CSV format).\n" +"\n" +"As the Triodos bank does not provide detailed specification concerning possible\n" +"values and their meaning for the fields in the CSV file format, the statements\n" +"are parsed according to an educated guess based on incomplete information.\n" +"You can contact the account-banking developers through their launchpad page and\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Note that imported bank transfers are organized in statements covering periods\n" +"of one week, even if the imported files cover a different period.\n" +"\n" +"This modules contains no logic, just an import filter for account_banking.\n" +" " + +#. module: account_banking_nl_triodos +#: model:ir.module.module,shortdesc:account_banking_nl_triodos.module_meta_information +msgid "Triodos (NL) Bank Statements Import" +msgstr "Triodos (NL) Bank Statements Import" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:185 +#, python-format +msgid "Triodos Bank" +msgstr "Triodos Bank" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:186 +#, python-format +msgid "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n" +"distinct from the Dutch multibank format. Transactions are not tied to Bank\n" +"Statements.\n" +"" +msgstr "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n" +"distinct from the Dutch multibank format. Transactions are not tied to Bank\n" +"Statements.\n" +"" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:63 +#, python-format +msgid "Invalid transaction line: expected %d columns, found %d" +msgstr "Invalid transaction line: expected %d columns, found %d" diff --git a/account_banking_nl_triodos/i18n/nl.po b/account_banking_nl_triodos/i18n/nl.po new file mode 100644 index 000000000..efd2f3f74 --- /dev/null +++ b/account_banking_nl_triodos/i18n/nl.po @@ -0,0 +1,77 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_nl_triodos +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.1\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-04-26 18:15+0000\n" +"PO-Revision-Date: 2011-04-26 18:15+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_nl_triodos +#: model:ir.module.module,description:account_banking_nl_triodos.module_meta_information +msgid "\n" +"Module to import Dutch Triodos bank format transation files (CSV format).\n" +"\n" +"As the Triodos bank does not provide detailed specification concerning possible\n" +"values and their meaning for the fields in the CSV file format, the statements\n" +"are parsed according to an educated guess based on incomplete information.\n" +"You can contact the account-banking developers through their launchpad page and\n" +"help improve the performance of this import filter on\n" +"https://launchpad.net/account-banking.\n" +"\n" +"Note that imported bank transfers are organized in statements covering periods\n" +"of one week, even if the imported files cover a different period.\n" +"\n" +"This modules contains no logic, just an import filter for account_banking.\n" +" " +msgstr "\n" +"Module voor het inlezen van bankafschiften van de Nederlandse Triodosbank (CSV format).\n" +"\n" +"Aangezien de Triodosbank geen details vrijgeeft over de mogelijke waarden van\n" +"de verschillende velden en hun betekenis worden de transacties zo goed mogelijk\n" +"ontleed op basis van onvolledige informatie. Je kunt de werking van dit filter\n" +"helpen verbeteren op https://launchpad.net/account-banking.\n" +"\n" +"Geïmpoteerde transacties worden samengevoegd tot bankafschriften in periodes\n" +"van een week, ook als de geïmporteerde bestanden een andere periode beslaan.\n" +"\n" +"Deze module zelf bevat geen bedrijfslogica, alleen een importdefinitie voor \n" +"account_banking.\n" +" " + +#. module: account_banking_nl_triodos +#: model:ir.module.module,shortdesc:account_banking_nl_triodos.module_meta_information +msgid "Triodos (NL) Bank Statements Import" +msgstr "Inlezen bankafschriften Triodosbank (NL)" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:185 +#, python-format +msgid "Triodos Bank" +msgstr "Triodosbank" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:186 +#, python-format +msgid "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n" +"distinct from the Dutch multibank format. Transactions are not tied to Bank\n" +"Statements.\n" +"" +msgstr "The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically\n" +"distinct from the Dutch multibank format. Transactions are not tied to Bank\n" +"Statements.\n" +"" + +#. module: account_banking_nl_triodos +#: code:addons/account_banking_nl_triodos/triodos.py:63 +#, python-format +msgid "Invalid transaction line: expected %d columns, found %d" +msgstr "Ongeldige transactieregel: %d kolommen verwacht, %d aangetroffen" diff --git a/account_banking_nl_triodos/triodos.py b/account_banking_nl_triodos/triodos.py new file mode 100644 index 000000000..5dce39924 --- /dev/null +++ b/account_banking_nl_triodos/triodos.py @@ -0,0 +1,213 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2009 EduSense BV (), +# 2011 Therp BV (). +# All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +''' +This parser follows the Dutch Banking Tools specifications which are +empirically recreated in this module. + +Dutch Banking Tools uses the concept of 'Afschrift' or Bank Statement. +Every transaction is bound to a Bank Statement. As such, this module generates +Bank Statements along with Bank Transactions. +''' +from account_banking.parsers import models +from account_banking.parsers.convert import str2date +from account_banking.sepa import postalcode +from tools.translate import _ + +import re +import csv + +__all__ = ['parser'] + +bt = models.mem_bank_transaction + +class transaction_message(object): + ''' + A auxiliary class to validate and coerce read values + ''' + attrnames = [ + 'date', 'local_account', 'transferred_amount', 'debcred', + 'remote_owner', 'remote_account', 'transfer_type', 'reference', + ] + + def __init__(self, values, subno): + ''' + Initialize own dict with attributes and coerce values to right type + ''' + if len(self.attrnames) != len(values): + raise ValueError( + _('Invalid transaction line: expected %d columns, found %d') + % (len(self.attrnames), len(values))) + self.__dict__.update(dict(zip(self.attrnames, values))) + # for lack of a standardized locale function to parse amounts + self.transferred_amount = float( + re.sub(',', '.', re.sub('\.', '', self.transferred_amount))) + if self.debcred == 'Debet': + self.transferred_amount = -self.transferred_amount + self.execution_date = str2date(self.date, '%d-%m-%Y') + self.effective_date = str2date(self.date, '%d-%m-%Y') + # Set statement_id based on week number + self.statement_id = self.effective_date.strftime('%Yw%W') + self.id = str(subno).zfill(4) + +class transaction(models.mem_bank_transaction): + ''' + Implementation of transaction communication class for account_banking. + ''' + attrnames = ['local_account', 'remote_account', + 'remote_owner', 'transferred_amount', + 'execution_date', 'effective_date', 'transfer_type', + 'reference', 'id', + ] + + type_map = { + # retrieved from online help in the Triodos banking application + 'AC': bt.ORDER, # Acceptgiro gecodeerd + 'AN': bt.ORDER, # Acceptgiro ongecodeerd + 'AT': bt.ORDER, # Acceptgiro via internet + 'BA': bt.PAYMENT_TERMINAL, # Betaalautomaat + 'CHIP': bt.BANK_TERMINAL, # Chipknip + # 'CO': # Correctie + 'DB': bt.ORDER, # Diskettebetaling + # 'DV': # Dividend + 'EI': bt.DIRECT_DEBIT, # Europese Incasso + 'EICO': bt.DIRECT_DEBIT, # Europese Incasso Correctie + 'EIST': bt.ORDER, # Europese Incasso Storno + 'ET': bt.ORDER, # Europese Transactie + 'ETST': bt.ORDER, #Europese Transactie Storno + 'GA': bt.BANK_TERMINAL, # Geldautomaat + 'IB': bt.ORDER, # Interne Boeking + 'IC': bt.DIRECT_DEBIT, # Incasso + 'ID': bt.ORDER, # iDeal-betaling + 'IT': bt.ORDER, # Internet transactie + 'KN': bt.BANK_COSTS, # Kosten + 'KO': bt.BANK_TERMINAL, # Kasopname + # 'KS': # Kwaliteitsstoring + 'OV': bt.ORDER, # Overboeking. NB: can also be bt.BANK_COSTS + # when no remote_account specified! + 'PO': bt.ORDER, # Periodieke Overboeking + 'PR': bt.BANK_COSTS, # Provisie + # 'RE': # Rente + # 'RS': # Renteschenking + 'ST': bt.ORDER, # Storno + 'TG': bt.ORDER, # Telegiro + # 'VL': # Vaste Lening + 'VO': bt.DIRECT_DEBIT, # Vordering overheid + 'VV': bt.ORDER, # Vreemde valuta + } + + def __init__(self, line, *args, **kwargs): + ''' + Initialize own dict with read values. + ''' + super(transaction, self).__init__(*args, **kwargs) + # Copy attributes from auxiliary class to self. + for attr in self.attrnames: + setattr(self, attr, getattr(line, attr)) + self.message = '' + # Decompose structured messages + self.parse_message() + if (self.transfer_type == 'OV' and + not self.remote_account and + not self.remote_owner): + self.transfer_type = 'KN' + + def is_valid(self): + if not self.error_message: + if not self.transferred_amount: + self.error_message = "No transferred amount" + elif not self.execution_date: + self.error_message = "No execution date" + elif not self.remote_account and self.transfer_type not in [ + 'KN', 'TG', 'GA', 'BA', 'CHIP' + ]: + self.error_message = ( + "No remote account for transaction type %s" % + self.transfer_type) + return not self.error_message + + def parse_message(self): + ''' + Parse structured message parts into appropriate attributes. + No processing done here for Triodos, maybe later. + ''' + +class statement(models.mem_bank_statement): + ''' + Implementation of bank_statement communication class of account_banking + ''' + def __init__(self, msg, *args, **kwargs): + ''' + Set decent start values based on first transaction read + ''' + super(statement, self).__init__(*args, **kwargs) + self.id = msg.statement_id + self.local_account = msg.local_account + self.date = str2date(msg.date, '%d-%m-%Y') + self.start_balance = self.end_balance = 0 # msg.start_balance + self.import_transaction(msg) + + def import_transaction(self, msg): + ''' + Import a transaction and keep some house holding in the mean time. + ''' + trans = transaction(msg) + self.end_balance += trans.transferred_amount + self.transactions.append(trans) + +class parser(models.parser): + code = 'TRIOD' + country_code = 'NL' + name = _('Triodos Bank') + doc = _('''\ +The Dutch Triodos format is basicly a MS Excel CSV format. It is specifically +distinct from the Dutch multibank format. Transactions are not tied to Bank +Statements. +''') + + def parse(self, data): + result = [] + stmnt = None + dialect = csv.excel() + dialect.quotechar = '"' + dialect.delimiter = ',' + lines = data.split('\n') + # Transaction lines are not numbered, so keep a tracer + subno = 0 + for line in csv.reader(lines, dialect=dialect): + # Skip empty (last) lines + if not line: + continue + subno += 1 + msg = transaction_message(line, subno) + if stmnt and stmnt.id != msg.statement_id: + result.append(stmnt) + stmnt = None + subno = 0 + if not stmnt: + stmnt = statement(msg) + else: + stmnt.import_transaction(msg) + result.append(stmnt) + return result + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: