From 203ec6cb84e0e95ae99380b2dd28eaa7c7b51fd9 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Thu, 5 Feb 2026 17:18:50 +0700 Subject: [PATCH] fix: run temp to profileSalary --- src/controllers/ProfileSalaryTempController.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/controllers/ProfileSalaryTempController.ts b/src/controllers/ProfileSalaryTempController.ts index 6d20d9f0..95713278 100644 --- a/src/controllers/ProfileSalaryTempController.ts +++ b/src/controllers/ProfileSalaryTempController.ts @@ -1326,6 +1326,7 @@ export class ProfileSalaryTempController extends Controller { * 3. Split Update / Insert * ========================= */ // const toUpdate = salaryTemps.filter((t) => t.salaryId && t.isEdit && !t.isDelete); + const backupTemp = salaryTemps; const toInsert = salaryTemps.filter((t) => !t.isDelete); const dateNow = new Date(); const metaUpdate = { @@ -1339,6 +1340,8 @@ export class ProfileSalaryTempController extends Controller { ...(isOfficer ? { profileId: body.profileId } : { profileEmployeeId: body.profileId }), }); + // add insert to profile salary backup + // delete profile salary await queryRunner.manager.delete(ProfileSalary, { ...(isOfficer ? { profileId: body.profileId } : { profileEmployeeId: body.profileId }), @@ -1377,6 +1380,15 @@ export class ProfileSalaryTempController extends Controller { await queryRunner.manager.insert(ProfileSalary, insertData); } + // insert profile salary temp new + if (backupTemp.length > 0) { + const insertBackupTemp = toInsert.map(({ id, ...data }) => ({ + ...data, + })); + + await queryRunner.manager.insert(ProfileSalaryTemp, insertBackupTemp); + } + await queryRunner.commitTransaction(); return new HttpSuccess(); } catch (error) {