insert profileSalary เดิมเข้ามายัง profile ใหม่ #232
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m8s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m8s
This commit is contained in:
parent
d82cd842f6
commit
58afa49fcd
1 changed files with 23 additions and 0 deletions
|
|
@ -6510,6 +6510,7 @@ export class CommandController extends Controller {
|
|||
relations: ["roleKeycloaks", "profileInsignias", "profileAvatars"],
|
||||
});
|
||||
let _oldInsigniaIds: string[] = [];
|
||||
let _oldSalaries: any[] = [];
|
||||
//ลูกจ้างประจำ หรือ บุคคลภายนอก
|
||||
if (!profile) {
|
||||
//กรณีลูกจ้างประจำมาสอบเป็นข้าราชการ ต้อง update สถานะโปรไฟล์เดิม
|
||||
|
|
@ -6618,6 +6619,11 @@ export class CommandController extends Controller {
|
|||
profile.isLeave &&
|
||||
["PLACEMENT_TRANSFER", "RETIRE_RESIGN"].includes(profile.leaveType)
|
||||
) {
|
||||
//ดึง profileSalary เดิม
|
||||
_oldSalaries = await this.salaryRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
if (profile.profileInsignias.length > 0) {
|
||||
_oldInsigniaIds = profile.profileInsignias?.map((x: any) => x.id) ?? [];
|
||||
}
|
||||
|
|
@ -6856,6 +6862,23 @@ export class CommandController extends Controller {
|
|||
await this.profileFamilyMotherHistoryRepo.save(motherHistory, { data: req });
|
||||
}
|
||||
//Salary
|
||||
//insert profileSalary อันเก่า กรณีพ้นราชการแล้วกลับมาบรรจุ
|
||||
if (_oldSalaries.length > 0) {
|
||||
await Promise.all(
|
||||
_oldSalaries.map(async (oldSal) => {
|
||||
const profileSal: any = new ProfileSalary();
|
||||
Object.assign(profileSal, { ...oldSal, ...meta });
|
||||
const salaryHistory = new ProfileSalaryHistory();
|
||||
Object.assign(salaryHistory, { ...profileSal, id: undefined });
|
||||
profileSal.profileId = profile.id;
|
||||
await this.salaryRepo.save(profileSal, { data: req });
|
||||
setLogDataDiff(req, { before, after: profileSal });
|
||||
salaryHistory.profileSalaryId = profileSal.id;
|
||||
await this.salaryHistoryRepo.save(salaryHistory, { data: req });
|
||||
}),
|
||||
);
|
||||
}
|
||||
//insert item.bodySalarys ต่อจากที่ insert เดิมไปแล้ว
|
||||
if (item.bodySalarys && item.bodySalarys != null) {
|
||||
const dest_item = await this.salaryRepo.findOne({
|
||||
where: { profileId: profile.id },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue