mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
perf: evaluate conditions outside loop
This commit is contained in:
@@ -398,27 +398,29 @@ def get_data_with_opening_closing(filters, account_details, accounting_dimension
|
|||||||
add_total_to_data(totals, "opening")
|
add_total_to_data(totals, "opening")
|
||||||
|
|
||||||
if filters.get("group_by") != "Group by Voucher (Consolidated)":
|
if filters.get("group_by") != "Group by Voucher (Consolidated)":
|
||||||
for _acc, acc_dict in gle_map.items():
|
set_opening_closing = (not filters.get("group_by") and not filters.get("voucher_no")) or (
|
||||||
# acc
|
filters.get("group_by") and filters.get("group_by") != "Group by Voucher"
|
||||||
if acc_dict.entries:
|
)
|
||||||
# opening
|
set_total = filters.get("group_by") or not filters.voucher_no
|
||||||
data.append({"debit_in_transaction_currency": None, "credit_in_transaction_currency": None})
|
|
||||||
if (not filters.get("group_by") and not filters.get("voucher_no")) or (
|
|
||||||
filters.get("group_by") and filters.get("group_by") != "Group by Voucher"
|
|
||||||
):
|
|
||||||
add_total_to_data(acc_dict.totals, "opening")
|
|
||||||
|
|
||||||
data += acc_dict.entries
|
for acc_dict in gle_map.values():
|
||||||
|
if not acc_dict.entries:
|
||||||
|
continue
|
||||||
|
|
||||||
# totals
|
# opening
|
||||||
if filters.get("group_by") or not filters.voucher_no:
|
data.append({"debit_in_transaction_currency": None, "credit_in_transaction_currency": None})
|
||||||
add_total_to_data(acc_dict.totals, "total")
|
if set_opening_closing:
|
||||||
|
add_total_to_data(acc_dict.totals, "opening")
|
||||||
|
|
||||||
# closing
|
data += acc_dict.entries
|
||||||
if (not filters.get("group_by") and not filters.get("voucher_no")) or (
|
|
||||||
filters.get("group_by") and filters.get("group_by") != "Group by Voucher"
|
# totals
|
||||||
):
|
if set_total:
|
||||||
add_total_to_data(acc_dict.totals, "closing")
|
add_total_to_data(acc_dict.totals, "total")
|
||||||
|
|
||||||
|
# closing
|
||||||
|
if set_opening_closing:
|
||||||
|
add_total_to_data(acc_dict.totals, "closing")
|
||||||
|
|
||||||
data.append({"debit_in_transaction_currency": None, "credit_in_transaction_currency": None})
|
data.append({"debit_in_transaction_currency": None, "credit_in_transaction_currency": None})
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user