[FIX] account_statement_import_camt: Add more info on payment reference instead of / when more info available

Updated changes as suggested

pre-commit fixes

Fixed call of function
This commit is contained in:
Anjeel
2024-03-06 18:30:32 +05:30
committed by Anjeel Haria
parent 10d1c443e7
commit 2cc7e64f4b
2 changed files with 10 additions and 3 deletions

View File

@@ -61,7 +61,6 @@ class CamtParser(models.AbstractModel):
node,
[
"./ns:RmtInf/ns:Ustrd|./ns:RtrInf/ns:AddtlInf",
"./ns:AddtlNtryInf",
"./ns:Refs/ns:InstrId",
],
transaction,
@@ -329,6 +328,7 @@ class CamtParser(models.AbstractModel):
details_nodes = node.xpath("./ns:NtryDtls/ns:TxDtls", namespaces={"ns": ns})
if len(details_nodes) == 0:
self.amend_transaction(transaction)
self.generate_narration(transaction)
yield transaction
return
@@ -336,6 +336,7 @@ class CamtParser(models.AbstractModel):
for node in details_nodes:
transaction = transaction_base.copy()
self.parse_transaction_details(ns, node, transaction)
self.amend_transaction(transaction)
self.generate_narration(transaction)
yield transaction
@@ -456,3 +457,9 @@ class CamtParser(models.AbstractModel):
account_number = statement.pop("account_number")
statements.append(statement)
return currency, account_number, statements
def amend_transaction(self, transaction):
if transaction.get("payment_ref") == "/":
transaction["payment_ref"] = transaction["narration"].get(
"%s (AddtlNtryInf)" % _("Additional Entry Information"), "/"
)

View File

@@ -20,7 +20,7 @@
'Account Servicer Reference (Refs/AcctSvcrRef): 123456CHCAFEBABE\n'
'Postal Address (PstlAdr): Place Saint-François | 14 | 1003 | Lausanne | CH1',
'partner_name': 'Banque Cantonale Vaudoise',
'payment_ref': '/',
'payment_ref': 'CRÉDIT GROUPÉ BVR TRAITEMENT DU 22.03.2017 NUMÉRO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE',
'ref': '302388292000011111111111111',
'transaction_type': 'PMNT-RCDT-VCOM'},
{'account_number': 'CH3333000000123456789',
@@ -39,6 +39,6 @@
'Account Servicer Reference (Refs/AcctSvcrRef): 123456CHCAFEBABE\n'
'Postal Address (PstlAdr): Place Saint-François | 14 | 1003 | Lausanne | CH2',
'partner_name': 'Banque Cantonale Vaudoise',
'payment_ref': '/',
'payment_ref': 'CRÉDIT GROUPÉ BVR TRAITEMENT DU 22.03.2017 NUMÉRO CLIENT 01-70884-3 PAQUET ID: 123456CHCAFEBABE',
'ref': '302388292000022222222222222',
'transaction_type': 'PMNT-RCDT-VCOM'}]}])