mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 19:24:21 +00:00
fix(financial reports): set fiscal year associated with the default company
This commit is contained in:
@@ -420,25 +420,36 @@ $.extend(erpnext.utils, {
|
|||||||
if (!frappe.boot.setup_complete) {
|
if (!frappe.boot.setup_complete) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const today = frappe.datetime.get_today();
|
||||||
if (!date) {
|
if (!date) {
|
||||||
date = frappe.datetime.get_today();
|
date = today;
|
||||||
}
|
}
|
||||||
|
|
||||||
let fiscal_year = "";
|
let fiscal_year = "";
|
||||||
frappe.call({
|
if (
|
||||||
method: "erpnext.accounts.utils.get_fiscal_year",
|
frappe.boot.current_fiscal_year &&
|
||||||
args: {
|
date >= frappe.boot.current_fiscal_year[1] &&
|
||||||
date: date,
|
date <= frappe.boot.current_fiscal_year[2]
|
||||||
boolean: boolean,
|
) {
|
||||||
},
|
if (with_dates) fiscal_year = frappe.boot.current_fiscal_year;
|
||||||
async: false,
|
else fiscal_year = frappe.boot.current_fiscal_year[0];
|
||||||
callback: function (r) {
|
} else if (today != date) {
|
||||||
if (r.message) {
|
frappe.call({
|
||||||
if (with_dates) fiscal_year = r.message;
|
method: "erpnext.accounts.utils.get_fiscal_year",
|
||||||
else fiscal_year = r.message[0];
|
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;
|
return fiscal_year;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,11 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.defaults import get_user_default
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
|
from erpnext.accounts.utils import get_fiscal_years
|
||||||
|
|
||||||
|
|
||||||
def boot_session(bootinfo):
|
def boot_session(bootinfo):
|
||||||
"""boot session - send website info if guest"""
|
"""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`""")
|
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.party_account_types = frappe._dict(party_account_types)
|
||||||
|
|
||||||
bootinfo.sysdefaults.demo_company = frappe.db.get_single_value("Global Defaults", "demo_company")
|
bootinfo.sysdefaults.demo_company = frappe.db.get_single_value("Global Defaults", "demo_company")
|
||||||
|
|||||||
Reference in New Issue
Block a user