diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 04de1aef..a9feeeb0 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -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;