fix(General Ledger): Condense account_conditions
This commit is contained in:
parent
79dc0f0afc
commit
53a9ac4466
@ -211,15 +211,16 @@ def get_conditions(filters):
|
|||||||
conditions = []
|
conditions = []
|
||||||
|
|
||||||
if filters.get("account") and not filters.get("include_dimensions"):
|
if filters.get("account") and not filters.get("include_dimensions"):
|
||||||
account_conditions = ""
|
account_conditions = "account in (select name from tabAccount where"
|
||||||
for account in filters["account"]:
|
for account in filters["account"]:
|
||||||
lft, rgt = frappe.db.get_value("Account", account, ["lft", "rgt"])
|
lft, rgt = frappe.db.get_value("Account", account, ["lft", "rgt"])
|
||||||
account_conditions += """account in (select name from tabAccount
|
account_conditions += """ (lft>=%s and rgt<=%s) """ % (lft, rgt)
|
||||||
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt)
|
|
||||||
|
|
||||||
# so that the OR doesn't get added to the last account condition
|
# so that the OR doesn't get added to the last account condition
|
||||||
if account != filters["account"][-1]:
|
if account != filters["account"][-1]:
|
||||||
account_conditions += "OR"
|
account_conditions += "OR"
|
||||||
|
|
||||||
|
account_conditions += "and docstatus<2)"
|
||||||
conditions.append(account_conditions)
|
conditions.append(account_conditions)
|
||||||
|
|
||||||
if filters.get("cost_center"):
|
if filters.get("cost_center"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user