Merge pull request #55943 from aerele/ignore_cancelled_GLE

refactor: ignore cancelled GLE's while looking for account
This commit is contained in:
Nabin Hait
2026-06-16 16:36:18 +05:30
committed by GitHub

View File

@@ -543,11 +543,19 @@ def get_party_gle_currency(party_type, party, company):
def get_party_gle_account(party_type, party, company): def get_party_gle_account(party_type, party, company):
def generator(): def generator():
existing_gle_account = frappe.db.sql( gl = qb.DocType("GL Entry")
"""select account from `tabGL Entry` existing_gle_account = (
where docstatus=1 and company=%(company)s and party_type=%(party_type)s and party=%(party)s qb.from_(gl)
limit 1""", .select(gl.account)
{"company": company, "party_type": party_type, "party": party}, .where(
(gl.docstatus == 1)
& (gl.company == company)
& (gl.party_type == party_type)
& (gl.party == party)
& (gl.is_cancelled == 0)
)
.limit(1)
.run()
) )
return existing_gle_account[0][0] if existing_gle_account else None return existing_gle_account[0][0] if existing_gle_account else None