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