-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: filter unmarked attendance by shift in employee attendance tool #3362 #3363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.json
Outdated
Show resolved
Hide resolved
hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.py
Outdated
Show resolved
Hide resolved
@asmitahase can you review and give feed back |
if filter_by_shift: | ||
unmarked_attendance = _get_unmarked_attendance_with_shift(unmarked_attendance, shift, date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementing filter by shift this way has one consequence of fetching employees with empty default shift if filter_by_shift is checked but shift isn't set. For other filters like company, department etc, if there's no value for filters all employees are fetched.
shift_assigned_employees = frappe.get_list( | ||
'Shift Assignment', | ||
filters = { | ||
'shift_type': shift, | ||
'start_date': ['<=', frappe.utils.getdate(date)], | ||
}, | ||
fields=['employee'] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more caveat is, because we're getting data from two different doctypes, get_list isn't enough to ensure all the filters are "and"ed e.g if someone wants to fetch employees from department A and shift B, it won't be ensured because shift assignment may have employees belonging to different department.
It's better to use query builder to select employees in this case. And while we're half way there, might as well use that to separate unmarked and half day marked employees too. I'll contribute to this. Looks good enough for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback! @asmitahase . The cases you mentioned are already covered in the current filter logic.
- The
employee_list
is first filtered to get the unmarked attendance through the_get_unmarked_attendance
function, which ensures that all necessary conditions (such as department, grades or other filters) are applied. - Using the same filtered
unmarked_attendance
, I'm further refining it by checking the shift assignments (both default shifts and shift assignments). This ensures that only employees assigned to the relevant shift are included.
Please correct me if I’m wrong in the current logic. Should I work on the requested changes if the filtering with shift logic is incorrect?
Closes #3362
_get_unmarked_attendance_with_shift()
to fetch the employees based on shift assignmentMoved the

Shift
field in filters sectionHR.PR.mp4