From 378c941a0128c124cf5309b562a3b6821f08ab09 Mon Sep 17 00:00:00 2001 From: Adisak Date: Mon, 11 May 2026 14:33:50 +0700 Subject: [PATCH] fix: command C-PM-20 insert history --- src/controllers/CommandController.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index ca82faa3..232d2689 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -5450,6 +5450,21 @@ export class CommandController extends Controller { _profile.leaveDate = item.commandDateAffect ?? _null; _profile.leaveType = exceptClear.LeaveType ?? _null; } else { + // บันทึกประวัติก่อนลบตำแหน่ง + const curRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, + }); + if (curRevision) { + const curPosMaster = await this.employeePosMasterRepository.findOne({ + where: { + current_holderId: _profile.id, + orgRevisionId: curRevision.id, + }, + }); + if (curPosMaster) { + await CreatePosMasterHistoryEmployee(curPosMaster.id, req, "DELETE"); + } + } await removeProfileInOrganize(_profile.id, "EMPLOYEE"); } }