diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index 5df2a6505a..93ffe0279f 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -162,8 +162,6 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances, filters, total_row["credit"] += d["credit"] total_row["opening_debit"] += d["opening_debit"] total_row["opening_credit"] += d["opening_credit"] - total_row["closing_debit"] += (d["opening_debit"] + d["debit"]) - total_row["closing_credit"] += (d["opening_credit"] + d["credit"]) return total_row @@ -176,6 +174,8 @@ def accumulate_values_into_parents(accounts, accounts_by_name): def prepare_data(accounts, filters, total_row, parent_children_map, company_currency): data = [] + total_row["closing_debit"] = total_row["closing_credit"] = 0 + for d in accounts: has_value = False row = { @@ -200,6 +200,10 @@ def prepare_data(accounts, filters, total_row, parent_children_map, company_curr row["has_value"] = has_value data.append(row) + if not d.parent_account: + total_row["closing_debit"] += (d["debit"] - d["credit"]) if (d["debit"] - d["credit"]) > 0 else 0 + total_row["closing_credit"] += abs(d["debit"] - d["credit"]) if (d["debit"] - d["credit"]) < 0 else 0 + data.extend([{},total_row]) return data