Merge pull request #38117 from frappe/mergify/bp/version-15-hotfix/pr-38082
refactor: use 'boolean' parameter while fetching FY year (backport #38082)
This commit is contained in:
commit
00a62692dc
@ -53,6 +53,9 @@ GL_REPOSTING_CHUNK = 100
|
|||||||
def get_fiscal_year(
|
def get_fiscal_year(
|
||||||
date=None, fiscal_year=None, label="Date", verbose=1, company=None, as_dict=False, boolean=False
|
date=None, fiscal_year=None, label="Date", verbose=1, company=None, as_dict=False, boolean=False
|
||||||
):
|
):
|
||||||
|
if isinstance(boolean, str):
|
||||||
|
boolean = frappe.json.loads(boolean)
|
||||||
|
|
||||||
fiscal_years = get_fiscal_years(
|
fiscal_years = get_fiscal_years(
|
||||||
date, fiscal_year, label, verbose, company, as_dict=as_dict, boolean=boolean
|
date, fiscal_year, label, verbose, company, as_dict=as_dict, boolean=boolean
|
||||||
)
|
)
|
||||||
|
|||||||
@ -139,7 +139,6 @@ function get_filters() {
|
|||||||
"label": __("Start Year"),
|
"label": __("Start Year"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Fiscal Year",
|
"options": "Fiscal Year",
|
||||||
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
|
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"depends_on": "eval:doc.filter_based_on == 'Fiscal Year'"
|
"depends_on": "eval:doc.filter_based_on == 'Fiscal Year'"
|
||||||
},
|
},
|
||||||
@ -148,7 +147,6 @@ function get_filters() {
|
|||||||
"label": __("End Year"),
|
"label": __("End Year"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Fiscal Year",
|
"options": "Fiscal Year",
|
||||||
"default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
|
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"depends_on": "eval:doc.filter_based_on == 'Fiscal Year'"
|
"depends_on": "eval:doc.filter_based_on == 'Fiscal Year'"
|
||||||
},
|
},
|
||||||
@ -197,5 +195,13 @@ function get_filters() {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// Dynamically set 'default' values for fiscal year filters
|
||||||
|
let fy_filters = filters.filter(x=>{return ["from_fiscal_year", "to_fiscal_year"].includes(x.fieldname);})
|
||||||
|
let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), false, true);
|
||||||
|
if (fiscal_year) {
|
||||||
|
let fy = erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), false, false);
|
||||||
|
fy_filters.forEach(x=>{x.default = fy;})
|
||||||
|
}
|
||||||
|
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -404,7 +404,7 @@ $.extend(erpnext.utils, {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
get_fiscal_year: function(date, with_dates=false) {
|
get_fiscal_year: function(date, with_dates=false, boolean=false) {
|
||||||
if(!date) {
|
if(!date) {
|
||||||
date = frappe.datetime.get_today();
|
date = frappe.datetime.get_today();
|
||||||
}
|
}
|
||||||
@ -413,7 +413,8 @@ $.extend(erpnext.utils, {
|
|||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.accounts.utils.get_fiscal_year",
|
method: "erpnext.accounts.utils.get_fiscal_year",
|
||||||
args: {
|
args: {
|
||||||
date: date
|
date: date,
|
||||||
|
boolean: boolean
|
||||||
},
|
},
|
||||||
async: false,
|
async: false,
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user