From 3961488b917ca77c7e9bad16b62a15e631df7d15 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 29 Sep 2025 11:46:19 +0700 Subject: [PATCH] =?UTF-8?q?#1409=20=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=80?= =?UTF-8?q?=E0=B8=9B=E0=B9=87=E0=B8=99=E0=B8=AA=E0=B9=88=E0=B8=87=20refId?= =?UTF-8?q?=20=E0=B8=82=E0=B8=AD=E0=B8=87=E0=B8=84=E0=B8=B3=E0=B8=AA?= =?UTF-8?q?=E0=B8=B1=E0=B9=88=E0=B8=87=E0=B8=82=E0=B8=AD=E0=B8=A5=E0=B8=B2?= =?UTF-8?q?=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B9=84=E0=B8=9B=E0=B8=84=E0=B9=89?= =?UTF-8?q?=E0=B8=99=E0=B8=97=E0=B8=B5=E0=B9=88=20command=20=E0=B8=81?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=99=E0=B8=AD=E0=B8=B1=E0=B8=9E=20status?= =?UTF-8?q?=20=3D=20CANCEL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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;