chore: Remove unnecessary list comprehension

This commit is contained in:
Deepesh Garg 2023-03-19 19:46:01 +05:30
parent 0aadb680eb
commit 44053db010
2 changed files with 6 additions and 16 deletions

View File

@ -98,7 +98,7 @@ def execute(filters=None):
chart = get_chart_data(filters, columns, asset, liability, equity)
report_summary = get_report_summary(
period_list, asset, liability, equity, provisional_profit_loss, total_credit, currency, filters
period_list, asset, liability, equity, provisional_profit_loss, currency, filters
)
return columns, data, message, chart, report_summary
@ -176,7 +176,6 @@ def get_report_summary(
liability,
equity,
provisional_profit_loss,
total_credit,
currency,
filters,
consolidated=False,

View File

@ -418,23 +418,15 @@ def set_gl_entries_by_account(
ignore_closing_entries=False,
):
"""Returns a dict like { "account": [gl entries], ... }"""
gl_entries = []
account = frappe.qb.DocType("Account")
accounts = (
frappe.qb.from_(account)
.select(account.name)
.where(account.lft >= root_lft)
.where(account.rgt <= root_rgt)
.where(account.company == company)
.run(as_dict=True)
accounts_list = frappe.db.get_all(
"Account",
filters={"company": company, "is_group": 0, "lft": (">=", root_lft), "rgt": ("<=", root_rgt)},
pluck="name",
)
accounts_list = [account.name for account in accounts]
if accounts_list:
# For balance sheet
if not from_date:
from_date = filters["period_start_date"]
@ -493,8 +485,6 @@ def get_accounting_entries(
.where(gl_entry.company == filters.company)
)
query = query.where(gl_entry.account.isin(accounts))
if doctype == "GL Entry":
query = query.select(gl_entry.posting_date, gl_entry.is_opening, gl_entry.fiscal_year)
query = query.where(gl_entry.is_cancelled == 0)
@ -504,6 +494,7 @@ def get_accounting_entries(
query = query.where(gl_entry.period_closing_voucher == period_closing_voucher)
query = apply_additional_conditions(doctype, query, from_date, ignore_closing_entries, filters)
query = query.where(gl_entry.account.isin(accounts))
entries = query.run(as_dict=True)