From cc56ff5c37664834d6769a1b22e2b669a12e0f5d Mon Sep 17 00:00:00 2001 From: Yaqin Shurrab Date: Fri, 27 Jul 2018 08:43:00 +0300 Subject: [PATCH] Get the correct Summation of Closing Balances (#14990) Fix total raw values for Closing Credit and Closing Debit --- erpnext/accounts/report/trial_balance/trial_balance.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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