Skip to content

Commit

Permalink
fix: Don't set description as key in Mapper doc if matched by descrip…
Browse files Browse the repository at this point in the history
…tion

- 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.
  • Loading branch information
marination committed Apr 4, 2023
1 parent 3a89828 commit 37c1331
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions erpnext/accounts/doctype/bank_transaction/auto_match_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ def match_party_name_desc_in_bank_party_mapper(self):
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",
Expand Down Expand Up @@ -156,7 +156,13 @@ def fuzzy_search_and_return_result(self, party, names, field):
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

Expand Down
6 changes: 3 additions & 3 deletions erpnext/accounts/doctype/bank_transaction/bank_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ def after_insert(self):
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):
Expand Down Expand Up @@ -162,6 +159,9 @@ def auto_set_party(self):
# 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,
Expand Down

0 comments on commit 37c1331

Please sign in to comment.