fix: run temp to profileSalary
All checks were successful
Build & Deploy on Dev / build (push) Successful in 53s

This commit is contained in:
Warunee Tamkoo 2026-02-05 17:18:50 +07:00
parent af466df0d0
commit 203ec6cb84

View file

@ -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) {