fix: hot path in page load
This commit is contained in:
@@ -420,7 +420,7 @@ $.extend(erpnext.utils, {
|
||||
});
|
||||
},
|
||||
|
||||
get_fiscal_year: function (date, with_dates = false, boolean = false) {
|
||||
get_fiscal_year: function (date, with_dates = false, raise_on_missing = true) {
|
||||
if (!frappe.boot.setup_complete) {
|
||||
return;
|
||||
}
|
||||
@@ -429,20 +429,30 @@ $.extend(erpnext.utils, {
|
||||
}
|
||||
|
||||
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 {
|
||||
frappe.call({
|
||||
method: "erpnext.accounts.utils.get_fiscal_year",
|
||||
type: "GET", // make it cacheable
|
||||
args: {
|
||||
date: date,
|
||||
raise_on_missing: raise_on_missing,
|
||||
},
|
||||
async: false,
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
if (with_dates) fiscal_year = r.message;
|
||||
else fiscal_year = r.message[0];
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
return fiscal_year;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user