ให้ออกจากราชการ
This commit is contained in:
parent
3edc66081f
commit
f4180cbfdf
1 changed files with 60 additions and 39 deletions
|
|
@ -88,29 +88,29 @@ export async function calculateGovAge(profileId: string, type: string) {
|
|||
|
||||
return { years, months, days };
|
||||
};
|
||||
let profile:any;
|
||||
let profile: any;
|
||||
profile = await AppDataSource.getRepository(Profile).findOne({
|
||||
where:{
|
||||
id:profileId
|
||||
}
|
||||
})
|
||||
if(isEmployee){
|
||||
where: {
|
||||
id: profileId,
|
||||
},
|
||||
});
|
||||
if (isEmployee) {
|
||||
profile = await AppDataSource.getRepository(ProfileEmployee).findOne({
|
||||
where:{
|
||||
id:profileId
|
||||
}
|
||||
})
|
||||
where: {
|
||||
id: profileId,
|
||||
},
|
||||
});
|
||||
}
|
||||
// const firstStartDate = new Date(records[0].date);
|
||||
const firstStartDate = profile?.dateAppoint ? profile?.dateAppoint : new Date();
|
||||
const firstEndDate = endDateFristRec ? new Date(endDateFristRec.dateGovernment) : new Date();
|
||||
|
||||
|
||||
const {
|
||||
years: totalYears1,
|
||||
months: totalMonths1,
|
||||
days: totalDays1,
|
||||
} = calculateDuration(firstStartDate, firstEndDate);
|
||||
|
||||
|
||||
const records_middle = await AppDataSource.getRepository(ProfileSalary).find({
|
||||
where: {
|
||||
[isEmployee ? "profileEmployeeId" : "profileId"]: profileId,
|
||||
|
|
@ -334,7 +334,7 @@ export async function checkReturnCommandType(commandId: string) {
|
|||
|
||||
export async function checkExceptCommandType(commandId: string) {
|
||||
const commandRepository = AppDataSource.getRepository(Command);
|
||||
const commandReciveRepository = AppDataSource.getRepository(CommandRecive)
|
||||
const commandReciveRepository = AppDataSource.getRepository(CommandRecive);
|
||||
const _type = await commandRepository.findOne({
|
||||
where: {
|
||||
id: commandId,
|
||||
|
|
@ -342,87 +342,106 @@ export async function checkExceptCommandType(commandId: string) {
|
|||
relations: ["commandType"],
|
||||
});
|
||||
if (!["C-PM-25", "C-PM-26"].includes(String(_type?.commandType.code))) {
|
||||
return { status: false, LeaveType: null, leaveRemark: null};
|
||||
return { status: false, LeaveType: null, leaveRemark: null };
|
||||
}
|
||||
const _commandRecive = await commandReciveRepository.findOne({
|
||||
where: { commandId: commandId }
|
||||
where: { commandId: commandId },
|
||||
});
|
||||
|
||||
let _leaveType: string =""
|
||||
switch(String(_type?.commandType.code)){
|
||||
case "C-PM-25" : {
|
||||
let _leaveType: string = "";
|
||||
switch (String(_type?.commandType.code)) {
|
||||
case "C-PM-25": {
|
||||
_leaveType = "DISCIPLINE_SUSPEND"; //คำสั่งพักจากราชการ
|
||||
break;
|
||||
}
|
||||
case "C-PM-26" : {
|
||||
case "C-PM-26": {
|
||||
_leaveType = "DISCIPLINE_SUSPEND"; //คำสั่งให้ออกจากราชการไว้ก่อน
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
_leaveType = ""
|
||||
_leaveType = "";
|
||||
}
|
||||
}
|
||||
return { status: true, LeaveType: _leaveType, leaveRemark: _commandRecive ? _commandRecive.remarkVertical : null };
|
||||
return {
|
||||
status: true,
|
||||
LeaveType: _leaveType,
|
||||
leaveRemark: _commandRecive ? _commandRecive.remarkVertical : null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function checkCommandType(commandId: string) {
|
||||
const commandRepository = AppDataSource.getRepository(Command);
|
||||
const commandReciveRepository = AppDataSource.getRepository(CommandRecive)
|
||||
const commandReciveRepository = AppDataSource.getRepository(CommandRecive);
|
||||
const _type = await commandRepository.findOne({
|
||||
where: {
|
||||
id: commandId,
|
||||
},
|
||||
relations: ["commandType", "commandRecives"],
|
||||
});
|
||||
|
||||
|
||||
if (
|
||||
!["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),
|
||||
)
|
||||
![
|
||||
"C-PM-12",
|
||||
"C-PM-13",
|
||||
"C-PM-17",
|
||||
"C-PM-18",
|
||||
"C-PM-23",
|
||||
"C-PM-19",
|
||||
"C-PM-20",
|
||||
"C-PM-43",
|
||||
].includes(String(_type?.commandType.code))
|
||||
) {
|
||||
// return false;
|
||||
return { status: false, LeaveType: null, leaveRemark: null};
|
||||
return { status: false, LeaveType: null, leaveRemark: null };
|
||||
}
|
||||
// return true;
|
||||
const _commandRecive = await commandReciveRepository.findOne({
|
||||
where: { commandId: commandId }
|
||||
where: { commandId: commandId },
|
||||
});
|
||||
|
||||
let _leaveType: string =""
|
||||
switch(String(_type?.commandType.code)){
|
||||
case "C-PM-12" : {
|
||||
let _leaveType: string = "";
|
||||
switch (String(_type?.commandType.code)) {
|
||||
case "C-PM-12": {
|
||||
_leaveType = "PROBATION_REPORT";
|
||||
break;
|
||||
}
|
||||
case "C-PM-13" : {
|
||||
case "C-PM-13": {
|
||||
_leaveType = "PLACEMENT_TRANSFER";
|
||||
break;
|
||||
}
|
||||
case "C-PM-17" : {
|
||||
case "C-PM-17": {
|
||||
_leaveType = "RETIRE_RESIGN";
|
||||
break;
|
||||
}
|
||||
case "C-PM-18" : {
|
||||
case "C-PM-18": {
|
||||
_leaveType = "RETIRE_OUT";
|
||||
break;
|
||||
}
|
||||
case "C-PM-19" : {
|
||||
case "C-PM-19": {
|
||||
_leaveType = "DISCIPLINE_RESULT_REMOVE";
|
||||
break;
|
||||
}
|
||||
case "C-PM-20" : {
|
||||
case "C-PM-20": {
|
||||
_leaveType = "DISCIPLINE_RESULT_DISMISS";
|
||||
break;
|
||||
}
|
||||
case "C-PM-23" : {
|
||||
case "C-PM-23": {
|
||||
_leaveType = "RETIRE_RESIGN_EMP";
|
||||
break;
|
||||
}
|
||||
case "C-PM-43": {
|
||||
_leaveType = "RETIRE_OUT_EMP";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
_leaveType = ""
|
||||
_leaveType = "";
|
||||
}
|
||||
}
|
||||
return { status: true, LeaveType: _leaveType, leaveRemark: _commandRecive ? _commandRecive.remarkVertical : null };
|
||||
return {
|
||||
status: true,
|
||||
LeaveType: _leaveType,
|
||||
leaveRemark: _commandRecive ? _commandRecive.remarkVertical : null,
|
||||
};
|
||||
}
|
||||
|
||||
//logs
|
||||
|
|
@ -548,6 +567,8 @@ export function commandTypePath(commandCode: string): string | null {
|
|||
return "/retirement/resign/leave-cancel/report";
|
||||
case "C-PM-42":
|
||||
return "/retirement/resign-employee/leave-cancel/report";
|
||||
case "C-PM-43":
|
||||
return "/retirement/out/command/report";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue