fix(auto attendance): handling None case for IN/OUT Logs (#18867)
This commit is contained in:
parent
91596f2467
commit
1d1427de60
@ -142,8 +142,10 @@ def calculate_working_hours(logs, check_in_out_type, working_hours_calc_type):
|
||||
|
||||
elif check_in_out_type == 'Strictly based on Log Type in Employee Checkin':
|
||||
if working_hours_calc_type == 'First Check-in and Last Check-out':
|
||||
first_in_log = logs[find_index_in_dict(logs, 'log_type', 'IN')]
|
||||
last_out_log = logs[len(logs)-1-find_index_in_dict(reversed(logs), 'log_type', 'OUT')]
|
||||
first_in_log_index = find_index_in_dict(logs, 'log_type', 'IN')
|
||||
first_in_log = logs[first_in_log_index] if first_in_log_index or first_in_log_index == 0 else None
|
||||
last_out_log_index = find_index_in_dict(reversed(logs), 'log_type', 'OUT')
|
||||
last_out_log = logs[len(logs)-1-last_out_log_index] if last_out_log_index or last_out_log_index == 0 else None
|
||||
if first_in_log and last_out_log:
|
||||
in_time, out_time = first_in_log.time, last_out_log.time
|
||||
total_hours = time_diff_in_hours(in_time, out_time)
|
||||
|
Loading…
x
Reference in New Issue
Block a user