Merge branch 'accumulated_header_std' of https://github.com/RicardoJohann/erpnext into RicardoJohann-accumulated_header_std
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js
index a20d47c..9cd92d4 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.js
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js
@@ -3,6 +3,12 @@
frappe.require("assets/erpnext/js/financial_statements.js", function() {
frappe.query_reports["Balance Sheet"] = erpnext.financial_statements;
+
+ frappe.query_reports["Balance Sheet"]["filters"].push({
+ "fieldname": "accumulated_values",
+ "label": __("Accumulated Values"),
+ "fieldtype": "Check"
+ });
});
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py
index 4325afc..d5d7a1b 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.py
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py
@@ -8,11 +8,14 @@
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
def execute(filters=None):
- period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company)
+ period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.accumulated_values)
- asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False)
- liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False)
- equity = get_data(filters.company, "Equity", "Credit", period_list, only_current_fiscal_year=False)
+ asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False, filters=filters,
+ accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
+ liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False, filters=filters,
+ accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
+ equity = get_data(filters.company, "Equity", "Credit", period_list, only_current_fiscal_year=False, filters=filters,
+ accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
period_list, filters.company)
@@ -43,9 +46,9 @@
if total_credit:
data.append(total_credit)
- columns = get_columns(filters.periodicity, period_list, company=filters.company)
+ columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, company=filters.company)
- chart = get_chart_data(columns, asset, liability, equity)
+ chart = get_chart_data(filters, columns, asset, liability, equity)
return columns, data, message, chart
@@ -107,7 +110,7 @@
return _("Previous Financial Year is not closed"),opening_balance
return None,None
-def get_chart_data(columns, asset, liability, equity):
+def get_chart_data(filters, columns, asset, liability, equity):
x_intervals = ['x'] + [d.get("label") for d in columns[2:]]
asset_data, liability_data, equity_data = [], [], []
@@ -128,9 +131,14 @@
if equity_data:
columns.append(["Equity"] + equity_data)
- return {
+ chart = {
"data": {
'x': 'x',
'columns': columns
}
}
+
+ if not filters.accumulated_values:
+ chart["chart_type"] = "bar"
+
+ return chart
\ No newline at end of file
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py
index d2c8c3e..be530d8 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/cash_flow.py
@@ -10,8 +10,7 @@
def execute(filters=None):
- period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
- filters.periodicity, filters.company)
+ period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.accumulated_values)
operation_accounts = {
"section_name": "Operations",
@@ -104,7 +103,7 @@
data = {}
total = 0
for period in period_list:
- start_date = get_start_date(period, accumulated_values, company)
+ start_date = get_start_date(period, accumulated_values)
gl_sum = frappe.db.sql_list("""
select sum(credit) - sum(debit)
from `tabGL Entry`
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 80b0bf2..1fc26ac 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -4,9 +4,10 @@
from __future__ import unicode_literals
import frappe
from frappe import _
-from frappe.utils import flt, getdate, get_first_day, add_months, add_days, formatdate
+from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
+ add_months, add_days, formatdate, cint)
-def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, company):
+def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False, company=None):
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
Periodicity can be (Yearly, Quarterly, Monthly)"""
@@ -58,11 +59,14 @@
# common processing
for opts in period_list:
key = opts["to_date"].strftime("%b_%Y").lower()
- if periodicity == "Monthly":
+ if periodicity == "Monthly" and not accumulated_values:
label = formatdate(opts["to_date"], "MMM YYYY")
else:
- label = get_label(periodicity, opts["from_date"], opts["to_date"])
-
+ if not accumulated_values:
+ label = get_label(periodicity, opts["from_date"], opts["to_date"])
+ else:
+ label = get_label(periodicity, period_list[0]["from_date"], opts["to_date"])
+
opts.update({
"key": key.replace(" ", "_").replace("-", "_"),
"label": label,
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 02dc870..73a4831 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
@@ -9,7 +9,7 @@
def execute(filters=None):
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
- filters.periodicity, filters.company)
+ filters.periodicity, filters.accumulated_values, filters.company)
income = get_data(filters.company, "Income", "Credit", period_list, filters = filters,
accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)