อัตรากำลังลูกจ้างประจำ กรณีนั่งทับที่ต้องเป็นตำแหน่งจริง #2563
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s

This commit is contained in:
harid 2026-06-17 15:42:48 +07:00
parent db36b250e3
commit e6bdea2b20

View file

@ -12,6 +12,7 @@ import { Position } from "../entities/Position";
import { ProfileEducation } from "../entities/ProfileEducation";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { ProfileEmployee } from "../entities/ProfileEmployee";
/**
* function
@ -221,6 +222,7 @@ export async function CreatePosMasterHistoryEmployee(
await AppDataSource.transaction(async (manager) => {
const repoPosmaster = manager.getRepository(EmployeePosMaster);
const repoHistory = manager.getRepository(PosMasterEmployeeHistory);
const repoProfileEmployee = manager.getRepository(ProfileEmployee);
const pm = await repoPosmaster.findOne({
where: { id: posMasterId },
@ -245,15 +247,28 @@ export async function CreatePosMasterHistoryEmployee(
pm.positions.length > 0
? pm.positions.find((p) => p.positionIsSelected === true) ?? null
: null;
let position = selectedPosition?.positionName ?? _null;
let posTypeName = selectedPosition?.posType?.posTypeName ?? _null;
let posLevelName = selectedPosition?.posLevel?.posLevelName ?? _null;
if (pm.isSit && pm.current_holderId) {
const profile = await repoProfileEmployee.findOne({
where: { id: pm.current_holderId },
relations: ["posType", "posLevel"]
});
position = profile?.position ?? _null;
posTypeName = profile?.posType?.posTypeName ?? _null;
posLevelName = profile?.posLevel?.posLevelName ?? _null;
}
h.ancestorDNA = pm.ancestorDNA;
if (!type || type != "DELETE") {
h.profileEmployeeId = pm.current_holder?.id || _null;
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.position = position;
h.posType = posTypeName;
h.posLevel = posLevelName;
}
h.rootDnaId = pm.orgRoot?.ancestorDNA || _null;
h.child1DnaId = pm.orgChild1?.ancestorDNA || _null;