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) chart = get_chart_data(filters, columns, asset, liability, equity)
report_summary = get_report_summary( 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 return columns, data, message, chart, report_summary
@ -176,7 +176,6 @@ def get_report_summary(
liability, liability,
equity, equity,
provisional_profit_loss, provisional_profit_loss,
total_credit,
currency, currency,
filters, filters,
consolidated=False, consolidated=False,

View File

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