diff --git a/backend/main.py b/backend/main.py index 32096ae..fc206d8 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1318,11 +1318,21 @@ async def attendance_records( elif status_text in ('missing', '缺勤'): rows = [r for r in all_rows if (r.status_code or '').lower() == 'missing'] elif status_text in ('holiday', '公假'): - rows = [r for r in all_rows if (r.status_code or '').lower() == 'holiday'] + # Holiday shift OR raw records carrying a holiday suffix in status_text + # (e.g. '異常 (🎉香港特區成立紀念日)' where the employee worked on the holiday). + rows = [r for r in all_rows + if (r.status_code or '').lower() == 'holiday' + or '🎉' in (r.status_text or '')] elif status_text in leave_codes: rows = [r for r in all_rows if (r.status_code or '').lower() == status_text] elif status_text in ('leave', '請假'): - rows = [r for r in all_rows if (r.status_code or '').lower() in leave_codes] + # Any leave presence: pure leave status_code OR a leave suffix appended + # to a normal/abnormal/ot code (employee worked but took leave mid-day). + # Suffix format produced by enrich: ' + SL2h', ' + AL4h', ' + CL4h', etc. + rows = [r for r in all_rows + if (r.status_code or '').lower() in leave_codes + or any(f'+ {tag}' in (r.status_text or '') + for tag in ('SL', 'AL', 'CL'))] elif status_text in ('normal', '正常'): rows = [r for r in all_rows if (r.status_code or '').lower() == 'normal'] else: