test: employee status filter in leave balance reports
diff --git a/erpnext/hr/report/employee_leave_balance/test_employee_leave_balance.py b/erpnext/hr/report/employee_leave_balance/test_employee_leave_balance.py
index dc0f4d2..5354abf 100644
--- a/erpnext/hr/report/employee_leave_balance/test_employee_leave_balance.py
+++ b/erpnext/hr/report/employee_leave_balance/test_employee_leave_balance.py
@@ -207,3 +207,40 @@
allocation1.new_leaves_allocated - leave_application.total_leave_days
)
self.assertEqual(report[1][0].opening_balance, opening_balance)
+
+ @set_holiday_list("_Test Emp Balance Holiday List", "_Test Company")
+ def test_employee_status_filter(self):
+ frappe.get_doc(test_records[0]).insert()
+ inactive_emp = make_employee("test_emp_status@example.com", company="_Test Company")
+
+ allocation = make_allocation_record(
+ employee=inactive_emp,
+ from_date=self.year_start,
+ to_date=self.year_end,
+ leaves=5,
+ )
+
+ # set employee as inactive
+ frappe.db.set_value("Employee", inactive_emp, "status", "Inactive")
+
+ filters = frappe._dict(
+ {
+ "from_date": allocation.from_date,
+ "to_date": allocation.to_date,
+ "employee": inactive_emp,
+ "employee_status": "Active",
+ }
+ )
+ report = execute(filters)
+ self.assertEqual(len(report[1]), 0)
+
+ filters = frappe._dict(
+ {
+ "from_date": allocation.from_date,
+ "to_date": allocation.to_date,
+ "employee": inactive_emp,
+ "employee_status": "Inactive",
+ }
+ )
+ report = execute(filters)
+ self.assertEqual(len(report[1]), 1)
diff --git a/erpnext/hr/report/employee_leave_balance_summary/test_employee_leave_balance_summary.py b/erpnext/hr/report/employee_leave_balance_summary/test_employee_leave_balance_summary.py
index 34b665f..2fd74b7 100644
--- a/erpnext/hr/report/employee_leave_balance_summary/test_employee_leave_balance_summary.py
+++ b/erpnext/hr/report/employee_leave_balance_summary/test_employee_leave_balance_summary.py
@@ -37,7 +37,6 @@
frappe.set_user("Administrator")
self.employee_id = make_employee("test_emp_leave_balance@example.com", company="_Test Company")
- self.employee_id = make_employee("test_emp_leave_balance@example.com", company="_Test Company")
self.date = getdate()
self.year_start = getdate(get_year_start(self.date))
@@ -146,3 +145,37 @@
]
self.assertEqual(report[1], expected_data)
+
+ @set_holiday_list("_Test Emp Balance Holiday List", "_Test Company")
+ def test_employee_status_filter(self):
+ frappe.get_doc(test_records[0]).insert()
+
+ inactive_emp = make_employee("test_emp_status@example.com", company="_Test Company")
+ allocation = make_allocation_record(
+ employee=inactive_emp, from_date=self.year_start, to_date=self.year_end
+ )
+
+ # set employee as inactive
+ frappe.db.set_value("Employee", inactive_emp, "status", "Inactive")
+
+ filters = frappe._dict(
+ {
+ "date": allocation.from_date,
+ "company": "_Test Company",
+ "employee": inactive_emp,
+ "employee_status": "Active",
+ }
+ )
+ report = execute(filters)
+ self.assertEqual(len(report[1]), 0)
+
+ filters = frappe._dict(
+ {
+ "date": allocation.from_date,
+ "company": "_Test Company",
+ "employee": inactive_emp,
+ "employee_status": "Inactive",
+ }
+ )
+ report = execute(filters)
+ self.assertEqual(len(report[1]), 1)