#1409 แก้เป็นส่ง refId ของคำสั่งขอลาออกไปค้นที่ command ก่อนอัพ status = CANCEL

This commit is contained in:
Bright 2025-09-29 11:46:19 +07:00
parent c5b54d55de
commit 3961488b91

View file

@ -3466,6 +3466,7 @@ export class CommandController extends Controller {
orgChild2New?: string | null;
orgChild3New?: string | null;
orgChild4New?: string | null;
resignId?: string | null;
}[];
},
) {
@ -3530,6 +3531,19 @@ export class CommandController extends Controller {
if (code && ["C-PM-08", "C-PM-17", "C-PM-18"].includes(code)) {
removePostMasterAct(profile.id);
}
//ออกคำสั่งยกเลิกลาออกต้องอัพเดทสถานะคำสั่งลาออกเป็น CANCEL
else if (item.resignId && code && ["C-PM-41"].includes(code)) {
const commandRecive = await this.commandReciveRepository.findOne({
select: ["commandId"],
where: { refId: item.resignId },
});
if (commandRecive && commandRecive.commandId) {
await this.commandRepository.update(
{ id: commandRecive?.commandId },
{ status: "CANCEL" }
);
}
}
let _commandYear = item.commandYear;
if (item.commandYear) {
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
@ -3796,6 +3810,7 @@ export class CommandController extends Controller {
commandCode?: string | null;
commandName?: string | null;
remark: string | null;
resignId: string | null;
}[];
},
) {
@ -3851,6 +3866,20 @@ export class CommandController extends Controller {
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const code = _command?.commandType?.code;
//ออกคำสั่งยกเลิกลาออกต้องอัพเดทสถานะคำสั่งลาออกเป็น CANCEL
if (item.resignId && code && ["C-PM-42"].includes(code)) {
const commandRecive = await this.commandReciveRepository.findOne({
select: ["commandId"],
where: { refId: item.resignId },
});
if (commandRecive && commandRecive.commandId) {
await this.commandRepository.update(
{ id: commandRecive?.commandId },
{ status: "CANCEL" }
);
}
}
let _commandYear = item.commandYear;
if (item.commandYear) {
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;