From 033e2fa8b60ca90e8bea666a903cef391fec1e91 Mon Sep 17 00:00:00 2001 From: Ricardo Johann Date: Fri, 31 Mar 2017 02:18:54 -0300 Subject: [PATCH] changed accumulated header --- .../report/balance_sheet/balance_sheet.js | 6 +++++ .../report/balance_sheet/balance_sheet.py | 24 ++++++++++++------- .../accounts/report/cash_flow/cash_flow.py | 5 ++-- .../accounts/report/financial_statements.py | 14 +++++++---- .../profit_and_loss_statement.py | 2 +- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js index a20d47c784..9cd92d4367 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 4325afcd29..d5d7a1b88d 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py @@ -8,11 +8,14 @@ from frappe.utils import flt, cint 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 @@ def execute(filters=None): 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 @@ def check_opening_balance(asset, liability, equity): 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 @@ def get_chart_data(columns, asset, liability, equity): 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 d2c8c3e5f1..be530d8a65 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.py +++ b/erpnext/accounts/report/cash_flow/cash_flow.py @@ -10,8 +10,7 @@ from erpnext.accounts.utils import get_fiscal_year 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 @@ def get_account_type_based_data(company, account_type, period_list, accumulated_ 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 80b0bf2558..1fc26ac07f 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 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, company): # 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 02dc870035..73a4831189 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 @@ from erpnext.accounts.report.financial_statements import (get_period_list, get_c 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)