From 53596ba540bc10291464f20e870cf3196ca21be4 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Tue, 31 Mar 2026 08:41:55 +0900 Subject: [PATCH] =?UTF-8?q?fix(vacation):=20bulkUpsert=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=ED=85=8C=EC=9D=B4=EB=B8=94=20=ED=86=B5=EC=9D=BC=20?= =?UTF-8?q?(sp=5Fvacation=5Fbalances)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vacation_balance_details에 쓰고 sp_vacation_balances에서 읽는 테이블 불일치 수정. 경조사 등 특별휴가 저장 후 반영 안 되던 문제 해결. - bulkUpsert: vacation_balance_details → sp_vacation_balances - balance_type 전달: CARRY_OVER, AUTO, LONG_SERVICE, COMPANY_GRANT - 기존 경조사 데이터 21건 sp_vacation_balances로 마이그레이션 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../api/controllers/vacationBalanceController.js | 14 +++++++------- .../web/pages/attendance/annual-overview.html | 12 ++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/system1-factory/api/controllers/vacationBalanceController.js b/system1-factory/api/controllers/vacationBalanceController.js index 420e2d7..069f322 100644 --- a/system1-factory/api/controllers/vacationBalanceController.js +++ b/system1-factory/api/controllers/vacationBalanceController.js @@ -213,7 +213,7 @@ const vacationBalanceController = { let errorCount = 0; for (const balance of balances) { - const { user_id, vacation_type_id, year, total_days, notes } = balance; + const { user_id, vacation_type_id, year, total_days, notes, balance_type } = balance; if (!user_id || !vacation_type_id || !year || total_days === undefined) { errorCount++; @@ -221,17 +221,17 @@ const vacationBalanceController = { } try { + const btype = balance_type || 'AUTO'; const query = ` - INSERT INTO vacation_balance_details - (user_id, vacation_type_id, year, total_days, used_days, notes, created_by) - VALUES (?, ?, ?, ?, 0, ?, ?) + INSERT INTO sp_vacation_balances + (user_id, vacation_type_id, year, total_days, used_days, notes, created_by, balance_type, expires_at) + VALUES (?, ?, ?, ?, 0, ?, ?, ?, NULL) ON DUPLICATE KEY UPDATE total_days = VALUES(total_days), - notes = VALUES(notes), - updated_at = NOW() + notes = VALUES(notes) `; - await db.query(query, [user_id, vacation_type_id, year, total_days, notes || null, created_by]); + await db.query(query, [user_id, vacation_type_id, year, total_days, notes || null, created_by, btype]); successCount++; } catch (err) { logger.error('휴가 잔액 저장 오류:', err); diff --git a/system1-factory/web/pages/attendance/annual-overview.html b/system1-factory/web/pages/attendance/annual-overview.html index f11e006..2ede310 100644 --- a/system1-factory/web/pages/attendance/annual-overview.html +++ b/system1-factory/web/pages/attendance/annual-overview.html @@ -829,7 +829,8 @@ user_id: w.user_id, vacation_type_id: typeIdMap['CARRYOVER'], year: currentYear, - total_days: d.carryover + total_days: d.carryover, + balance_type: 'CARRY_OVER' }); } if (typeIdMap['ANNUAL']) { @@ -837,7 +838,8 @@ user_id: w.user_id, vacation_type_id: typeIdMap['ANNUAL'], year: currentYear, - total_days: d.annual + total_days: d.annual, + balance_type: 'AUTO' }); } if (typeIdMap['LONG_SERVICE']) { @@ -845,7 +847,8 @@ user_id: w.user_id, vacation_type_id: typeIdMap['LONG_SERVICE'], year: currentYear, - total_days: d.longService + total_days: d.longService, + balance_type: 'LONG_SERVICE' }); } @@ -883,7 +886,8 @@ vacation_type_id: specialTypeId, year: currentYear, total_days: special.days, - notes: special.typeName || special.type + notes: special.typeName || special.type, + balance_type: 'COMPANY_GRANT' }); } }