From 0d3986c9f67395264902fbe4181728f2f0701afc Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 9 Apr 2019 11:36:41 +0530 Subject: [PATCH] fix(dashboard): account timeline for balance sheet accounts --- .../account_balance_timeline/account_balance_timeline.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py index 8375aa33ff9..52c202386c8 100644 --- a/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py +++ b/erpnext/accounts/dashboard_chart_source/account_balance_timeline/account_balance_timeline.py @@ -41,6 +41,7 @@ def get(filters=None): def build_result(account, dates, gl_entries): result = [[getdate(date), 0.0] for date in dates] + root_type = frappe.db.get_value('Account', account, 'root_type') # start with the first date date_index = 0 @@ -55,10 +56,16 @@ def build_result(account, dates, gl_entries): result[date_index][1] += entry.debit - entry.credit # if account type is credit, switch balances - if frappe.db.get_value('Account', account, 'root_type') not in ('Asset', 'Expense'): + if root_type not in ('Asset', 'Expense'): for r in result: r[1] = -1 * r[1] + # for balance sheet accounts, the totals are cumulative + if root_type in ('Asset', 'Liability', 'Equity'): + for i, r in enumerate(result): + if i < 0: + r[1] = r[1] + result[i-1][1] + return result def get_gl_entries(account, to_date):