Balance Sheet always shows accumulated values from previous fiscal year (#8668)
This commit is contained in:
parent
1c09a991f3
commit
932423ecba
@ -7,7 +7,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
frappe.query_reports["Balance Sheet"]["filters"].push({
|
||||
"fieldname": "accumulated_values",
|
||||
"label": __("Accumulated Values"),
|
||||
"fieldtype": "Check"
|
||||
"fieldtype": "Check",
|
||||
"default": 1
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -9,22 +9,19 @@ 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.accumulated_values, filters.company)
|
||||
filters.periodicity, company=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)
|
||||
accumulated_values=filters.accumulated_values)
|
||||
|
||||
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)
|
||||
accumulated_values=filters.accumulated_values)
|
||||
|
||||
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)
|
||||
accumulated_values=filters.accumulated_values)
|
||||
|
||||
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
|
||||
period_list, filters.company)
|
||||
@ -114,7 +111,8 @@ def check_opening_balance(asset, liability, equity):
|
||||
opening_balance -= flt(liability[0].get("opening_balance", 0), float_precision)
|
||||
if equity:
|
||||
opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)
|
||||
|
||||
|
||||
opening_balance = flt(opening_balance, float_precision)
|
||||
if opening_balance:
|
||||
return _("Previous Financial Year is not closed"),opening_balance
|
||||
return None,None
|
||||
|
@ -6,8 +6,11 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
|
||||
add_months, add_days, formatdate, cint)
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
|
||||
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False, company=None):
|
||||
|
||||
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False,
|
||||
company=None, reset_period_on_fy_change=True):
|
||||
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
|
||||
Periodicity can be (Yearly, Quarterly, Monthly)"""
|
||||
|
||||
@ -49,7 +52,8 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_v
|
||||
# if a fiscal year ends before a 12 month period
|
||||
period.to_date = year_end_date
|
||||
|
||||
period.to_date_fiscal_year = get_date_fiscal_year(period.to_date, company)
|
||||
period.to_date_fiscal_year = get_fiscal_year(period.to_date, company=company)[0]
|
||||
period.from_date_fiscal_year_start_date = get_fiscal_year(period.from_date, company=company)[1]
|
||||
|
||||
period_list.append(period)
|
||||
|
||||
@ -65,7 +69,10 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_v
|
||||
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"])
|
||||
if reset_period_on_fy_change:
|
||||
label = get_label(periodicity, opts.from_date_fiscal_year_start_date, opts["to_date"])
|
||||
else:
|
||||
label = get_label(periodicity, period_list[0].from_date, opts["to_date"])
|
||||
|
||||
opts.update({
|
||||
"key": key.replace(" ", "_").replace("-", "_"),
|
||||
@ -150,10 +157,6 @@ def calculate_values(accounts_by_name, gl_entries_by_account, period_list, accum
|
||||
if entry.posting_date < period_list[0].year_start_date:
|
||||
d["opening_balance"] = d.get("opening_balance", 0.0) + flt(entry.debit) - flt(entry.credit)
|
||||
|
||||
def get_date_fiscal_year(date, company):
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
return get_fiscal_year(date, company=company)[0]
|
||||
|
||||
def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
|
||||
"""accumulate children's values in parent accounts"""
|
||||
for d in reversed(accounts):
|
||||
|
@ -11,7 +11,6 @@ from frappe.utils import formatdate, get_number_format_info
|
||||
|
||||
# imported to enable erpnext.accounts.utils.get_account_currency
|
||||
from erpnext.accounts.doctype.account.account import get_account_currency
|
||||
from erpnext.accounts.report.financial_statements import sort_root_accounts
|
||||
|
||||
class FiscalYearError(frappe.ValidationError): pass
|
||||
|
||||
@ -652,6 +651,8 @@ def get_companies():
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children():
|
||||
from erpnext.accounts.report.financial_statements import sort_root_accounts
|
||||
|
||||
args = frappe.local.form_dict
|
||||
doctype, company = args['doctype'], args['company']
|
||||
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user