fix(financial reports): set fiscal year associated with the default company

This commit is contained in:
ravibharathi656
2025-11-14 16:46:10 +05:30
parent 9b06eaab78
commit ac40b59665
2 changed files with 34 additions and 15 deletions

View File

@@ -420,25 +420,36 @@ $.extend(erpnext.utils, {
if (!frappe.boot.setup_complete) {
return;
}
const today = frappe.datetime.get_today();
if (!date) {
date = frappe.datetime.get_today();
date = today;
}
let fiscal_year = "";
frappe.call({
method: "erpnext.accounts.utils.get_fiscal_year",
args: {
date: date,
boolean: boolean,
},
async: false,
callback: function (r) {
if (r.message) {
if (with_dates) fiscal_year = r.message;
else fiscal_year = r.message[0];
}
},
});
if (
frappe.boot.current_fiscal_year &&
date >= frappe.boot.current_fiscal_year[1] &&
date <= frappe.boot.current_fiscal_year[2]
) {
if (with_dates) fiscal_year = frappe.boot.current_fiscal_year;
else fiscal_year = frappe.boot.current_fiscal_year[0];
} else if (today != date) {
frappe.call({
method: "erpnext.accounts.utils.get_fiscal_year",
type: "GET", // make it cacheable
args: {
date: date,
boolean: boolean,
},
async: false,
callback: function (r) {
if (r.message) {
if (with_dates) fiscal_year = r.message;
else fiscal_year = r.message[0];
}
},
});
}
return fiscal_year;
},

View File

@@ -3,8 +3,11 @@
import frappe
from frappe.defaults import get_user_default
from frappe.utils import cint
from erpnext.accounts.utils import get_fiscal_years
def boot_session(bootinfo):
"""boot session - send website info if guest"""
@@ -53,6 +56,11 @@ def boot_session(bootinfo):
)
party_account_types = frappe.db.sql(""" select name, ifnull(account_type, '') from `tabParty Type`""")
fiscal_year = get_fiscal_years(
frappe.utils.nowdate(), company=get_user_default("company"), boolean=True
)
if fiscal_year:
bootinfo.current_fiscal_year = fiscal_year[0]
bootinfo.party_account_types = frappe._dict(party_account_types)
bootinfo.sysdefaults.demo_company = frappe.db.get_single_value("Global Defaults", "demo_company")