Skip to content

Commit

Permalink
fix: account group totals calculation to consider include_in_gross
Browse files Browse the repository at this point in the history
(cherry picked from commit 8dcb930)
  • Loading branch information
akurungadam authored and mergify[bot] committed Jun 19, 2023
1 parent 3d0add8 commit f22969d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
):
Expand Down

0 comments on commit f22969d

Please sign in to comment.