fix ปลดจากกิ่ง ยกเว้นคำสั่ง25 26
This commit is contained in:
parent
2f378fa4a1
commit
1b3f42fd85
2 changed files with 18 additions and 2 deletions
|
|
@ -39,6 +39,7 @@ import {
|
||||||
commandTypePath,
|
commandTypePath,
|
||||||
removeProfileInOrganize,
|
removeProfileInOrganize,
|
||||||
setLogDataDiff,
|
setLogDataDiff,
|
||||||
|
checkExceptCommandType,
|
||||||
checkCommandType,
|
checkCommandType,
|
||||||
} from "../interfaces/utils";
|
} from "../interfaces/utils";
|
||||||
import { Position } from "../entities/Position";
|
import { Position } from "../entities/Position";
|
||||||
|
|
@ -2113,7 +2114,7 @@ export class CommandController extends Controller {
|
||||||
// ประวัติตำแหน่ง
|
// ประวัติตำแหน่ง
|
||||||
const data = new ProfileSalary();
|
const data = new ProfileSalary();
|
||||||
const meta = {
|
const meta = {
|
||||||
profileId: item.profileId,
|
profileId: profile.id,
|
||||||
date: item.date,
|
date: item.date,
|
||||||
refCommandNo: item.refCommandNo,
|
refCommandNo: item.refCommandNo,
|
||||||
templateDoc: item.salaryRef,
|
templateDoc: item.salaryRef,
|
||||||
|
|
@ -2185,7 +2186,8 @@ 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) {
|
const exceptClear = await checkExceptCommandType(String(item.commandId));
|
||||||
|
if (item.isLeave == true && !exceptClear) {
|
||||||
await removeProfileInOrganize(profile.id, "OFFICER");
|
await removeProfileInOrganize(profile.id, "OFFICER");
|
||||||
}
|
}
|
||||||
const clearProfile = await checkCommandType(String(item.commandId));
|
const clearProfile = await checkCommandType(String(item.commandId));
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,20 @@ export async function removeProfileInOrganize(profileId: string, type: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function checkExceptCommandType(commandId: string) {
|
||||||
|
const commandRepository = AppDataSource.getRepository(Command);
|
||||||
|
const _type = await commandRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: commandId
|
||||||
|
},
|
||||||
|
relations: ["commandType"],
|
||||||
|
});
|
||||||
|
if (!["C-PM-25", "C-PM-26"].includes(String(_type?.commandType.code))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
export async function checkCommandType(commandId: string) {
|
export async function checkCommandType(commandId: string) {
|
||||||
const commandRepository = AppDataSource.getRepository(Command);
|
const commandRepository = AppDataSource.getRepository(Command);
|
||||||
const _type = await commandRepository.findOne({
|
const _type = await commandRepository.findOne({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue