This commit is contained in:
parent
256296672d
commit
9aa0a97a53
2 changed files with 18 additions and 24 deletions
|
|
@ -1339,9 +1339,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
// add insert to profile salary backup
|
||||
const profileSalaryBeforeDelete = await queryRunner.manager.find(ProfileSalary, {
|
||||
where: {
|
||||
...(isOfficer
|
||||
? { profileId: body.profileId }
|
||||
: { profileEmployeeId: body.profileId }),
|
||||
...(isOfficer ? { profileId: body.profileId } : { profileEmployeeId: body.profileId }),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -1350,7 +1348,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
queryRunner.manager.create(ProfileSalaryBackup, {
|
||||
...salary,
|
||||
profileSalaryId: id,
|
||||
})
|
||||
}),
|
||||
);
|
||||
await queryRunner.manager.insert(ProfileSalaryBackup, backupRows);
|
||||
}
|
||||
|
|
@ -1389,17 +1387,11 @@ export class ProfileSalaryTempController extends Controller {
|
|||
lastUpdatedAt: dateNow,
|
||||
};
|
||||
|
||||
const salaryRows = toInsert.filter(
|
||||
x => !["17", "18"].includes(x.commandCode)
|
||||
);
|
||||
// ส่งไปรักษาการ
|
||||
const actPositionRows = toInsert.filter(
|
||||
x => x.commandCode === "17"
|
||||
);
|
||||
const salaryRows = toInsert.filter((x) => !["17", "18"].includes(x.commandCode));
|
||||
// ส่งไปรักษาการ
|
||||
const actPositionRows = toInsert.filter((x) => x.commandCode === "17");
|
||||
// ส่งไปช่วยราชการ
|
||||
const assistanceRows = toInsert.filter(
|
||||
x => x.commandCode === "18"
|
||||
);
|
||||
const assistanceRows = toInsert.filter((x) => x.commandCode === "18");
|
||||
|
||||
if (salaryRows.length) {
|
||||
await queryRunner.manager.insert(
|
||||
|
|
@ -1407,14 +1399,14 @@ export class ProfileSalaryTempController extends Controller {
|
|||
salaryRows.map(({ id, ...data }) => ({
|
||||
...data,
|
||||
...metaCreated,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
if (actPositionRows.length) {
|
||||
if (actPositionRows.length > 0) {
|
||||
await queryRunner.manager.insert(
|
||||
ProfileActposition,
|
||||
actPositionRows.map(x => ({
|
||||
actPositionRows.map((x) => ({
|
||||
profileId: x.profileId,
|
||||
profileEmployeeId: x.profileEmployeeId,
|
||||
dateStart: x.commandDateAffect,
|
||||
|
|
@ -1427,14 +1419,14 @@ export class ProfileSalaryTempController extends Controller {
|
|||
status: false,
|
||||
isDeleted: false,
|
||||
...metaCreated,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
if (assistanceRows.length) {
|
||||
|
||||
if (assistanceRows.length > 0) {
|
||||
await queryRunner.manager.insert(
|
||||
ProfileAssistance,
|
||||
assistanceRows.map(x => ({
|
||||
assistanceRows.map((x) => ({
|
||||
profileId: x.profileId,
|
||||
profileEmployeeId: x.profileEmployeeId,
|
||||
agency: x.orgRoot,
|
||||
|
|
@ -1448,7 +1440,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
status: "DONE",
|
||||
isUpload: false,
|
||||
...metaCreated,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1457,6 +1449,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
if (backupTemp.length > 0) {
|
||||
const insertBackupTemp = toInsert.map(({ id, ...data }) => ({
|
||||
...data,
|
||||
salaryId: null,
|
||||
}));
|
||||
|
||||
await queryRunner.manager.insert(ProfileSalaryTemp, insertBackupTemp);
|
||||
|
|
|
|||
|
|
@ -273,8 +273,9 @@ export class ProfileSalaryTemp extends EntityBase {
|
|||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง profileSalary",
|
||||
default: null,
|
||||
type: "varchar",
|
||||
})
|
||||
salaryId: string;
|
||||
salaryId: string | null;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
|
|
@ -292,7 +293,7 @@ export class ProfileSalaryTemp extends EntityBase {
|
|||
})
|
||||
posNumCodeSitAbb: string;
|
||||
|
||||
@Column({
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 255,
|
||||
comment: "ด้านทางการบริหาร",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue