Skip to content

Commit

Permalink
fix: don't consider default shift in overlapping period if curr shift…
Browse files Browse the repository at this point in the history
… is found
  • Loading branch information
ruchamahabal committed Jul 20, 2023
1 parent 2e6147a commit d94f94c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions hrms/hr/doctype/shift_assignment/shift_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,24 @@ def get_employee_shift_timings(
if for_timestamp is None:
for_timestamp = now_datetime()

# write and verify a test case for midnight shift.
prev_shift = curr_shift = next_shift = None
curr_shift = get_employee_shift(employee, for_timestamp, consider_default_shift, "forward")

# don't consider default shift in overlapping period as curr shift is already fetched
# default shift is supposed to be used as a fallback
consider_default_shift_in_overlapping_period = False if curr_shift else consider_default_shift

if curr_shift:
next_shift = get_employee_shift(
employee, curr_shift.start_datetime + timedelta(days=1), consider_default_shift, "forward"
employee,
curr_shift.start_datetime + timedelta(days=1),
consider_default_shift_in_overlapping_period,
"forward",
)
prev_shift = get_employee_shift(
employee,
(curr_shift.end_datetime if curr_shift else for_timestamp) + timedelta(days=-1),
consider_default_shift,
consider_default_shift_in_overlapping_period,
"reverse",
)

Expand Down

0 comments on commit d94f94c

Please sign in to comment.