fix: IN time not captured in Attendance through Employee Checkin (#31029)
diff --git a/erpnext/hr/doctype/employee_checkin/employee_checkin.py b/erpnext/hr/doctype/employee_checkin/employee_checkin.py
index e07b5e5..ecee541 100644
--- a/erpnext/hr/doctype/employee_checkin/employee_checkin.py
+++ b/erpnext/hr/doctype/employee_checkin/employee_checkin.py
@@ -227,11 +227,15 @@
in_log = out_log = None
if not in_log:
in_log = log if log.log_type == "IN" else None
+ if in_log and not in_time:
+ in_time = in_log.time
elif not out_log:
out_log = log if log.log_type == "OUT" else None
+
if in_log and out_log:
out_time = out_log.time
total_hours += time_diff_in_hours(in_log.time, out_log.time)
+
return total_hours, in_time, out_time
diff --git a/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py b/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py
index ced42bb..b603b3a 100644
--- a/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py
+++ b/erpnext/hr/doctype/employee_checkin/test_employee_checkin.py
@@ -125,6 +125,11 @@
)
self.assertEqual(working_hours, (4.5, logs_type_2[1].time, logs_type_2[-1].time))
+ working_hours = calculate_working_hours(
+ [logs_type_2[1], logs_type_2[-1]], check_in_out_type[1], working_hours_calc_type[1]
+ )
+ self.assertEqual(working_hours, (5.0, logs_type_2[1].time, logs_type_2[-1].time))
+
def test_fetch_shift(self):
employee = make_employee("test_employee_checkin@example.com", company="_Test Company")