fix mode profileSalaryTemp to profileSalary
All checks were successful
Build & Deploy on Dev / build (push) Successful in 53s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 53s
This commit is contained in:
parent
631d634074
commit
af466df0d0
1 changed files with 35 additions and 29 deletions
|
|
@ -1315,9 +1315,7 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
* 2. Load Salary Temp
|
* 2. Load Salary Temp
|
||||||
* ========================= */
|
* ========================= */
|
||||||
const salaryTemps = await queryRunner.manager.find(ProfileSalaryTemp, {
|
const salaryTemps = await queryRunner.manager.find(ProfileSalaryTemp, {
|
||||||
where: isOfficer
|
where: isOfficer ? { profileId: body.profileId } : { profileEmployeeId: body.profileId },
|
||||||
? { profileId: body.profileId }
|
|
||||||
: { profileEmployeeId: body.profileId },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (salaryTemps.length === 0) {
|
if (salaryTemps.length === 0) {
|
||||||
|
|
@ -1327,8 +1325,8 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
/* =========================
|
/* =========================
|
||||||
* 3. Split Update / Insert
|
* 3. Split Update / Insert
|
||||||
* ========================= */
|
* ========================= */
|
||||||
const toUpdate = salaryTemps.filter(t => t.salaryId);
|
// const toUpdate = salaryTemps.filter((t) => t.salaryId && t.isEdit && !t.isDelete);
|
||||||
const toInsert = salaryTemps.filter(t => !t.salaryId);
|
const toInsert = salaryTemps.filter((t) => !t.isDelete);
|
||||||
const dateNow = new Date();
|
const dateNow = new Date();
|
||||||
const metaUpdate = {
|
const metaUpdate = {
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
|
|
@ -1336,20 +1334,30 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
lastUpdatedAt: dateNow,
|
lastUpdatedAt: dateNow,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// delete profile salary temp
|
||||||
|
await queryRunner.manager.delete(ProfileSalaryTemp, {
|
||||||
|
...(isOfficer ? { profileId: body.profileId } : { profileEmployeeId: body.profileId }),
|
||||||
|
});
|
||||||
|
|
||||||
|
// delete profile salary
|
||||||
|
await queryRunner.manager.delete(ProfileSalary, {
|
||||||
|
...(isOfficer ? { profileId: body.profileId } : { profileEmployeeId: body.profileId }),
|
||||||
|
});
|
||||||
|
|
||||||
/* =========================
|
/* =========================
|
||||||
* 4. UPDATE
|
* 4. UPDATE
|
||||||
* ========================= */
|
* ========================= */
|
||||||
for (const temp of toUpdate) {
|
// for (const temp of toUpdate) {
|
||||||
const { id, salaryId, isDelete, isEdit, ...data } = temp;
|
// const { id, salaryId, isDelete, isEdit, ...data } = temp;
|
||||||
await queryRunner.manager.update(
|
// await queryRunner.manager.update(
|
||||||
ProfileSalary,
|
// ProfileSalary,
|
||||||
{ id: salaryId },
|
// { id: salaryId },
|
||||||
{
|
// {
|
||||||
...data,
|
// ...data,
|
||||||
...metaUpdate,
|
// ...metaUpdate,
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* =========================
|
/* =========================
|
||||||
* 5. INSERT (bulk)
|
* 5. INSERT (bulk)
|
||||||
|
|
@ -1371,7 +1379,6 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
|
|
||||||
await queryRunner.commitTransaction();
|
await queryRunner.commitTransaction();
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -1380,7 +1387,6 @@ export class ProfileSalaryTempController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API แก้ไขข้อมูล
|
* API แก้ไขข้อมูล
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue