Fix: strip existing leave suffix before appending new leave to prevent duplication
This commit is contained in:
+10
-1
@@ -181,13 +181,22 @@ def enrich_attendance_with_leave(records, db):
|
||||
r.status_code = "mixed_leave"
|
||||
r.status_text = leave_text
|
||||
elif original_code in ("al", "sl", "cl"):
|
||||
# Pure leave status: check if multiple leave types → upgrade to mixed
|
||||
# Pure leave status: replace with aggregated leave text
|
||||
if len(leave_by_type) > 1:
|
||||
r.status_code = "mixed_leave"
|
||||
r.status_text = leave_text
|
||||
else:
|
||||
r.status_text = leave_text
|
||||
elif original_code not in ("missing", "", "holiday", "al", "sl", "cl"):
|
||||
# Non-leave attendance status: strip any previously-enriched leave suffix and rebuild
|
||||
base_text = (r.status_text or "正常").split(" + ")[0] # keep only attendance part
|
||||
base_text = base_text.split(" (")[0] # strip holiday annotation
|
||||
if leave_text:
|
||||
r.status_text = f"{base_text} + {leave_text}"
|
||||
else:
|
||||
r.status_text = base_text
|
||||
else:
|
||||
# original_code is empty or holiday or already handled above
|
||||
base = r.status_text or "正常"
|
||||
r.status_text = f"{base} + {leave_text}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user