Skip to content

Commit

Permalink
fix: IN time not captured in Attendance through Employee Checkin (bac…
Browse files Browse the repository at this point in the history
…kport #31029) (#31031)

* fix: IN time not captured in Attendance through Employee Checkin (#31029)

(cherry picked from commit 1b7ce96)

# Conflicts:
#	erpnext/hr/doctype/employee_checkin/test_employee_checkin.py

* fix: conflicts

Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
  • Loading branch information
mergify[bot] and ruchamahabal authored May 16, 2022
1 parent fc80a50 commit 477bbcc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions erpnext/hr/doctype/employee_checkin/employee_checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,15 @@ def calculate_working_hours(logs, check_in_out_type, working_hours_calc_type):
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


Expand Down
5 changes: 5 additions & 0 deletions erpnext/hr/doctype/employee_checkin/test_employee_checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ def test_calculate_working_hours(self):
)
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 make_n_checkins(employee, n, hours_to_reverse=1):
logs = [make_checkin(employee, now_datetime() - timedelta(hours=hours_to_reverse, minutes=n + 1))]
Expand Down

0 comments on commit 477bbcc

Please sign in to comment.