mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[13.0][IMP]account_bank_statement_import_camt_oca - line note
This commit is contained in:
@@ -8,7 +8,7 @@ import pytz
|
||||
from dateutil.parser import isoparse
|
||||
from lxml import etree
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
class CamtParser(models.AbstractModel):
|
||||
@@ -70,7 +70,7 @@ class CamtParser(models.AbstractModel):
|
||||
)
|
||||
# name
|
||||
self.add_value_from_node(
|
||||
ns, node, ["./ns:AddtlTxInf"], transaction, "note", join_str="\n"
|
||||
ns, node, ["./ns:AddtlTxInf"], transaction, "AddtlTxInf", join_str="\n"
|
||||
)
|
||||
# eref
|
||||
self.add_value_from_node(
|
||||
@@ -222,6 +222,8 @@ class CamtParser(models.AbstractModel):
|
||||
transactions = []
|
||||
for entry_node in entry_nodes:
|
||||
transactions.extend(self.parse_entry(ns, entry_node))
|
||||
for transaction in transactions:
|
||||
self._add_line_note(transaction)
|
||||
result["transactions"] = transactions
|
||||
result["date"] = None
|
||||
if transactions:
|
||||
@@ -230,6 +232,27 @@ class CamtParser(models.AbstractModel):
|
||||
)[0]["date"]
|
||||
return result
|
||||
|
||||
def _add_line_note(self, transaction):
|
||||
transaction["note"] = _(
|
||||
"Partner Name: %s"
|
||||
"\nPartner Account Number: %s"
|
||||
"\nTransaction Date: %s"
|
||||
"\nReference: %s"
|
||||
"\nCommunication: %s"
|
||||
) % (
|
||||
transaction.get("partner_name", "").strip(),
|
||||
transaction.get("account_number", ""),
|
||||
transaction.get("date", ""),
|
||||
transaction.get("ref", "").strip(),
|
||||
transaction.get("name", "").strip(),
|
||||
)
|
||||
AddtlTxInf = transaction.pop("AddtlTxInf", None)
|
||||
if AddtlTxInf:
|
||||
transaction["note"] += (
|
||||
_("\nAdditional Transaction Information: %s")
|
||||
% transaction["AddtlTxInf"].strip()
|
||||
)
|
||||
|
||||
def check_version(self, ns, root):
|
||||
"""Validate validity of camt file."""
|
||||
# Check whether it is camt at all:
|
||||
|
||||
Reference in New Issue
Block a user