fix: Don't set description as key in Mapper doc if matched by description

- Description is volatile and will keep changing
- It will lead to multiple Bank Party Mapper docs for the same party that will never be referenced again
- Parts of the descripton keep changing which is why it will never match a mapper record
- If matched by desc, dont create mapper record.
This commit is contained in:
marination 2023-04-04 14:03:35 +05:30
parent 3a898289b0
commit 37c1331aba
2 changed files with 12 additions and 6 deletions

View File

@ -107,10 +107,10 @@ class AutoMatchbyPartyDescription:
or_filters = []
if self.bank_party_name:
or_filters.append(["bank_party_name_desc", self.bank_party_name])
or_filters.append({"bank_party_name_desc": self.bank_party_name})
if self.description:
or_filters.append(["bank_party_name_desc", self.description])
or_filters.append({"bank_party_name_desc": self.description})
mapper_res = frappe.get_all(
"Bank Party Mapper",
@ -156,7 +156,13 @@ class AutoMatchbyPartyDescription:
if result:
party_name, score, index = result
if score > 75:
return (party, party_name, {"bank_party_name_desc": self.get(field)})
# Dont set description as a key in Bank Party Mapper due to its volatility
mapper = {"bank_party_name_desc": self.get(field)} if field == "bank_party_name" else None
return (
party,
party_name,
mapper,
)
else:
return None

View File

@ -18,9 +18,6 @@ class BankTransaction(StatusUpdater):
self.unallocated_amount = abs(flt(self.withdrawal) - flt(self.deposit))
def on_update(self):
if self.party_type and self.party:
return
self.auto_set_party()
def on_submit(self):
@ -162,6 +159,9 @@ class BankTransaction(StatusUpdater):
# TODO: check if enabled
from erpnext.accounts.doctype.bank_transaction.auto_match_party import AutoMatchParty
if self.party_type and self.party:
return
result = AutoMatchParty(
bank_party_account_number=self.bank_party_account_number,
bank_party_iban=self.bank_party_iban,