@@ -295,3 +295,36 @@ def test_consecutive_day_and_night_shifts(self):
295
295
self .assertEqual (checkin .shift_type , checkout .shift_type )
296
296
self .assertEqual (checkin .actual_start .date (), today )
297
297
self .assertEqual (checkout .actual_end .date (), today )
298
+
299
+ def test_shift_details_on_consecutive_days_with_overlapping_timings (self ):
300
+ # defaults
301
+ employee = make_employee (
"[email protected] " ,
company = "_Test Company" )
302
+ today = getdate ()
303
+ yesterday = add_days (today , - 1 )
304
+
305
+ # shift 1
306
+ shift_type = setup_shift_type (shift_type = "Morning" , start_time = "07:00:00" , end_time = "12:00:00" )
307
+ make_shift_assignment (shift_type .name , employee , add_days (yesterday , - 1 ), yesterday )
308
+
309
+ # shift 2
310
+ shift_type = setup_shift_type (shift_type = "Afternoon" , start_time = "09:30:00" , end_time = "14:00:00" )
311
+ make_shift_assignment (shift_type .name , employee , today , add_days (today , 1 ))
312
+
313
+ # current_shift shift log - checkin in the grace period of current shift, non-overlapping with prev shift
314
+ current_shift = get_actual_start_end_datetime_of_shift (
315
+ employee , get_datetime (f"{ today } 14:01:00" ), True
316
+ )
317
+ self .assertEqual (current_shift .shift_type .name , "Afternoon" )
318
+ self .assertEqual (current_shift .actual_start , get_datetime (f"{ today } 08:30:00" ))
319
+ self .assertEqual (current_shift .actual_end , get_datetime (f"{ today } 15:00:00" ))
320
+
321
+ # previous shift
322
+ checkin = get_actual_start_end_datetime_of_shift (
323
+ employee , get_datetime (f"{ yesterday } 07:01:00" ), True
324
+ )
325
+ checkout = get_actual_start_end_datetime_of_shift (
326
+ employee , get_datetime (f"{ yesterday } 13:00:00" ), True
327
+ )
328
+ self .assertTrue (checkin .shift_type .name == checkout .shift_type .name == "Morning" )
329
+ self .assertEqual (checkin .actual_start , get_datetime (f"{ yesterday } 06:00:00" ))
330
+ self .assertEqual (checkout .actual_end , get_datetime (f"{ yesterday } 13:00:00" ))
0 commit comments