เพิ่มแสดงเหตุผลการพ้นจากราชการในทะเบียนประวัติ #1240

This commit is contained in:
Bright 2025-01-27 17:50:21 +07:00
parent 03a7b45aa3
commit b2c8bdecf3
4 changed files with 90 additions and 10 deletions

View file

@ -2561,7 +2561,7 @@ export class CommandController extends Controller {
await removeProfileInOrganize(profile.id, "OFFICER"); await removeProfileInOrganize(profile.id, "OFFICER");
} }
const clearProfile = await checkCommandType(String(item.commandId)); const clearProfile = await checkCommandType(String(item.commandId));
if (clearProfile) { if (clearProfile.status) {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
@ -2570,6 +2570,11 @@ export class CommandController extends Controller {
profile.isActive = false; profile.isActive = false;
} }
} }
profile.leaveCommandId = item.commandId ?? _null;
profile.leaveCommandNo = item.refCommandNo ?? _null;
profile.leaveRemark = clearProfile.leaveRemark ?? _null;
profile.leaveDate = item.date ?? _null;
profile.leaveType = clearProfile.LeaveType ?? _null;
profile.position = _null; profile.position = _null;
profile.posTypeId = _null; profile.posTypeId = _null;
profile.posLevelId = _null; profile.posLevelId = _null;
@ -2715,7 +2720,7 @@ export class CommandController extends Controller {
await removeProfileInOrganize(profile.id, "EMPLOYEE"); await removeProfileInOrganize(profile.id, "EMPLOYEE");
} }
const clearProfile = await checkCommandType(String(item.commandId)); const clearProfile = await checkCommandType(String(item.commandId));
if (clearProfile) { if (clearProfile.status) {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
@ -2724,6 +2729,11 @@ export class CommandController extends Controller {
profile.isActive = false; profile.isActive = false;
} }
} }
profile.leaveCommandId = item.commandId ?? _null;
profile.leaveCommandNo = item.refCommandNo ?? _null;
profile.leaveRemark = clearProfile.leaveRemark ?? _null;
profile.leaveDate = item.date ?? _null;
profile.leaveType = clearProfile.LeaveType ?? _null;
profile.position = _null; profile.position = _null;
profile.posTypeId = _null; profile.posTypeId = _null;
profile.posLevelId = _null; profile.posLevelId = _null;
@ -2803,7 +2813,7 @@ export class CommandController extends Controller {
} }
const clearProfile = await checkCommandType(String(item.commandId)); const clearProfile = await checkCommandType(String(item.commandId));
const _null: any = null; const _null: any = null;
if (clearProfile) { if (clearProfile.status) {
if (profile.keycloak != null) { if (profile.keycloak != null) {
const delUserKeycloak = await deleteUser(profile.keycloak); const delUserKeycloak = await deleteUser(profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
@ -2812,6 +2822,11 @@ export class CommandController extends Controller {
profile.isActive = false; profile.isActive = false;
} }
} }
profile.leaveCommandId = item.commandId ?? _null;
profile.leaveCommandNo = item.refCommandNo ?? _null;
profile.leaveRemark = clearProfile.leaveRemark ?? _null;
profile.leaveDate = item.date ?? _null;
profile.leaveType = clearProfile.LeaveType ?? _null;
profile.position = _null; profile.position = _null;
profile.posTypeId = _null; profile.posTypeId = _null;
profile.posLevelId = _null; profile.posLevelId = _null;
@ -3110,7 +3125,7 @@ export class CommandController extends Controller {
} }
} }
const clearProfile = await checkCommandType(String(item.commandId)); const clearProfile = await checkCommandType(String(item.commandId));
if (clearProfile) { if (clearProfile.status) {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
@ -3119,6 +3134,11 @@ export class CommandController extends Controller {
_profile.isActive = false; _profile.isActive = false;
} }
} }
_profile.leaveCommandId = item.commandId ?? _null;
_profile.leaveCommandNo = item.refCommandNo ?? _null;
_profile.leaveRemark = clearProfile.leaveRemark ?? _null;
_profile.leaveDate = item.date ?? _null;
_profile.leaveType = clearProfile.LeaveType ?? _null;
_profile.position = _null; _profile.position = _null;
_profile.posTypeId = _null; _profile.posTypeId = _null;
_profile.posLevelId = _null; _profile.posLevelId = _null;
@ -3299,7 +3319,7 @@ export class CommandController extends Controller {
} }
} }
const clearProfile = await checkCommandType(String(item.commandId)); const clearProfile = await checkCommandType(String(item.commandId));
if (clearProfile) { if (clearProfile.status) {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
@ -3308,6 +3328,11 @@ export class CommandController extends Controller {
_profile.isActive = false; _profile.isActive = false;
} }
} }
_profile.leaveCommandId = item.commandId ?? _null;
_profile.leaveCommandNo = item.refCommandNo ?? _null;
_profile.leaveRemark = clearProfile.leaveRemark ?? _null;
_profile.leaveDate = item.date ?? _null;
_profile.leaveType = clearProfile.LeaveType ?? _null;
_profile.position = _null; _profile.position = _null;
_profile.posTypeId = _null; _profile.posTypeId = _null;
_profile.posLevelId = _null; _profile.posLevelId = _null;
@ -3524,7 +3549,7 @@ export class CommandController extends Controller {
} }
} }
const clearProfile = await checkCommandType(String(item.commandId)); const clearProfile = await checkCommandType(String(item.commandId));
if (clearProfile) { if (clearProfile.status) {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
@ -3533,6 +3558,11 @@ export class CommandController extends Controller {
_profile.isActive = false; _profile.isActive = false;
} }
} }
_profile.leaveCommandId = item.commandId ?? _null;
_profile.leaveCommandNo = item.refCommandNo ?? _null;
_profile.leaveRemark = clearProfile.leaveRemark ?? _null;
_profile.leaveDate = item.date ?? _null;
_profile.leaveType = clearProfile.LeaveType ?? _null;
_profile.position = _null; _profile.position = _null;
_profile.posTypeId = _null; _profile.posTypeId = _null;
_profile.posLevelId = _null; _profile.posLevelId = _null;
@ -3851,7 +3881,7 @@ export class CommandController extends Controller {
await removeProfileInOrganize(profile.id, "OFFICER"); await removeProfileInOrganize(profile.id, "OFFICER");
const clearProfile = await checkCommandType(String(item.commandId)); const clearProfile = await checkCommandType(String(item.commandId));
const _null: any = null; const _null: any = null;
if (clearProfile) { if (clearProfile.status) {
if (_profile.keycloak != null) { if (_profile.keycloak != null) {
const delUserKeycloak = await deleteUser(_profile.keycloak); const delUserKeycloak = await deleteUser(_profile.keycloak);
if (delUserKeycloak) { if (delUserKeycloak) {
@ -3860,6 +3890,11 @@ export class CommandController extends Controller {
_profile.isActive = false; _profile.isActive = false;
} }
} }
_profile.leaveCommandId = item.commandId ?? _null;
_profile.leaveCommandNo = item.refCommandNo ?? _null;
_profile.leaveRemark = clearProfile.leaveRemark ?? _null;
_profile.leaveDate = item.date ?? _null;
_profile.leaveType = clearProfile.LeaveType ?? _null;
_profile.position = _null; _profile.position = _null;
_profile.posTypeId = _null; _profile.posTypeId = _null;
_profile.posLevelId = _null; _profile.posLevelId = _null;

View file

@ -8263,6 +8263,7 @@ export class ProfileController extends Controller {
if (requestBody.isLeave == true) { if (requestBody.isLeave == true) {
await removeProfileInOrganize(profile.id, "OFFICER"); await removeProfileInOrganize(profile.id, "OFFICER");
} }
profile.leaveType = "RETIRE_DECEASED";
await this.profileRepo.save(profile, { data: request }); await this.profileRepo.save(profile, { data: request });
setLogDataDiff(request, { before, after: profile }); setLogDataDiff(request, { before, after: profile });

View file

@ -3871,6 +3871,7 @@ export class ProfileEmployeeController extends Controller {
if (requestBody.isLeave == true) { if (requestBody.isLeave == true) {
await removeProfileInOrganize(profile.id, "EMPLOYEE"); await removeProfileInOrganize(profile.id, "EMPLOYEE");
} }
profile.leaveType = "RETIRE_DECEASED";
await this.profileRepo.save(profile); await this.profileRepo.save(profile);
return new HttpSuccess(); return new HttpSuccess();

View file

@ -10,6 +10,7 @@ import { Command } from "../entities/Command";
import { ProfileSalary } from "../entities/ProfileSalary"; import { ProfileSalary } from "../entities/ProfileSalary";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import { CommandRecive } from "../entities/CommandRecive";
export function calculateAge(start: Date, end = new Date()) { export function calculateAge(start: Date, end = new Date()) {
if (start.getTime() > end.getTime()) return null; if (start.getTime() > end.getTime()) return null;
@ -347,20 +348,62 @@ export async function checkExceptCommandType(commandId: string) {
export async function checkCommandType(commandId: string) { export async function checkCommandType(commandId: string) {
const commandRepository = AppDataSource.getRepository(Command); const commandRepository = AppDataSource.getRepository(Command);
const commandReciveRepository = AppDataSource.getRepository(CommandRecive)
const _type = await commandRepository.findOne({ const _type = await commandRepository.findOne({
where: { where: {
id: commandId, id: commandId,
}, },
relations: ["commandType"], relations: ["commandType", "commandRecives"],
}); });
if ( if (
!["C-PM-12", "C-PM-13", "C-PM-17", "C-PM-18", "C-PM-23", "C-PM-19", "C-PM-20"].includes( !["C-PM-12", "C-PM-13", "C-PM-17", "C-PM-18", "C-PM-23", "C-PM-19", "C-PM-20"].includes(
String(_type?.commandType.code), String(_type?.commandType.code),
) )
) { ) {
return false; // return false;
return { status: false, LeaveType: null, leaveRemark: null};
} }
return true; // return true;
const _commandRecive = await commandReciveRepository.findOne({
where: { commandId: commandId }
});
let _leaveType: string =""
switch(String(_type?.commandType.code)){
case "C-PM-12" : {
_leaveType = "PROBATION_REPORT";
break;
}
case "C-PM-13" : {
_leaveType = "PLACEMENT_TRANSFER";
break;
}
case "C-PM-17" : {
_leaveType = "RETIRE_RESIGN";
break;
}
case "C-PM-18" : {
_leaveType = "RETIRE_OUT";
break;
}
case "C-PM-19" : {
_leaveType = "DISCIPLINE_RESULT_REMOVE";
break;
}
case "C-PM-20" : {
_leaveType = "DISCIPLINE_RESULT_DISMISS";
break;
}
case "C-PM-23" : {
_leaveType = "RETIRE_RESIGN_EMP";
break;
}
default: {
_leaveType = ""
}
}
return { status: true, LeaveType: _leaveType, leaveRemark: _commandRecive ? _commandRecive.remarkVertical : null };
} }
//logs //logs