fix: account group totals calculation to consider include_in_gross

This commit is contained in:
Anoop Kurungadam
2023-05-08 20:41:38 +05:30
parent 19f08afcef
commit 8dcb9302b4

View File

@@ -152,10 +152,17 @@ def adjust_account(data, period_list, consolidated=False):
totals = {}
for node in leaf_nodes:
set_total(node, node["total"], data, totals)
for d in data:
for d in reversed(data):
for period in period_list:
key = period if consolidated else period.key
if d.get("is_group"):
# reset totals for group accounts as totals set by get_data doesn't consider include_in_gross check
d[period.key] = sum(
item[period.key] for item in data if item.get("parent_account") == d.get("account")
)
d["total"] = totals[d["account"]]
return data
@@ -170,7 +177,6 @@ def set_total(node, value, complete_list, totals):
next(item for item in complete_list if item["account"] == parent), value, complete_list, totals
)
def get_profit(
gross_income, gross_expense, period_list, company, profit_type, currency=None, consolidated=False
):