Hi All,
I need “from date” which 01 Jan of the year and “to date” is today’s date in Employee Leave balance report it should autofill need not to show error message below
Thanks in Advance
Hi All,
I need “from date” which 01 Jan of the year and “to date” is today’s date in Employee Leave balance report it should autofill need not to show error message below
First, create one record in Leave Period doctype. By default it will set From Date as year start date and to_date as year_end_date.If you want to_date as current date then use this script.
Path:
/workspace/development/frappe-bench/apps/hrms/hrms/hr/report/employee_leave_balance/employee_leave_balance.js
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.query_reports["Employee Leave Balance"] = {
filters: [
{
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.defaults.get_default("year_start_date")
},
{
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
reqd: 1,
default: frappe.defaults.get_default("year_end_date")
},
{
label: __("Company"),
fieldname: "company",
fieldtype: "Link",
options: "Company",
reqd: 1,
default: frappe.defaults.get_user_default("Company")
},
{
fieldname: "department",
label: __("Department"),
fieldtype: "Link",
options: "Department",
},
{
fieldname: "employee",
label: __("Employee"),
fieldtype: "Link",
options: "Employee",
},
{
fieldname: "employee_status",
label: __("Employee Status"),
fieldtype: "Select",
options: [
"",
{ "value": "Active", "label": __("Active") },
{ "value": "Inactive", "label": __("Inactive") },
{ "value": "Suspended", "label": __("Suspended") },
{ "value": "Left", "label": __("Left") },
],
default: "Active",
},
{
fieldname: "consolidate_leave_types",
label: __("Consolidate Leave Types"),
fieldtype: "Check",
default: 1,
depends_on: "eval: !doc.employee",
}
],
onload: () => {
const today = frappe.datetime.now_date();
frappe.call({
type: "GET",
method: "hrms.hr.utils.get_leave_period",
args: {
"from_date": today,
"to_date": today,
"company": frappe.defaults.get_user_default("Company")
},
freeze: true,
callback: (data) => {
frappe.query_report.set_filter_value("from_date", data.message[0].from_date);
frappe.query_report.set_filter_value("to_date", today);
}
});
}
}
in clientscript list which doctype to use for this client script and save? im new to Erpnext
Thanks in Advance