fix(dashboard): Consider opening balance
diff --git a/erpnext/accounts/dashboard.py b/erpnext/accounts/dashboard.py
index b9cb22e..b6ac4de 100644
--- a/erpnext/accounts/dashboard.py
+++ b/erpnext/accounts/dashboard.py
@@ -32,6 +32,8 @@
for row in report_results[1:-2]:
_results.append([row[key] for key in interesting_fields])
+ _results = add_opening_balance(from_date, _results, report_results[0])
+
grouped_results = groupby(_results, key=itemgetter(0))
results = [list(values)[-1] for key, values in grouped_results]
@@ -61,6 +63,12 @@
return add_to_date(None, years=years, months=months, days=days,
as_string=True, as_datetime=True)
+
+def add_opening_balance(from_date, _results, opening):
+ if not _results or (_results[0][0] != getdate(from_date)):
+ _results.insert(0, [from_date, opening.balance])
+ return _results
+
def add_missing_dates(incomplete_results, from_date, to_date):
dates = [r[0] for r in incomplete_results]
day_count = date_diff(to_date, from_date)