Merge pull request #4740 from vjFaLk/holiday-report-improvements
Added From and To date to Holiday Report
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 f1037ff..d9d4c8c 100644
--- a/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.js
+++ b/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.js
@@ -3,6 +3,19 @@
frappe.query_reports["Employee Holiday Attendance"] = {
"filters": [
-
+ {
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "reqd": 1,
+ "default": frappe.datetime.year_start()
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "reqd": 1,
+ "default": frappe.datetime.year_end()
+ }
]
}
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 bb68cf3..f25fa03 100644
--- a/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.py
+++ b/erpnext/hr/report/employee_holiday_attendance/employee_holiday_attendance.py
@@ -11,7 +11,7 @@
filters = {}
columns = get_columns()
- data = get_employees()
+ data = get_employees(filters)
return columns, data
@@ -19,14 +19,17 @@
return [
_("Employee") + ":Link/Employee:120",
_("Name") + ":Data:200",
- _("Date")+ ":Date:100",
+ _("Date") + ":Date:100",
_("Status") + ":Data:70",
_("Holiday") + ":Data:200"
]
-def get_employees():
- holidays = frappe.get_all("Holiday", fields=["holiday_date", "description"])
+def get_employees(filters):
+ holidays = frappe.get_all("Holiday", fields=["holiday_date", "description"],
+ filters=[["holiday_date", ">=",
+ filters.from_date],
+ ["holiday_date", "<=", filters.to_date]])
holiday_names = {}
holidays_list = []
@@ -35,15 +38,15 @@
holiday_names[holiday.holiday_date] = holiday.description
if(holidays_list):
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)
+ employee, employee_name, att_date, status
+ from tabAttendance
+ where
+ att_date in ({0})""".format(', '.join(["%s"] * len(holidays_list))),
+ holidays_list, as_list=True)
for employee_data in employee_list:
employee_data.append(holiday_names[employee_data[2]])
return employee_list
else:
- return None
\ No newline at end of file
+ return []
diff --git a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
index 0dc25d2..3bc355c 100644
--- a/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
+++ b/erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py
@@ -27,7 +27,7 @@
total_p = total_a = 0.0
for day in range(filters["total_days_in_month"]):
status = att_map.get(emp).get(day + 1, "Absent")
- status_map = {"Present": "P", "Absent": "A", "Half Day": "HD"}
+ status_map = {"Present": "P", "Absent": "A", "Half Day": "H"}
row.append(status_map[status])
if status == "Present":