This commit is contained in:
AdisakKanthawilang 2025-09-05 13:06:52 +07:00
parent 2a542e9f5c
commit 8f62a41db3

View file

@ -3540,10 +3540,29 @@ export class CommandController extends Controller {
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
profile.lastUpdatedAt = new Date();
const clearProfile = await checkCommandType(String(item.commandId));
//ปั๊มประวัติก่อนลบตำแหน่ง
const curRevition = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }
})
if(curRevition){
const curPosMaster = await this.posMasterRepository.findOne({
where:{
current_holderId: profile.id,
orgRevisionId: curRevition.id
}
})
if (curPosMaster && clearProfile.LeaveType != "RETIRE_OUT_EMP") {
await CreatePosMasterHistoryOfficer(curPosMaster.id, req);
}
}
//ลบตำแหน่ง
if (item.isLeave == true) {
await removeProfileInOrganize(profile.id, "OFFICER");
}
const clearProfile = await checkCommandType(String(item.commandId));
if (clearProfile.status) {
if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak);
@ -3601,7 +3620,7 @@ export class CommandController extends Controller {
positionNew.positionIsSelected = true;
await this.positionRepository.save(positionNew, { data: req });
}
// await CreatePosMasterHistoryOfficer(posMaster.id, req);
await CreatePosMasterHistoryOfficer(posMaster.id, req);
}
const newMapProfileSalary = {
profileId: profile.id,
@ -3706,11 +3725,6 @@ export class CommandController extends Controller {
profile.isActive = true;
}
await this.profileRepository.save(profile);
console.log("item>>>", item);
console.log("clearProfile.LeaveType >>>", clearProfile.LeaveType );
if (item.posmasterId && clearProfile.LeaveType != "RETIRE_OUT_EMP") {
await CreatePosMasterHistoryOfficer(item.posmasterId, req);
}
}),
);