feat: add Employee Status filter in leave balance reports

(cherry picked from commit ed8a49737a)
This commit is contained in:
Rucha Mahabal
2022-05-13 20:23:32 +05:30
committed by Mergify
parent 5b1d85e8bf
commit 716b5253a4
4 changed files with 26 additions and 9 deletions

View File

@@ -4,21 +4,21 @@
frappe.query_reports["Employee Leave Balance"] = { frappe.query_reports["Employee Leave Balance"] = {
"filters": [ "filters": [
{ {
"fieldname":"from_date", "fieldname": "from_date",
"label": __("From Date"), "label": __("From Date"),
"fieldtype": "Date", "fieldtype": "Date",
"reqd": 1, "reqd": 1,
"default": frappe.defaults.get_default("year_start_date") "default": frappe.defaults.get_default("year_start_date")
}, },
{ {
"fieldname":"to_date", "fieldname": "to_date",
"label": __("To Date"), "label": __("To Date"),
"fieldtype": "Date", "fieldtype": "Date",
"reqd": 1, "reqd": 1,
"default": frappe.defaults.get_default("year_end_date") "default": frappe.defaults.get_default("year_end_date")
}, },
{ {
"fieldname":"company", "fieldname": "company",
"label": __("Company"), "label": __("Company"),
"fieldtype": "Link", "fieldtype": "Link",
"options": "Company", "options": "Company",
@@ -26,16 +26,23 @@ frappe.query_reports["Employee Leave Balance"] = {
"default": frappe.defaults.get_user_default("Company") "default": frappe.defaults.get_user_default("Company")
}, },
{ {
"fieldname":"department", "fieldname": "department",
"label": __("Department"), "label": __("Department"),
"fieldtype": "Link", "fieldtype": "Link",
"options": "Department", "options": "Department",
}, },
{ {
"fieldname":"employee", "fieldname": "employee",
"label": __("Employee"), "label": __("Employee"),
"fieldtype": "Link", "fieldtype": "Link",
"options": "Employee", "options": "Employee",
},
{
"fieldname": "employee_status",
"label": __("Employee Status"),
"fieldtype": "Select",
"options": ["", "Active", "Inactive", "Suspended", "Left"],
"default": "Active",
} }
], ],

View File

@@ -168,9 +168,8 @@ def get_opening_balance(
def get_conditions(filters: Filters) -> Dict: def get_conditions(filters: Filters) -> Dict:
conditions = { conditions = {}
"status": "Active",
}
if filters.get("employee"): if filters.get("employee"):
conditions["name"] = filters.get("employee") conditions["name"] = filters.get("employee")
@@ -180,6 +179,9 @@ def get_conditions(filters: Filters) -> Dict:
if filters.get("department"): if filters.get("department"):
conditions["department"] = filters.get("department") conditions["department"] = filters.get("department")
if filters.get("employee_status"):
conditions["status"] = filters.get("employee_status")
return conditions return conditions

View File

@@ -30,6 +30,13 @@ frappe.query_reports['Employee Leave Balance Summary'] = {
label: __('Department'), label: __('Department'),
fieldtype: 'Link', fieldtype: 'Link',
options: 'Department', options: 'Department',
},
{
fieldname: "employee_status",
label: __("Employee Status"),
fieldtype: "Select",
options: ["", "Active", "Inactive", "Suspended", "Left"],
default: "Active",
} }
] ]
}; };

View File

@@ -35,9 +35,10 @@ def get_columns(leave_types):
def get_conditions(filters): def get_conditions(filters):
conditions = { conditions = {
"status": "Active",
"company": filters.company, "company": filters.company,
} }
if filters.get("employee_status"):
conditions.update({"status": filters.get("employee_status")})
if filters.get("department"): if filters.get("department"):
conditions.update({"department": filters.get("department")}) conditions.update({"department": filters.get("department")})
if filters.get("employee"): if filters.get("employee"):