From da3f07221cc0e685fa6b5ef3a9472753f876f256 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 8 Apr 2019 19:38:55 +0530 Subject: [PATCH] fix(dashboard): accounting timeline query fix --- .../account_balance_timeline/account_balance_timeline.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 101e30892ae..8375aa33ff9 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 @@ -48,7 +48,7 @@ def build_result(account, dates, gl_entries): # get balances in debit for entry in gl_entries: - # find the date index after the posting date + # entry date is after the current pointer, so move the pointer forward while getdate(entry.posting_date) > result[date_index][0]: date_index += 1 @@ -63,13 +63,15 @@ def build_result(account, dates, gl_entries): def get_gl_entries(account, to_date): child_accounts = get_descendants_of('Account', account, ignore_permissions=True) + child_accounts.append(account) return frappe.db.get_all('GL Entry', fields = ['posting_date', 'debit', 'credit'], filters = [ dict(posting_date = ('<', to_date)), dict(account = ('in', child_accounts)) - ]) + ], + order_by = 'posting_date asc') def get_from_date_from_timespan(timespan): days = months = years = 0