Merge pull request #5705 from KanchanChauhan/fixed-employee-holiday-attendance-report
Added Holiday List filter
This commit is contained in:
commit
4beba3aff9
@ -16,6 +16,12 @@ frappe.query_reports["Employee Holiday Attendance"] = {
|
||||
"fieldtype": "Date",
|
||||
"reqd": 1,
|
||||
"default": frappe.datetime.year_end()
|
||||
},
|
||||
{
|
||||
"fieldname":"holiday_list",
|
||||
"label": __("Holiday List"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Holiday List"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -24,25 +24,34 @@ def get_columns():
|
||||
_("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]])
|
||||
|
Loading…
x
Reference in New Issue
Block a user