feat: added chart to cash-flow report
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py
index 75d99e7..626d185 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/cash_flow.py
@@ -69,7 +69,9 @@
add_total_row_account(data, data, _("Net Change in Cash"), period_list, company_currency)
columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company)
- return columns, data
+ chart = get_chart_data(columns, data)
+
+ return columns, data, None, chart
def get_cash_flow_accounts():
operation_accounts = {
@@ -171,4 +173,19 @@
total_row["total"] += row["total"]
out.append(total_row)
- out.append({})
\ No newline at end of file
+ out.append({})
+
+def get_chart_data(columns, data):
+ labels = [d.get("label") for d in columns[2:]]
+ datasets = [{'name':account.get('account').replace("'", ""), 'values': [account.get('total')]} for account in data if account.get('parent_account') == None and account.get('currency')]
+ datasets = datasets[:-1]
+
+ chart = {
+ "data": {
+ 'labels': labels,
+ 'datasets': datasets
+ },
+ "type": "bar"
+ }
+
+ return chart
\ No newline at end of file