From 811b9991c97c788dd1935624116d2f85283b596f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IT=E7=8B=97?= Date: Tue, 21 Jul 2026 23:39:15 +0800 Subject: [PATCH] =?UTF-8?q?Attendance=20filter:=20=E8=AB=8B=E5=81=87/?= =?UTF-8?q?=E5=85=AC=E5=81=87=20=E2=80=94=20also=20match=20leave/holiday?= =?UTF-8?q?=20suffix=20in=20status=5Ftext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure-leave status_code (al/sl/cl/mixed_leave) only catches employees who took the whole day off. Records where the employee worked AND took leave mid-day keep their raw status_code (normal/abnormal/ot) but carry a ' + SL2h' / ' + AL4h' suffix that the badge now surfaces as a chip — yet those records disappeared under the '請假' filter. Same gap for holidays: '公假' only matched status_code='holiday' but an employee who worked on the public holiday still gets the '🎉' suffix and should be reachable from the holiday filter. Expand both filters to also match records whose status_text contains the relevant suffix (' + SL' / ' + AL' / ' + CL' / '🎉'), keeping the result set aligned with what the badge chip advertises. --- backend/main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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: