update 2473
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m2s

This commit is contained in:
Adisak 2026-05-11 13:25:26 +07:00
parent b000e8b531
commit 7a6cf119bd
3 changed files with 12 additions and 9 deletions

View file

@ -4565,7 +4565,7 @@ export class CommandController extends Controller {
orgChild3Ref = curPosMaster?.orgChild3 ?? null;
orgChild4Ref = curPosMaster?.orgChild4 ?? null;
if (curPosMaster) {
await CreatePosMasterHistoryEmployee(curPosMaster.id, req);
await CreatePosMasterHistoryEmployee(curPosMaster.id, req, "DELETE");
}
}
@ -5792,7 +5792,7 @@ export class CommandController extends Controller {
},
});
if (curPosMaster) {
await CreatePosMasterHistoryEmployee(curPosMaster.id, req);
await CreatePosMasterHistoryEmployee(curPosMaster.id, req, "DELETE");
}
}
await removeProfileInOrganize(_profile.id, "EMPLOYEE");

View file

@ -5784,7 +5784,7 @@ export class ProfileEmployeeController extends Controller {
await this.profileRepo.save(profile);
if (requestBody.isLeave == true) {
if (orgRevisionRef) {
await CreatePosMasterHistoryEmployee(orgRevisionRef.id, request);
await CreatePosMasterHistoryEmployee(orgRevisionRef.id, request, "DELETE");
}
await removeProfileInOrganize(profile.id, "EMPLOYEE");
}

View file

@ -137,6 +137,7 @@ export async function CreatePosMasterHistoryOfficer(
export async function CreatePosMasterHistoryEmployee(
posMasterId: string,
request: RequestWithUser | null,
type?: string | null,
): Promise<boolean> {
try {
await AppDataSource.transaction(async (manager) => {
@ -167,15 +168,17 @@ export async function CreatePosMasterHistoryEmployee(
? pm.positions.find((p) => p.positionIsSelected === true) ?? null
: null;
h.ancestorDNA = pm.ancestorDNA;
h.prefix = pm.current_holder?.prefix || _null;
h.firstName = pm.current_holder?.firstName || _null;
h.lastName = pm.current_holder?.lastName || _null;
if (!type || type != "DELETE") {
h.prefix = pm.current_holder?.prefix || _null;
h.firstName = pm.current_holder?.firstName || _null;
h.lastName = pm.current_holder?.lastName || _null;
h.position = selectedPosition?.positionName ?? _null;
h.posType = selectedPosition?.posType?.posTypeName ?? _null;
h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null;
}
h.posMasterNoPrefix = pm.posMasterNoPrefix ?? _null;
h.posMasterNo = pm.posMasterNo ?? _null;
h.posMasterNoSuffix = pm.posMasterNoSuffix ?? _null;
h.position = selectedPosition?.positionName ?? _null;
h.posType = selectedPosition?.posType?.posTypeName ?? _null;
h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null;
h.shortName =
[
pm.orgChild4?.orgChild4ShortName,