ออกคำสั่งลูกจ้างชั่วคราว

This commit is contained in:
Kittapath 2024-06-12 12:52:12 +07:00
parent 576f83d12f
commit f1cdec9076

View file

@ -18,7 +18,7 @@ import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { Brackets, IsNull, Like, Not } from "typeorm";
import { Brackets, In, IsNull, Like, Not } from "typeorm";
import { OrgRevision } from "../entities/OrgRevision";
import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
@ -557,10 +557,10 @@ export class ProfileEmployeeController extends Controller {
const exists =
!!body.citizenId &&
(await this.profileRepo.findOne({
where: {
id: Not(id),
citizenId: body.citizenId,
employeeClass: String(body.employeeClass)
where: {
id: Not(id),
citizenId: body.citizenId,
employeeClass: String(body.employeeClass),
},
}));
@ -690,12 +690,12 @@ export class ProfileEmployeeController extends Controller {
: _data.current_holders[0].orgRoot != null
? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}`
: null;
const dateEmployment =
const dateEmployment =
_data.profileEmployeeEmployment.length == 0
? null
: _data.profileEmployeeEmployment.reduce((latest, current) => {
return (latest.date > current.date) ? latest : current;
}).date;
return latest.date > current.date ? latest : current;
}).date;
return {
id: _data.id,
prefix: _data.prefix,
@ -933,12 +933,12 @@ export class ProfileEmployeeController extends Controller {
: _data.current_holders[0].orgRoot != null
? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}`
: null;
const dateEmployment =
const dateEmployment =
_data.profileEmployeeEmployment.length == 0
? null
: _data.profileEmployeeEmployment.reduce((latest, current) => {
return (latest.date > current.date) ? latest : current;
}).date;
return latest.date > current.date ? latest : current;
}).date;
return {
id: _data.id,
prefix: _data.prefix,
@ -2569,33 +2569,33 @@ export class ProfileEmployeeController extends Controller {
/**
* API
*
* @summary (ADMIN)
* @summary (ADMIN)
*
* @param {string} profileEmployeeId profileEmployeeId
*/
@Get("information/{profileEmployeeId}")
async getInformationById(@Path() profileEmployeeId: string) {
const profileInformation = await this.profileRepo.findOne({
where: { id: profileEmployeeId }
where: { id: profileEmployeeId },
});
if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const mapData = {
id: profileInformation.id,
positionEmployeeGroupId: profileInformation.positionEmployeeGroupId,
positionEmployeeLineId: profileInformation.positionEmployeeLineId,
positionEmployeePositionId: profileInformation.positionEmployeePositionId,
employeeOc: profileInformation.employeeOc,
employeeTypeIndividual: profileInformation.employeeTypeIndividual,
employeeWage: profileInformation.employeeWage,
employeeMoneyIncrease: profileInformation.employeeMoneyIncrease,
employeeMoneyAllowance: profileInformation.employeeMoneyAllowance,
employeeMoneyEmployee: profileInformation.employeeMoneyEmployee,
employeeMoneyEmployer: profileInformation.employeeMoneyEmployer,
id: profileInformation.id,
positionEmployeeGroupId: profileInformation.positionEmployeeGroupId,
positionEmployeeLineId: profileInformation.positionEmployeeLineId,
positionEmployeePositionId: profileInformation.positionEmployeePositionId,
employeeOc: profileInformation.employeeOc,
employeeTypeIndividual: profileInformation.employeeTypeIndividual,
employeeWage: profileInformation.employeeWage,
employeeMoneyIncrease: profileInformation.employeeMoneyIncrease,
employeeMoneyAllowance: profileInformation.employeeMoneyAllowance,
employeeMoneyEmployee: profileInformation.employeeMoneyEmployee,
employeeMoneyEmployer: profileInformation.employeeMoneyEmployer,
};
return new HttpSuccess(mapData);
}
/**
* API
*
@ -2781,4 +2781,28 @@ export class ProfileEmployeeController extends Controller {
return new HttpSuccess();
}
/**
* API
*
* @summary ORG_038 - (ADMIN) #
*
*/
@Post("report")
async sendReport(@Request() request: RequestWithUser, @Body() requestBody: { id: string[] }) {
const profiles = await this.profileRepo.find({ where: { id: In(requestBody.id) } });
const _profiles = await Promise.all(
profiles.map(async (item: any) => {
return {
...item,
statusTemp: "REPORT",
lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name,
};
}),
);
await this.profileRepo.save(_profiles);
return new HttpSuccess();
}
}