when i created a employee checkin then the shift field is being empty for some shifts
shift assignment is done for the employee the why shift is empty for some shift types
shift is not empty
shift is empty
when i created a employee checkin then the shift field is being empty for some shifts
shift assignment is done for the employee the why shift is empty for some shift types
shift is not empty
shift is empty
hi @NCP ,
I am customizing the HR app by adding face recognition, so an employee will clock-in or clock-out then face recognition is done then employee checkin is created for the employee
query = """SELECT name, shift_type, docstatus
FROM `tabShift Assignment`
WHERE employee = %s AND docstatus = %s
"""
shift_assigned = frappe.db.sql(query, (employee_id, 1), as_dict=True)
employee_check_in = frappe.new_doc("Employee Checkin")
employee_check_in.employee = employee_id
employee_check_in.log_type = "IN"
employee_check_in.custom_location = location_json
shift_doc = frappe.get_doc("Shift Type",shift_assigned[0]['shift_type'])
logger.info(f"shift_doc: {shift_doc}")
employee_check_in.shift = shift_doc
employee_check_in.insert(ignore_permissions=True)
this is how a record is created in employee checkin, even though I am filling the shift field for the employee checkin still the field is being empty
why is this happening, this is happening only for some shift types, why?
also all shift types are configured in same way
Not idea about that, you have to find the core code and check that concept, i think itâs a new features.
it turns out that the employee clock-in or clock-out time should be in between shift actual start time and shift actual end time
def _is_timestamp_within_shift(shift_details: dict, for_timestamp: datetime) -> bool:
"""Checks whether the timestamp is within shift's actual start and end datetime"""
return shift_details.actual_start <= for_timestamp <= shift_details.actual_end
so thats why shift is empty in employee checkin