fix(vacation): bulkUpsert 저장 테이블 통일 (sp_vacation_balances)
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user