refactor: ignore cancelled GLE's while looking for currency
(cherry picked from commit 8d9b90f3f53083e631444a0d39d86bda0b08f479)
This commit is contained in:
parent
f132552968
commit
9ce123d0b9
@ -5,7 +5,7 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, msgprint, scrub
|
from frappe import _, msgprint, qb, scrub
|
||||||
from frappe.contacts.doctype.address.address import get_company_address, get_default_address
|
from frappe.contacts.doctype.address.address import get_company_address, get_default_address
|
||||||
from frappe.core.doctype.user_permission.user_permission import get_permitted_documents
|
from frappe.core.doctype.user_permission.user_permission import get_permitted_documents
|
||||||
from frappe.model.utils import get_fetch_values
|
from frappe.model.utils import get_fetch_values
|
||||||
@ -480,11 +480,19 @@ def get_party_account_currency(party_type, party, company):
|
|||||||
|
|
||||||
def get_party_gle_currency(party_type, party, company):
|
def get_party_gle_currency(party_type, party, company):
|
||||||
def generator():
|
def generator():
|
||||||
existing_gle_currency = frappe.db.sql(
|
gl = qb.DocType("GL Entry")
|
||||||
"""select account_currency from `tabGL Entry`
|
existing_gle_currency = (
|
||||||
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_currency)
|
||||||
{"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_currency[0][0] if existing_gle_currency else None
|
return existing_gle_currency[0][0] if existing_gle_currency else None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user