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.lastUpdateUserId = req.user.sub;
|
||||||
profile.lastUpdateFullName = req.user.name;
|
profile.lastUpdateFullName = req.user.name;
|
||||||
profile.lastUpdatedAt = new Date();
|
profile.lastUpdatedAt = new Date();
|
||||||
if (item.isLeave == true) {
|
// บันทึกประวัติก่อนลบตำแหน่ง
|
||||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
|
||||||
}
|
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
const curRevision = await this.orgRevisionRepo.findOne({
|
const curRevision = await this.orgRevisionRepo.findOne({
|
||||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
|
|
@ -4566,6 +4564,14 @@ export class CommandController extends Controller {
|
||||||
orgChild2Ref = curPosMaster?.orgChild2 ?? null;
|
orgChild2Ref = curPosMaster?.orgChild2 ?? null;
|
||||||
orgChild3Ref = curPosMaster?.orgChild3 ?? null;
|
orgChild3Ref = curPosMaster?.orgChild3 ?? null;
|
||||||
orgChild4Ref = curPosMaster?.orgChild4 ?? 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) {
|
if (clearProfile.status) {
|
||||||
|
|
@ -5774,6 +5780,21 @@ export class CommandController extends Controller {
|
||||||
_profile.leaveDate = item.commandDateAffect ?? _null;
|
_profile.leaveDate = item.commandDateAffect ?? _null;
|
||||||
_profile.leaveType = exceptClear.LeaveType ?? _null;
|
_profile.leaveType = exceptClear.LeaveType ?? _null;
|
||||||
} else {
|
} 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");
|
await removeProfileInOrganize(_profile.id, "EMPLOYEE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ import { ProfileAssistance } from "../entities/ProfileAssistance";
|
||||||
import { ProfileChangeName } from "../entities/ProfileChangeName";
|
import { ProfileChangeName } from "../entities/ProfileChangeName";
|
||||||
import { ProfileChildren } from "../entities/ProfileChildren";
|
import { ProfileChildren } from "../entities/ProfileChildren";
|
||||||
import { ProfileDuty } from "../entities/ProfileDuty";
|
import { ProfileDuty } from "../entities/ProfileDuty";
|
||||||
import { getTopDegrees } from "../services/PositionService";
|
import { CreatePosMasterHistoryEmployee, getTopDegrees } from "../services/PositionService";
|
||||||
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
import { ProfileLeaveService } from "../services/ProfileLeaveService";
|
||||||
import { CommandCode } from "../entities/CommandCode";
|
import { CommandCode } from "../entities/CommandCode";
|
||||||
@Route("api/v1/org/profile-employee")
|
@Route("api/v1/org/profile-employee")
|
||||||
|
|
@ -5783,6 +5783,9 @@ export class ProfileEmployeeController extends Controller {
|
||||||
}
|
}
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
if (requestBody.isLeave == true) {
|
if (requestBody.isLeave == true) {
|
||||||
|
if (orgRevisionRef) {
|
||||||
|
await CreatePosMasterHistoryEmployee(orgRevisionRef.id, request, "DELETE");
|
||||||
|
}
|
||||||
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
await removeProfileInOrganize(profile.id, "EMPLOYEE");
|
||||||
}
|
}
|
||||||
let organizeName = "";
|
let organizeName = "";
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
export async function CreatePosMasterHistoryEmployee(
|
export async function CreatePosMasterHistoryEmployee(
|
||||||
posMasterId: string,
|
posMasterId: string,
|
||||||
request: RequestWithUser | null,
|
request: RequestWithUser | null,
|
||||||
|
type?: string | null,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await AppDataSource.transaction(async (manager) => {
|
await AppDataSource.transaction(async (manager) => {
|
||||||
|
|
@ -167,15 +168,17 @@ export async function CreatePosMasterHistoryEmployee(
|
||||||
? pm.positions.find((p) => p.positionIsSelected === true) ?? null
|
? pm.positions.find((p) => p.positionIsSelected === true) ?? null
|
||||||
: null;
|
: null;
|
||||||
h.ancestorDNA = pm.ancestorDNA;
|
h.ancestorDNA = pm.ancestorDNA;
|
||||||
h.prefix = pm.current_holder?.prefix || _null;
|
if (!type || type != "DELETE") {
|
||||||
h.firstName = pm.current_holder?.firstName || _null;
|
h.prefix = pm.current_holder?.prefix || _null;
|
||||||
h.lastName = pm.current_holder?.lastName || _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.posMasterNoPrefix = pm.posMasterNoPrefix ?? _null;
|
||||||
h.posMasterNo = pm.posMasterNo ?? _null;
|
h.posMasterNo = pm.posMasterNo ?? _null;
|
||||||
h.posMasterNoSuffix = pm.posMasterNoSuffix ?? _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 =
|
h.shortName =
|
||||||
[
|
[
|
||||||
pm.orgChild4?.orgChild4ShortName,
|
pm.orgChild4?.orgChild4ShortName,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue