feat(vacation): 이월연차 만료 시스템 + 대시보드 합산 개선
- createBalance/bulkUpsert에서 CARRY_OVER expires_at 자동 설정 (carry_over_expiry_month 설정 기반, 기본값 2월말) - deductByPriority/deductDays 쿼리에 만료 필터 추가 (expires_at >= CURDATE() 조건, 만료된 이월 차감 제외) - 대시보드 합산에서 만료된 잔액 제외 - DB 보정 완료: CARRY_OVER 8건 expires_at 설정, 황인용/최광욱 소급 재계산 (이월 우선 차감 반영) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,9 +44,11 @@ const DashboardController = {
|
||||
remaining: parseFloat(v.remaining_days) || 0
|
||||
}));
|
||||
|
||||
// 모든 balance_type 합산
|
||||
const totalDays = vacationRows.reduce((s, v) => s + (parseFloat(v.total_days) || 0), 0);
|
||||
const usedDays = vacationRows.reduce((s, v) => s + (parseFloat(v.used_days) || 0), 0);
|
||||
// 만료되지 않은 balance만 합산 (만료된 이월연차 제외)
|
||||
const today = new Date().toISOString().substring(0, 10);
|
||||
const activeRows = vacationRows.filter(v => !v.expires_at || v.expires_at >= today);
|
||||
const totalDays = activeRows.reduce((s, v) => s + (parseFloat(v.total_days) || 0), 0);
|
||||
const usedDays = activeRows.reduce((s, v) => s + (parseFloat(v.used_days) || 0), 0);
|
||||
const remainingDays = totalDays - usedDays;
|
||||
|
||||
res.json({
|
||||
|
||||
@@ -223,6 +223,7 @@ const vacationBalanceModel = {
|
||||
INNER JOIN vacation_types vt ON svb.vacation_type_id = vt.id
|
||||
WHERE svb.user_id = ? AND svb.year = ?
|
||||
AND (svb.total_days - svb.used_days) > 0
|
||||
AND (svb.expires_at IS NULL OR svb.expires_at >= CURDATE())
|
||||
ORDER BY vt.priority ASC, FIELD(svb.balance_type, 'CARRY_OVER', 'AUTO', 'MANUAL', 'LONG_SERVICE', 'COMPANY_GRANT')
|
||||
FOR UPDATE
|
||||
`, [userId, year]);
|
||||
|
||||
Reference in New Issue
Block a user