From d5d8db7a3f339445159f333d1d157d39d21252a6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 25 Apr 2017 16:26:33 +0530 Subject: [PATCH] Cleanup on financial statement PR --- .../report/balance_sheet/balance_sheet.py | 23 +++++++++++++------ .../accounts/report/cash_flow/cash_flow.py | 5 ++-- .../accounts/report/financial_statements.py | 3 ++- .../profit_and_loss_statement.py | 7 ++++-- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py index d5d7a1b88d..9095d8619b 100644 --- a/erpnext/accounts/report/balance_sheet/balance_sheet.py +++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py @@ -8,14 +8,23 @@ 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.accumulated_values) + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, + filters.periodicity, filters.accumulated_values, filters.company) - 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) + 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) diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py index be530d8a65..f55d192731 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.py +++ b/erpnext/accounts/report/cash_flow/cash_flow.py @@ -10,7 +10,8 @@ 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.accumulated_values) + period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, + filters.periodicity, filters.accumulated_values, filters.company) operation_accounts = { "section_name": "Operations", @@ -103,7 +104,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) + start_date = get_start_date(period, accumulated_values, company) 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 1fc26ac07f..9ba7711f0b 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -143,7 +143,8 @@ def calculate_values(accounts_by_name, gl_entries_by_account, period_list, accum if entry.posting_date <= period.to_date: if (accumulated_values or entry.posting_date >= period.from_date) and \ - (not ignore_accumulated_values_for_fy or entry.fiscal_year == period.to_date_fiscal_year): + (not ignore_accumulated_values_for_fy or + entry.fiscal_year == period.to_date_fiscal_year): d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit) if entry.posting_date < period_list[0].year_start_date: 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 73a4831189..95085b957a 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 @@ -12,9 +12,12 @@ def execute(filters=None): 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) + accumulated_values=filters.accumulated_values, + ignore_closing_entries=True, ignore_accumulated_values_for_fy= True) + expense = get_data(filters.company, "Expense", "Debit", period_list, filters=filters, - accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True) + accumulated_values=filters.accumulated_values, + ignore_closing_entries=True, ignore_accumulated_values_for_fy= True) net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company)