mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MRG] backports from previous merge request
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Account Banking',
|
||||
'version': '0.1.57',
|
||||
'version': '0.1.61',
|
||||
'license': 'GPL-3',
|
||||
'author': 'EduSense BV',
|
||||
'website': 'http://www.edusense.nl',
|
||||
|
||||
@@ -878,7 +878,7 @@ class payment_order(osv.osv):
|
||||
to the absence of filters on writes and hence the requirement to
|
||||
filter on the client(=OpenERP server) side.
|
||||
'''
|
||||
if isinstance(ids, (int, long)):
|
||||
if not hasattr(ids, '__iter__'):
|
||||
ids = [ids]
|
||||
payment_line_obj = self.pool.get('payment.line')
|
||||
line_ids = payment_line_obj.search(
|
||||
@@ -917,16 +917,16 @@ class payment_order(osv.osv):
|
||||
uid, 'payment.order', id, 'rejected', cursor)
|
||||
return True
|
||||
|
||||
def set_done(self, cursor, uid, id, *args):
|
||||
def set_done(self, cursor, uid, ids, *args):
|
||||
'''
|
||||
Extend standard transition to update children as well.
|
||||
'''
|
||||
self._write_payment_lines(cursor, uid, id,
|
||||
self._write_payment_lines(cursor, uid, ids,
|
||||
export_state='done',
|
||||
date_done=time.strftime('%Y-%m-%d')
|
||||
)
|
||||
return super(payment_order, self).set_done(
|
||||
cursor, uid, id, *args
|
||||
cursor, uid, ids, *args
|
||||
)
|
||||
|
||||
def get_wizard(self, type):
|
||||
@@ -1182,9 +1182,16 @@ class res_partner_bank(osv.osv):
|
||||
# the handling user
|
||||
if not country_ids:
|
||||
user = self.pool.get('res.users').browse(cursor, uid, uid)
|
||||
# Try users address first
|
||||
if user.address_id and user.address_id.country_id:
|
||||
country = user.address_id.country_id
|
||||
country_ids = [country.id]
|
||||
# Last try user companies partner
|
||||
elif (user.company_id and
|
||||
user.company_id.partner_id and
|
||||
user.company_id.partner_id.country
|
||||
):
|
||||
country_ids = [user.company_id.partner_id.country.id]
|
||||
else:
|
||||
if (user.company_id and user.company_id.partner_id and
|
||||
user.company_id.partner_id.country):
|
||||
|
||||
@@ -239,7 +239,7 @@ class mem_bank_transaction(object):
|
||||
'''
|
||||
super(mem_bank_transaction, self).__init__(*args, **kwargs)
|
||||
for attr in self.__slots__:
|
||||
setattr(self, attr, None)
|
||||
setattr(self, attr, '')
|
||||
self.remote_owner_address = []
|
||||
|
||||
def copy(self):
|
||||
@@ -344,6 +344,16 @@ class parser(object):
|
||||
numbers or bank statements ids on your own - stick with those provided
|
||||
by your bank. Doing so enables the users to re-load old transaction
|
||||
files without creating multiple identical bank statements.
|
||||
|
||||
If your bank does not provide transaction ids, take a high resolution
|
||||
and a repeatable algorithm for the numbering. For example the date can
|
||||
be used as a prefix. Adding a tracer (day resolution) can create
|
||||
uniqueness. Adding unique statement ids can add to the robustness of
|
||||
your transaction numbering.
|
||||
|
||||
Just mind that users can create random (file)containers with
|
||||
transactions in it. Try not to depend on order of appearance within
|
||||
these files. If in doubt: sort.
|
||||
'''
|
||||
raise NotImplementedError(
|
||||
_('This is a stub. Please implement your own.')
|
||||
|
||||
@@ -198,7 +198,7 @@ class IBAN(str):
|
||||
'CS': BBANFormat('BBBAAAAAAAAAAAAAVV', '%B-%A-%V'),
|
||||
'CY': BBANFormat('BBBCCCCCAAAAAAAAAAAAAAAA', '%B%C%A'),
|
||||
'CZ': BBANFormat('BBBBPPPPPPAAAAAAAAAA', '%B-%P/%A'),
|
||||
'DE': BBANFormat('BBBBBBBBAAAAAAAAAA', '%A BLZ %B'),
|
||||
'DE': BBANFormat('BBBBBBBBAAAAAAAAAAV', '%A BLZ %B'),
|
||||
'DK': BBANFormat('CCCCAAAAAAAAAV', '%C %A%V'),
|
||||
'EE': BBANFormat('BBCCAAAAAAAAAAAV', '%A%V'),
|
||||
'ES': BBANFormat('BBBBCCCCWVAAAAAAAAAA', '%B%C%W%V%A'),
|
||||
|
||||
@@ -132,7 +132,7 @@ def BBAN_is_IBAN(bank_acc):
|
||||
else:
|
||||
iban_acc = IBAN(bank_acc)
|
||||
return struct(
|
||||
iban = iban_acc,
|
||||
iban = str(iban_acc),
|
||||
account = str(bank_acc),
|
||||
country_id = iban_acc.countrycode,
|
||||
code = iban_acc.BIC_searchkey,
|
||||
|
||||
@@ -753,7 +753,8 @@ class banking_import(wizard.interface):
|
||||
results.log)
|
||||
if not period_id:
|
||||
results.trans_skipped_cnt += 1
|
||||
i += 1
|
||||
if not injected:
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# When bank costs are part of transaction itself, split it.
|
||||
|
||||
@@ -147,6 +147,8 @@ def get_or_create_partner(pool, cursor, uid, name, address, postal_code, city,
|
||||
filter.append(('zip', 'ilike', postal_code))
|
||||
address_ids = address_obj.search(cursor, uid, filter)
|
||||
key = name.lower()
|
||||
|
||||
# Make sure to get a unique list
|
||||
partner_ids = list(set([x.partner_id.id
|
||||
for x in address_obj.browse(cursor, uid, address_ids)
|
||||
# Beware for dangling addresses
|
||||
@@ -156,21 +158,23 @@ def get_or_create_partner(pool, cursor, uid, name, address, postal_code, city,
|
||||
if not partner_ids:
|
||||
if (not country_code) or not country_id:
|
||||
user = pool.get('res.user').browse(cursor, uid, uid)
|
||||
country_id = (user.company_id and user.company_id.partner_id and
|
||||
user.company_id.partner_id.country and
|
||||
user.company_id.partner_id.country.id or False)
|
||||
partner_id = partner_obj.create(
|
||||
cursor, uid, dict(
|
||||
name=name, active=True,
|
||||
comment='Generated from Bank Statements Import',
|
||||
address=[(0,0,{
|
||||
'street': address and address[0] or '',
|
||||
'street2': len(address) > 1 and address[1] or '',
|
||||
'city': city,
|
||||
'zip': postal_code or '',
|
||||
'country_id': country_id,
|
||||
})],)
|
||||
country_id = (
|
||||
user.company_id and
|
||||
user.company_id.partner_id and
|
||||
user.company_id.partner_id.country and
|
||||
user.company_id.partner_id.country.id or
|
||||
False
|
||||
)
|
||||
partner_id = partner_obj.create(cursor, uid, dict(
|
||||
name=name, active=True, comment='Generated from Bank Statements Import',
|
||||
address=[(0,0,{
|
||||
'street': address and address[0] or '',
|
||||
'street2': len(address) > 1 and address[1] or '',
|
||||
'city': city,
|
||||
'zip': postal_code or '',
|
||||
'country_id': country_id,
|
||||
})],
|
||||
))
|
||||
elif len(partner_ids) > 1:
|
||||
log.append(
|
||||
_('More then one possible match found for partner with name %(name)s')
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Account Banking PATU module',
|
||||
'version': '0.57',
|
||||
'version': '0.61',
|
||||
'license': 'GPL-3',
|
||||
'author': 'Sami Haahtinen',
|
||||
'website': 'http://ressukka.net',
|
||||
|
||||
31
account_banking_nl_abnamro/__init__.py
Normal file
31
account_banking_nl_abnamro/__init__.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
|
||||
# and Therp BV (<http://therp.nl>)
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import abnamro
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
53
account_banking_nl_abnamro/__openerp__.py
Normal file
53
account_banking_nl_abnamro/__openerp__.py
Normal file
@@ -0,0 +1,53 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
|
||||
# and Therp BV (<http://therp.nl>)
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
'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,
|
||||
}
|
||||
53
account_banking_nl_abnamro/__terp__.py
Normal file
53
account_banking_nl_abnamro/__terp__.py
Normal file
@@ -0,0 +1,53 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
|
||||
# and Therp BV (<http://therp.nl>)
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'abnamro (NL) Bank Statements Import',
|
||||
'version': '0.61',
|
||||
'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,
|
||||
}
|
||||
287
account_banking_nl_abnamro/abnamro.py
Normal file
287
account_banking_nl_abnamro/abnamro.py
Normal file
@@ -0,0 +1,287 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>)
|
||||
# 2011 Therp BV (<http://therp.nl>)
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
'''
|
||||
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:
|
||||
@@ -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"
|
||||
""
|
||||
84
account_banking_nl_abnamro/i18n/en.po
Normal file
84
account_banking_nl_abnamro/i18n/en.po
Normal file
@@ -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"
|
||||
""
|
||||
84
account_banking_nl_abnamro/i18n/nl.po
Normal file
84
account_banking_nl_abnamro/i18n/nl.po
Normal file
@@ -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"
|
||||
""
|
||||
@@ -25,7 +25,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Account Banking NL ClieOp',
|
||||
'version': '0.57',
|
||||
'version': '0.61',
|
||||
'license': 'GPL-3',
|
||||
'author': 'EduSense BV',
|
||||
'website': 'http://www.edusense.nl',
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Account Banking - Girotel',
|
||||
'version': '0.57',
|
||||
'version': '0.61',
|
||||
'license': 'GPL-3',
|
||||
'author': 'EduSense BV',
|
||||
'website': 'http://www.edusense.nl',
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Account Banking',
|
||||
'version': '0.57',
|
||||
'version': '0.61',
|
||||
'license': 'GPL-3',
|
||||
'author': 'EduSense BV',
|
||||
'website': 'http://www.edusense.nl',
|
||||
|
||||
@@ -136,7 +136,7 @@ class transaction(models.mem_bank_transaction):
|
||||
|
||||
2. Invoices from the bank itself are communicated through statements.
|
||||
These too have no remote_account and no remote_owner. They have a
|
||||
transfer_type set to 'KST' or 'KNT'.
|
||||
transfer_type set to 'KST', 'KNT' or 'DIV'.
|
||||
|
||||
3. Transfers sent through the 'International Transfers' system get
|
||||
their feedback rerouted through a statement, which is not designed to
|
||||
@@ -155,7 +155,7 @@ class transaction(models.mem_bank_transaction):
|
||||
self.effective_date) and (
|
||||
self.remote_account or
|
||||
self.transfer_type in [
|
||||
'KST', 'PRV', 'BTL', 'BEA', 'OPN', 'KNT',
|
||||
'KST', 'PRV', 'BTL', 'BEA', 'OPN', 'KNT', 'DIV',
|
||||
]
|
||||
and not self.error_message
|
||||
)
|
||||
@@ -306,6 +306,7 @@ to Bank Statements.
|
||||
# Probe first record to find out which format we are parsing.
|
||||
if lines and lines[0].count(',') > lines[0].count(';'):
|
||||
dialect.delimiter = ','
|
||||
if lines and lines[0].count("'") > lines[0].count('"'):
|
||||
dialect.quotechar = "'"
|
||||
# Transaction lines are not numbered, so keep a tracer
|
||||
subno = 0
|
||||
|
||||
31
account_banking_nl_triodos/__init__.py
Normal file
31
account_banking_nl_triodos/__init__.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
|
||||
# and Therp BV (<http://therp.nl>)
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import triodos
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
58
account_banking_nl_triodos/__openerp__.py
Normal file
58
account_banking_nl_triodos/__openerp__.py
Normal file
@@ -0,0 +1,58 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
|
||||
# and Therp BV (<http://therp.nl>)
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
'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,
|
||||
}
|
||||
58
account_banking_nl_triodos/__terp__.py
Normal file
58
account_banking_nl_triodos/__terp__.py
Normal file
@@ -0,0 +1,58 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 - 2011 EduSense BV (<http://www.edusense.nl>)
|
||||
# and Therp BV (<http://therp.nl>)
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
'name': 'Triodos (NL) Bank Statements Import',
|
||||
'version': '0.61',
|
||||
'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,
|
||||
}
|
||||
@@ -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"
|
||||
78
account_banking_nl_triodos/i18n/en.po
Normal file
78
account_banking_nl_triodos/i18n/en.po
Normal file
@@ -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"
|
||||
77
account_banking_nl_triodos/i18n/nl.po
Normal file
77
account_banking_nl_triodos/i18n/nl.po
Normal file
@@ -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"
|
||||
213
account_banking_nl_triodos/triodos.py
Normal file
213
account_banking_nl_triodos/triodos.py
Normal file
@@ -0,0 +1,213 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>),
|
||||
# 2011 Therp BV (<http://therp.nl>).
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
'''
|
||||
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:
|
||||
Reference in New Issue
Block a user