Browse Source

CAMT import for ING bank Netherlands gives error on saving account lines (#108)

* CAMT import for ING bank netherlands gives error on 'transfer to saving account' entries where 'Ntry/NtryDtls/TxDtls/RmtInf/Ustrd' element is missing. Selecting 'Ntry/NtryDtls/TxDtls/RltdPties/CdtrAcct/Tp/Prtry' in this case.

Also: The name of the savings account should be last in the list of things to look in for the transaction name, DbtrAcct entry added to catch a meaningful name for to AND from savings account entries. Default added for when nothing is found
pull/124/head
Tom 7 years ago
committed by Stefan Rijnhart (Opener)
parent
commit
d12419ba87
  1. 1
      account_bank_statement_import_camt/__openerp__.py
  2. 24
      account_bank_statement_import_camt/camt.py

1
account_bank_statement_import_camt/__openerp__.py

@ -20,6 +20,7 @@
{
'name': 'CAMT Format Bank Statements Import',
'version': '8.0.0.4.0',
'summary': 'Module to import SEPA CAMT.053 Format bank statement files',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import',

24
account_bank_statement_import_camt/camt.py

@ -21,11 +21,14 @@
##############################################################################
import re
from copy import copy
from datetime import datetime
from lxml import etree
from openerp import _
from openerp.addons.account_bank_statement_import.parserlib import (
BankStatement)
from copy import copy
class CamtParser(object):
@ -46,7 +49,8 @@ class CamtParser(object):
return amount
def add_value_from_node(
self, ns, node, xpath_str, obj, attr_name, join_str=None):
self, ns, node, xpath_str, obj, attr_name, join_str=None,
default=None):
"""Add value to object from first or all nodes found with xpath.
If xpath_str is a list (or iterable), it will be seen as a series
@ -63,16 +67,28 @@ class CamtParser(object):
attr_value = join_str.join([x.text for x in found_node])
setattr(obj, attr_name, attr_value)
break
else:
if default:
setattr(obj, attr_name, default)
def parse_transaction_details(self, ns, node, transaction):
"""Parse TxDtls node."""
# message
self.add_value_from_node(
ns, node, [
ns,
node,
[
'./ns:RmtInf/ns:Ustrd',
'./ns:AddtlTxInf',
'./ns:AddtlNtryInf',
], transaction, 'message', join_str='\n')
'./ns:RltdPties/ns:CdtrAcct/ns:Tp/ns:Prtry',
'./ns:RltdPties/ns:DbtrAcct/ns:Tp/ns:Prtry',
],
transaction,
'message',
join_str='\n',
default=_('No description')
)
# eref
self.add_value_from_node(
ns, node, [

Loading…
Cancel
Save