From 3d2ecd1644a47cf0ae3827eba220e0795983d2ce Mon Sep 17 00:00:00 2001 From: NguyenND Date: Tue, 10 Mar 2026 17:02:01 -0400 Subject: [PATCH] March 10 2026: changed overnight shift timeframe --- app.py | 16 ++++++++-------- working_hours_calculator.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index f9626dc..ca059c8 100644 --- a/app.py +++ b/app.py @@ -9337,7 +9337,7 @@ def _overnight_aware_sort_key(record): action = (record.action_description or '').lower() is_out = 'out' in action or 'checkout' in action # Push early-morning check-outs past midnight to end of day order - if is_out and t.hour <= 6: + if is_out and t.hour <= 3: minutes += 24 * 60 return minutes @@ -9674,15 +9674,15 @@ def export_time_attendance_excel(records, project_name_for_filename, date_range_ _nxt_outs = [r for r in _next_recs if _is_out(r)] # Day N must have an unmatched late check-in (more INs than OUTs, - # with at least one IN at or after 18:00) + # with at least one IN at or after 20:00) if len(_day_ins) <= len(_day_outs): continue - _late_ins = [r for r in _day_ins if r.check_in_time.hour >= 18] + _late_ins = [r for r in _day_ins if r.check_in_time.hour >= 20] if not _late_ins: continue - # Find early-morning OUTs (<=06:00) on Day N+1 - _early_outs = [r for r in _nxt_outs if r.check_in_time.hour <= 6] + # Find early-morning OUTs (<=03:00) on Day N+1 + _early_outs = [r for r in _nxt_outs if r.check_in_time.hour <= 3] if not _early_outs: continue @@ -10045,12 +10045,12 @@ def export_time_attendance_excel(records, project_name_for_filename, date_range_ pair_hours = 'Missed Punch' # Determine whether this is an overnight pair: - # check-in is late evening (>= 18:00) AND check-out is early morning (<= 06:00) + # check-in is late evening (>= 20:00) AND check-out is early morning (<= 03:00) # Both records share the same check_in_date in the DB for this scenario. _is_overnight_pair = ( check_in_record and check_out_record and - check_in_record.check_in_time.hour >= 18 and - check_out_record.check_in_time.hour <= 6 + check_in_record.check_in_time.hour >= 20 and + check_out_record.check_in_time.hour <= 3 ) # Show daily total on last pair of last location diff --git a/working_hours_calculator.py b/working_hours_calculator.py index bf15372..b2633fe 100644 --- a/working_hours_calculator.py +++ b/working_hours_calculator.py @@ -484,8 +484,8 @@ class WorkingHoursCalculator: # check-out record to Day N so the pair resolves correctly. # Hours are attributed to the earlier day (Day N). # --------------------------------------------------------------- - OVERNIGHT_CHECKIN_HOUR = 18 # Check-in must be at or after 6 PM - OVERNIGHT_CHECKOUT_HOUR = 6 # Check-out must be at or before 6 AM + OVERNIGHT_CHECKIN_HOUR = 20 # Check-in must be at or after 8 PM + OVERNIGHT_CHECKOUT_HOUR = 3 # Check-out must be at or before 3 AM for work_type in ['regular', 'SP', 'PW', 'PT']: all_dates = sorted(daily_records_by_type[work_type].keys())