mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
Balance Sheet always shows accumulated values from previous fiscal year (#8668)
This commit is contained in:
@@ -7,7 +7,8 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
|||||||
frappe.query_reports["Balance Sheet"]["filters"].push({
|
frappe.query_reports["Balance Sheet"]["filters"].push({
|
||||||
"fieldname": "accumulated_values",
|
"fieldname": "accumulated_values",
|
||||||
"label": __("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):
|
def execute(filters=None):
|
||||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
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,
|
asset = get_data(filters.company, "Asset", "Debit", period_list,
|
||||||
only_current_fiscal_year=False, filters=filters,
|
only_current_fiscal_year=False, filters=filters,
|
||||||
accumulated_values=filters.accumulated_values,
|
accumulated_values=filters.accumulated_values)
|
||||||
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
|
|
||||||
|
|
||||||
liability = get_data(filters.company, "Liability", "Credit", period_list,
|
liability = get_data(filters.company, "Liability", "Credit", period_list,
|
||||||
only_current_fiscal_year=False, filters=filters,
|
only_current_fiscal_year=False, filters=filters,
|
||||||
accumulated_values=filters.accumulated_values,
|
accumulated_values=filters.accumulated_values)
|
||||||
ignore_closing_entries=True, ignore_accumulated_values_for_fy=True)
|
|
||||||
|
|
||||||
equity = get_data(filters.company, "Equity", "Credit", period_list,
|
equity = get_data(filters.company, "Equity", "Credit", period_list,
|
||||||
only_current_fiscal_year=False, filters=filters,
|
only_current_fiscal_year=False, filters=filters,
|
||||||
accumulated_values=filters.accumulated_values,
|
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,
|
provisional_profit_loss, total_credit = get_provisional_profit_loss(asset, liability, equity,
|
||||||
period_list, filters.company)
|
period_list, filters.company)
|
||||||
@@ -115,6 +112,7 @@ def check_opening_balance(asset, liability, equity):
|
|||||||
if equity:
|
if equity:
|
||||||
opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)
|
opening_balance -= flt(equity[0].get("opening_balance", 0), float_precision)
|
||||||
|
|
||||||
|
opening_balance = flt(opening_balance, float_precision)
|
||||||
if opening_balance:
|
if opening_balance:
|
||||||
return _("Previous Financial Year is not closed"),opening_balance
|
return _("Previous Financial Year is not closed"),opening_balance
|
||||||
return None,None
|
return None,None
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
|
from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
|
||||||
add_months, add_days, formatdate, cint)
|
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}
|
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
|
||||||
Periodicity can be (Yearly, Quarterly, Monthly)"""
|
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
|
# if a fiscal year ends before a 12 month period
|
||||||
period.to_date = year_end_date
|
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)
|
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:
|
if not accumulated_values:
|
||||||
label = get_label(periodicity, opts["from_date"], opts["to_date"])
|
label = get_label(periodicity, opts["from_date"], opts["to_date"])
|
||||||
else:
|
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({
|
opts.update({
|
||||||
"key": key.replace(" ", "_").replace("-", "_"),
|
"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:
|
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)
|
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):
|
def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
|
||||||
"""accumulate children's values in parent accounts"""
|
"""accumulate children's values in parent accounts"""
|
||||||
for d in reversed(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
|
# imported to enable erpnext.accounts.utils.get_account_currency
|
||||||
from erpnext.accounts.doctype.account.account import 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
|
class FiscalYearError(frappe.ValidationError): pass
|
||||||
|
|
||||||
@@ -652,6 +651,8 @@ def get_companies():
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children():
|
def get_children():
|
||||||
|
from erpnext.accounts.report.financial_statements import sort_root_accounts
|
||||||
|
|
||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
doctype, company = args['doctype'], args['company']
|
doctype, company = args['doctype'], args['company']
|
||||||
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
|
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
|
||||||
|
|||||||
Reference in New Issue
Block a user