Line/Bar chart in Balance Sheet / Profit and Loss statement
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py
index 1f60f8f..6d115c8 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.py
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py
@@ -27,8 +27,10 @@
data.append(provisional_profit_loss)
columns = get_columns(filters.periodicity, period_list, company=filters.company)
+
+ graph_data = get_graph_data(columns, asset, liability, equity)
- return columns, data, message
+ return columns, data, message, graph_data
def get_provisional_profit_loss(asset, liability, equity, period_list, company):
if asset and (liability or equity):
@@ -69,4 +71,21 @@
opening_balance -= flt(asset[0].get("opening_balance", 0))
if opening_balance:
- return _("Previous Financial Year is not closed")
\ No newline at end of file
+ return _("Previous Financial Year is not closed")
+
+def get_graph_data(columns, asset, liability, equity):
+ x_intervals = ['x'] + [d.get("label") for d in columns[2:]]
+
+ asset_data, liability_data, equity_data = ["Assets"], ["Liabilities"], ["Equity"]
+
+ for p in columns[2:]:
+ asset_data.append(asset[-2].get(p.get("fieldname")))
+ liability_data.append(liability[-2].get(p.get("fieldname")))
+ equity_data.append(equity[-2].get(p.get("fieldname")))
+
+ return {
+ "data": {
+ 'x': 'x',
+ 'columns': [x_intervals, asset_data, liability_data, equity_data]
+ }
+ }
\ No newline at end of file
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 1a59a9d..c930952 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -112,7 +112,7 @@
out = filter_out_zero_value_rows(out, parent_children_map)
if out:
- add_total_row(out, balance_must_be, period_list, company_currency)
+ add_total_row(out, root_type, balance_must_be, period_list, company_currency)
return out
@@ -193,9 +193,9 @@
return data_with_value
-def add_total_row(out, balance_must_be, period_list, company_currency):
+def add_total_row(out, root_type, balance_must_be, period_list, company_currency):
total_row = {
- "account_name": "'" + _("Total ({0})").format(balance_must_be) + "'",
+ "account_name": "'" + _("Total {0} ({1})").format(root_type, balance_must_be) + "'",
"account": None,
"currency": company_currency
}
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
index 7c33db2..c1b0120 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
@@ -24,8 +24,10 @@
data.append(net_profit_loss)
columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company)
+
+ graph_data = get_graph_data(filters, columns, income, expense, net_profit_loss)
- return columns, data
+ return columns, data, None, graph_data
def get_net_profit_loss(income, expense, period_list, company):
if income and expense:
@@ -50,3 +52,25 @@
if has_value:
return net_profit_loss
+
+def get_graph_data(filters, columns, income, expense, net_profit_loss):
+ x_intervals = ['x'] + [d.get("label") for d in columns[2:-1]]
+
+ income_data, expense_data, net_profit = ["Income"], ["Expense"], ["Net Profit/Loss"]
+
+ for p in columns[2:]:
+ income_data.append(income[-2].get(p.get("fieldname")))
+ expense_data.append(expense[-2].get(p.get("fieldname")))
+ net_profit.append(net_profit_loss.get(p.get("fieldname")))
+
+ graph_data = {
+ "data": {
+ 'x': 'x',
+ 'columns': [x_intervals, income_data, expense_data, net_profit]
+ }
+ }
+
+ if not filters.accumulated_values:
+ graph_data["data"]["type"] = "bar"
+
+ return graph_data
\ No newline at end of file
diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js
index 3c87dab..c1e53a2 100644
--- a/erpnext/public/js/financial_statements.js
+++ b/erpnext/public/js/financial_statements.js
@@ -28,7 +28,7 @@
{ "value": "Half-Yearly", "label": __("Half-Yearly") },
{ "value": "Yearly", "label": __("Yearly") }
],
- "default": "Yearly",
+ "default": "Monthly",
"reqd": 1
}
],
@@ -83,5 +83,5 @@
var filters = report.get_values();
frappe.set_route('query-report', 'Cash Flow', {company: filters.company});
}, 'Financial Statements');
- },
+ }
};