Browse Source

[FIX] Prioritize batch node over details.

pull/153/head
Ronald Portier 8 years ago
parent
commit
3d627657ce
  1. 23
      account_bank_statement_import_camt/models/parser.py

23
account_bank_statement_import_camt/models/parser.py

@ -158,18 +158,23 @@ class CamtParser(models.AbstractModel):
self.add_value_from_node(
node, './ns:ValDt/ns:Dt', transaction, 'value_date')
transaction.transferred_amount = self.parse_amount(node)
self.add_value_from_node(
node, './ns:AddtlNtryInf', transaction, 'name')
self.add_value_from_node(
ns, node, [
'./ns:NtryDtls/ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref',
'./ns:NtryDtls/ns:Btch/ns:PmtInfId',
],
transaction, 'eref'
)
batch_node = self.xpath(node, './ns:NtryDtls/ns:Btch')
if batch_node:
self.add_value_from_node(
batch_node[0], './ns:PmtInfId', transaction, 'eref')
else:
self.add_value_from_node(
node, './ns:AddtlNtryInf', transaction, 'name')
self.add_value_from_node(
node,
['./ns:NtryDtls/ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref',
'./ns:NtryDtls/ns:Btch/ns:PmtInfId'],
transaction,
'eref')
details_nodes = node.xpath(
'./ns:NtryDtls/ns:TxDtls', namespaces={'ns': ns})
if len(details_nodes) == 0:
transaction.data = etree.tostring(node)
yield transaction
return
transaction_base = transaction

Loading…
Cancel
Save