Skip to content

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

anwarpatelnoori
Copy link

@anwarpatelnoori anwarpatelnoori commented Jul 19, 2025

Closes #3362

Please provide enough information so that others can review your pull request:

  • Shift field is already present in Employee Attendance DocType.
  • Shift field is not used in filters while fetching employees
  • But while marking the attendance the field is used
  • So I added another _get_unmarked_attendance_with_shift() to fetch the employees based on shift assignment

Explain the details for making this change. What existing problem does the pull request solve?
If ERPNext setup has over 4,000 employees, and their HR team uses the Employee Attendance Tool exclusively to mark attendance.

  • Each shift contains around 1,000+ employees.
    
  • Currently, the tool fetches employees from all shifts, regardless of which shift is being assigned .
    
  • As a result, HR staff have to manually remove employees who are not part of the target shift before proceeding.
    
  • This process is time-consuming given the volume of employees.
    
  • A shift-based filter would significantly improve efficiency and accuracy when marking attendance.
    
image > Screenshots/GIFs

Moved the Shift field in filters section
image

HR.PR.mp4

"column_break_gmhs",
"late_entry",
"early_exit",
"section_break_ackd",
"company",
"branch",
"department",
"shift",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good problem to solve, although the UX could be improved.

Shifting shift field from the top section to filters could be confusing to users who don't fetch employees by shift and need to set one while marking attendance. Good problem to solve, although the UX could be improved.

Instead of moving shift field, maybe add separate field called "Assigned Shift" in the filters section. Or add a checkbox that says "Filter employees by Shift" which would then use the value set in shift to filter employees. Just thinking out loud here...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback.
I will work on changes

Comment on lines +93 to +110
shift_assigned_employees = frappe.get_list(
'Shift Assignment',
filters={
'shift_type': shift,
'start_date': ['<=', frappe.utils.getdate(date)],
'end_date': ['>=', frappe.utils.getdate(date)]
},
fields=['employee']
)
assigned_employee_ids = {emp['employee'] for emp in shift_assigned_employees}

# Filter unmarked attendance based on assigned employees
shiftwise_unmarked_attendance = []
for emp in unmarked_attendance:
if emp['employee'] in assigned_employee_ids:
shiftwise_unmarked_attendance.append(emp)

return shiftwise_unmarked_attendance
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also excludes default shifts that are set in the employee master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Employee Attendance Tool Doctype needs shift wise filter for fetching unmarked Employees
2 participants