Merge branch 'develop' into develop-Bright
This commit is contained in:
commit
53d0f79126
3 changed files with 37 additions and 10 deletions
|
|
@ -4535,9 +4535,7 @@ export class CommandController extends Controller {
|
|||
profile.lastUpdateUserId = req.user.sub;
|
||||
profile.lastUpdateFullName = req.user.name;
|
||||
profile.lastUpdatedAt = new Date();
|
||||
if (item.isLeave == true) {
|
||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||
}
|
||||
// บันทึกประวัติก่อนลบตำแหน่ง
|
||||
const clearProfile = await checkCommandType(String(item.commandId));
|
||||
const curRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
|
|
@ -4566,6 +4564,14 @@ export class CommandController extends Controller {
|
|||
orgChild2Ref = curPosMaster?.orgChild2 ?? null;
|
||||
orgChild3Ref = curPosMaster?.orgChild3 ?? null;
|
||||
orgChild4Ref = curPosMaster?.orgChild4 ?? null;
|
||||
if (curPosMaster) {
|
||||
await CreatePosMasterHistoryEmployee(curPosMaster.id, req, "DELETE");
|
||||
}
|
||||
}
|
||||
|
||||
// ลบตำแหน่ง
|
||||
if (item.isLeave == true) {
|
||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||
}
|
||||
|
||||
if (clearProfile.status) {
|
||||
|
|
@ -5774,6 +5780,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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ import { ProfileAssistance } from "../entities/ProfileAssistance";
|
|||
import { ProfileChangeName } from "../entities/ProfileChangeName";
|
||||
import { ProfileChildren } from "../entities/ProfileChildren";
|
||||
import { ProfileDuty } from "../entities/ProfileDuty";
|
||||
import { getTopDegrees } from "../services/PositionService";
|
||||
import { CreatePosMasterHistoryEmployee, getTopDegrees } from "../services/PositionService";
|
||||
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
||||
import { CommandCode } from "../entities/CommandCode";
|
||||
@Route("api/v1/org/profile-employee")
|
||||
|
|
@ -5783,6 +5783,9 @@ export class ProfileEmployeeController extends Controller {
|
|||
}
|
||||
await this.profileRepo.save(profile);
|
||||
if (requestBody.isLeave == true) {
|
||||
if (orgRevisionRef) {
|
||||
await CreatePosMasterHistoryEmployee(orgRevisionRef.id, request, "DELETE");
|
||||
}
|
||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||
}
|
||||
let organizeName = "";
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue