How to set attendace status as Absent from employee employee checkin’s Auto Attendance if any checkin entry missing?
I have given attendance from employee checkin and 3 will be unmakred. How to show these as Absent in Attendance data using Auto Attendance?
ejaaz
October 15, 2024, 7:15pm
2
There is no default feature for that; you will have to write a script to do that.
)
from hrms.hr.doctype.shift_assignment.shift_assignment import get_employee_shift, get_shift_details
from hrms.utils import get_date_range
from hrms.utils.holiday_list import get_holiday_dates_between
EMPLOYEE_CHUNK_SIZE = 50
class ShiftType(Document):
@frappe.whitelist()
def process_auto_attendance(self):
if (
not cint(self.enable_auto_attendance)
or not self.process_attendance_after
or not self.last_sync_of_checkin
):
return
logs = self.get_employee_checkins()
group_key = lambda x: (x["employee"], x["shift_start"]) # noqa
Override this function
In this function you will get in_time and out_time
check condition if not in_time or not out_time then set attendance status as absent.
@ejaaz Thanks for the reply. I’ll check the override you suggest.
But how can I detect employee’s absent data if it will skip marking attendance for that particular record? If any employee absent for a day, then that employee’s checkin will be not added in checkin data, and it should add as absent in Attendance record.
ejaaz
October 16, 2024, 4:13am
4
ERP automatically handles that check; below is the code for that.
# commit after processing checkin logs to avoid losing progress
frappe.db.commit() # nosemgrep
assigned_employees = self.get_assigned_employees(self.process_attendance_after, True)
# mark absent in batches & commit to avoid losing progress since this tries to process remaining attendance
# right from "Process Attendance After" to "Last Sync of Checkin"
for batch in create_batch(assigned_employees, EMPLOYEE_CHUNK_SIZE):
for employee in batch:
self.mark_absent_for_dates_with_no_attendance(employee)
frappe.db.commit() # nosemgrep
def get_employee_checkins(self) -> list[dict]:
return frappe.get_all(
"Employee Checkin",
fields=[
"name",
"employee",
"log_type",
Sorry, with this sentence, I understand that you want to check if an IN or OUT entry is missing from employee check-ins.
If whole-day check-ins are not present, then the ERP will automatically handle that as explained above.
1 Like
@ejaaz Ok. I have added employee checkin data for the period from February 1st to February 28th, 2023, intentionally leaving three days of attendance unmarked. When I pull attendance from shift type. There is no Absent. Only present attendees are showing. The 3 unmarked attendees are skipped.
ejaaz
October 16, 2024, 4:30am
6
@Lone_Wolf
Are the 3 skipped days added to the holiday list?
No, they are not in Holiday list. And monthly attendance sheet report shows 3 unmarked Days.
ejaaz
October 16, 2024, 4:47am
8
Can you please share your Shift Type setting?
ejaaz
October 16, 2024, 5:09am
10
Your Shift setting looks good
I have almost the same settings, and I don’t have check-in for the 4th of October. When I marked attendance, it automatically marked me absent for the 4th of October.
I did not add checkin data at 2, 6 and 9 Feb. Not found any absent