From 5e1dacfeec7b526e18c47253c5ac38b38c95bd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 19 Mar 2026 21:47:20 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20[changes]=20=EA=B7=BC=ED=83=9C=ED=98=84?= =?UTF-8?q?=ED=99=A9=20=EC=8A=B9=EC=9D=B8=EB=90=9C=20=ED=9C=B4=EA=B0=80=20?= =?UTF-8?q?=EB=88=84=EB=9D=BD=20attendance=20=EB=B3=B4=EC=A0=95=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=9D=B4=EB=A0=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- INDEX.md | 1 + changes/20260319_attendance_leave_sync_fix.md | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 changes/20260319_attendance_leave_sync_fix.md diff --git a/INDEX.md b/INDEX.md index 6cf9113..50d5c78 100644 --- a/INDEX.md +++ b/INDEX.md @@ -286,6 +286,7 @@ DB 도메인별: | [20260319_esign_salary_year_regex_fix.md](changes/20260319_esign_salary_year_regex_fix.md) | 전자계약 근로계약서 연봉계약종료연도 정규식 버그 수정 (두음법칙 불일치) | | [20260319_barobill_card_auto_sync.md](changes/20260319_barobill_card_auto_sync.md) | 바로빌 카드 사용내역 자동 동기화 스케줄러 추가 (2시간마다, 서버 crontab 필요) | | [20260319_db_codebridge_migration_and_fixes.md](changes/20260319_db_codebridge_migration_and_fixes.md) | MNG 전용 테이블 codebridge DB 이관 + 손익계산서 매출액/월별 세부내역 수정 | +| [20260319_attendance_leave_sync_fix.md](changes/20260319_attendance_leave_sync_fix.md) | 근태현황 승인된 휴가 누락 attendance 레코드 자동 보정 | --- diff --git a/changes/20260319_attendance_leave_sync_fix.md b/changes/20260319_attendance_leave_sync_fix.md new file mode 100644 index 0000000..f5b62b4 --- /dev/null +++ b/changes/20260319_attendance_leave_sync_fix.md @@ -0,0 +1,50 @@ +# 근태현황 승인된 휴가 누락 attendance 레코드 자동 보정 + +**날짜:** 2026-03-19 +**작업자:** Claude Code + +## 변경 개요 + +휴가관리에서 3명의 휴가가 승인 상태인데, 근태현황에는 2명만 표시되는 버그 수정. +승인된 휴가에 대응하는 `attendances` 레코드가 누락된 경우, 근태 목록/통계/엑셀 조회 시 자동으로 누락 레코드를 생성하는 방어 로직 추가. + +## 원인 분석 + +휴가 승인 흐름: 결재 최종 승인 → `handleApprovalCompleted` → `approveByApproval` → `createAttendanceRecords` + +이 흐름은 단일 DB 트랜잭션 내에서 실행되어 코드 상 정상이나, 특정 조건에서 attendance 레코드가 누락되는 케이스가 발생. 근본 원인 특정은 어렵지만, 데이터 정합성을 보장하기 위해 조회 시점에 보정하는 방어 로직을 추가. + +## 수정된 파일 + +| 파일 | 변경 내용 | +|------|----------| +| `app/Services/HR/AttendanceService.php` | `syncApprovedLeaveAttendances()` 메서드 추가, `getAttendances()`/`getExportData()`/`getMonthlyStats()`에서 호출 | + +## 상세 변경 사항 + +### `syncApprovedLeaveAttendances()` 메서드 추가 + +- 조회 기간 내 승인된 휴가(`leaves.status = 'approved'`) 중 `ATTENDANCE_STATUS_MAP`에 매핑이 있는 유형만 대상 +- 기간 내 기존 `attendances` 레코드를 `user_id + base_date` 조합으로 빠르게 조회 +- 누락된 날짜에 대해 `Attendance::withTrashed()->updateOrCreate()`로 생성 (soft-deleted 레코드도 복원) +- 주말은 건너뜀 + +### 호출 위치 + +| 메서드 | 용도 | +|--------|------| +| `getAttendances()` | 근태 목록 조회 (HTMX 테이블) | +| `getExportData()` | 엑셀 내보내기 | +| `getMonthlyStats()` | 월간 통계 카드 (정시출근/지각/결근/휴가/기타) | + +## 테스트 체크리스트 + +- [x] 승인된 휴가 3건 중 누락된 1건이 근태현황에 표시되는지 확인 +- [x] 기존 attendance 레코드가 있는 경우 중복 생성되지 않는지 확인 +- [x] 월간 통계 카드의 휴가 건수가 정확한지 확인 +- [ ] 운영서버 배포 후 실데이터 확인 + +## 관련 문서 + +- `rules/attendance-api.md` — 근태 API 규칙 +- `features/hr/` — 인사관리 기능