Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 58s

This commit is contained in:
Adisak 2025-11-12 18:05:17 +07:00
commit 4eff64113a

View file

@ -4266,12 +4266,22 @@ export class CommandController extends Controller {
body.data.map(async (item) => {
const profile: any = await this.profileRepository.findOne({
where: { id: item.profileId },
relations: ["roleKeycloaks"],
relations: ["roleKeycloaks","current_holders"],
});
if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
}
const orgRevision = await this.orgRevisionRepo.findOne({
where: {
orgRevisionIsCurrent: true,
orgRevisionIsDraft: false,
},
});
const orgRevisionRef =
profile?.current_holders?.find((x:any) => x.orgRevisionId == orgRevision?.id) ?? null;
//ลบตำแหน่งที่รักษาการแทน
const code = _command?.commandType?.code;
if (code && ["C-PM-13"].includes(code)) {
@ -4300,6 +4310,9 @@ export class CommandController extends Controller {
lastUpdatedAt: new Date(),
};
if (item.isLeave != undefined && item.isLeave == true) {
if(orgRevisionRef){
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE");
}
await removeProfileInOrganize(profile.id, "OFFICER");
}
const clearProfile = await checkCommandType(String(item.commandId));
@ -4628,8 +4641,8 @@ export class CommandController extends Controller {
orgRevisionIsDraft: false,
},
});
// const orgRevisionRef =
// profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
// const orgRootRef = orgRevisionRef?.orgRoot ?? null;
// const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
// const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
@ -4770,6 +4783,9 @@ export class CommandController extends Controller {
_profile.leaveDate = item.commandDateAffect ?? _null;
_profile.leaveType = exceptClear.LeaveType ?? _null;
} else {
if(orgRevisionRef){
await CreatePosMasterHistoryOfficer(orgRevisionRef.id, req, "DELETE");
}
await removeProfileInOrganize(_profile.id, "OFFICER");
}
}