fix: Set right party name in bank transaction
- If party name and docname are different, set the docname in Bank Transaction
This commit is contained in:
parent
f160e49483
commit
ff1dc72d74
@ -1,6 +1,7 @@
|
|||||||
from typing import Tuple, Union
|
from typing import Tuple, Union
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.core.utils import find
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from rapidfuzz import fuzz, process
|
from rapidfuzz import fuzz, process
|
||||||
|
|
||||||
@ -112,7 +113,8 @@ class AutoMatchbyPartyNameDescription:
|
|||||||
|
|
||||||
for party in parties:
|
for party in parties:
|
||||||
filters = {"status": "Active"} if party == "Employee" else {"disabled": 0}
|
filters = {"status": "Active"} if party == "Employee" else {"disabled": 0}
|
||||||
names = frappe.get_all(party, filters=filters, pluck=party.lower() + "_name")
|
field = party.lower() + "_name"
|
||||||
|
names = frappe.get_all(party, filters=filters, fields=[f"{field} as party_name", "name"])
|
||||||
|
|
||||||
for field in ["bank_party_name", "description"]:
|
for field in ["bank_party_name", "description"]:
|
||||||
if not self.get(field):
|
if not self.get(field):
|
||||||
@ -131,12 +133,18 @@ class AutoMatchbyPartyNameDescription:
|
|||||||
|
|
||||||
def fuzzy_search_and_return_result(self, party, names, field) -> Union[Tuple, None]:
|
def fuzzy_search_and_return_result(self, party, names, field) -> Union[Tuple, None]:
|
||||||
skip = False
|
skip = False
|
||||||
result = process.extract(query=self.get(field), choices=names, scorer=fuzz.token_set_ratio)
|
result = process.extract(
|
||||||
|
query=self.get(field),
|
||||||
|
choices=[name.get("party_name") for name in names],
|
||||||
|
scorer=fuzz.token_set_ratio,
|
||||||
|
)
|
||||||
party_name, skip = self.process_fuzzy_result(result)
|
party_name, skip = self.process_fuzzy_result(result)
|
||||||
|
|
||||||
if not party_name:
|
if not party_name:
|
||||||
return None, skip
|
return None, skip
|
||||||
|
|
||||||
|
# Get Party Docname from the list of dicts
|
||||||
|
party_name = find(names, lambda x: x["party_name"] == party_name).get("name")
|
||||||
return (
|
return (
|
||||||
party,
|
party,
|
||||||
party_name,
|
party_name,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user