Added Holiday List filter
diff --git a/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.js b/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.js
index d9d4c8c..1345433 100644
--- a/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.js
+++ b/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.js
@@ -16,6 +16,12 @@
"fieldtype": "Date",
"reqd": 1,
"default": frappe.datetime.year_end()
+ },
+ {
+ "fieldname":"holiday_list",
+ "label": __("Holiday List"),
+ "fieldtype": "Link",
+ "options": "Holiday List"
}
]
}
diff --git a/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.py b/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.py
index f25fa03..a0b78a6 100644
--- a/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.py
+++ b/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.py
@@ -24,25 +24,34 @@
_("Holiday") + ":Data:200"
]
-
def get_employees(filters):
+ holiday_filter = {"holiday_date": (">=", filters.from_date),
+ "holiday_date": ("<=", filters.to_date)}
+ if filters.holiday_list:
+ holiday_filter["parent"] = filters.holiday_list
+
holidays = frappe.get_all("Holiday", fields=["holiday_date", "description"],
- filters=[["holiday_date", ">=",
- filters.from_date],
- ["holiday_date", "<=", filters.to_date]])
+ filters=holiday_filter)
+
holiday_names = {}
holidays_list = []
for holiday in holidays:
holidays_list.append(holiday.holiday_date)
holiday_names[holiday.holiday_date] = holiday.description
+
if(holidays_list):
+ cond = " att_date in %(holidays_list)s"
+
+ if filters.holiday_list:
+ cond += """ and (employee in (select employee from tabEmployee where holiday_list = %(holidays)s))"""
+
employee_list = frappe.db.sql("""select
employee, employee_name, att_date, status
from tabAttendance
- where
- att_date in ({0})""".format(', '.join(["%s"] * len(holidays_list))),
- holidays_list, as_list=True)
+ where %s"""% cond.format(', '.join(["%s"] * len(holidays_list))),
+ {'holidays_list':holidays_list,
+ 'holidays':filters.holiday_list}, as_list=True)
for employee_data in employee_list:
employee_data.append(holiday_names[employee_data[2]])