ออกคำสั่ง C-PM-11, C-PM-12

This commit is contained in:
Bright 2024-06-18 13:26:55 +07:00
parent 9bf37a2f1d
commit cfe1eba3b0
2 changed files with 160 additions and 4 deletions

View file

@ -460,13 +460,12 @@ export class ProfileController extends Controller {
});
const Salary = salarys.map((item) => ({
SalaryDate: Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.date)) ?? null,
SalaryDate: item.date ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.date)) : null,
Position: item.position ?? null,
PosNo: item.posNo ?? null,
Salary: item.amount ?? null,
Rank: item.positionLevel ?? null,
RefAll: Extension.ToThaiNumber(item.templateDoc) ?? null,
PositionType: item.positionType ?? null,
RefAll: item.templateDoc ? Extension.ToThaiNumber(item.templateDoc) : null,
PositionLevel: item.positionLevel ?? null,
PositionAmount:
item.positionSalaryAmount == null
@ -746,6 +745,163 @@ export class ProfileController extends Controller {
return new HttpSuccess(profile.id);
}
/**
* API
*
* @summary API (ADMIN)
*
*/
@Post("command11/{profileId}")
async ExecuteCommand11Async(
@Request() req: RequestWithUser,
@Body() body: {
profileId: string,
date: Date | null,
refCommandNo: string | null,
salaryRef: string | null
}
) {
const profile = await this.profileRepo.findOne({
relations: ['profileSalary'],
where: { id: body.profileId }
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
}
// const posType = await this.posTypeRepo.findOneBy({ id: String(profile.posTypeId) })
// const posLevel = await this.posLevelRepo.findOneBy({ id: String(profile.posLevelId) })
if(profile.isProbation != false) {
profile.isProbation = false;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId,
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position: profile.position,
positionType: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionType
: null,
positionLevel: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionLevel
: null,
posNo: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].posNo
: null,
positionLine: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionLine
: null,
positionPathSide: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionPathSide
: null,
positionExecutive: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionExecutive
: null,
amount: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].amount
: null,
positionSalaryAmount: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionSalaryAmount
: null,
mouthSalaryAmount: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].mouthSalaryAmount
: null,
order: profile.profileSalary.length >= 0
? profile.profileSalary.length > 0 ? profile.profileSalary[profile.profileSalary.length-1].order + 1 : 1
: null,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await Promise.all([
this.profileRepo.save(profile),
this.salaryRepository.save(profileSalary),
]);
}
return new HttpSuccess();
}
/**
* API
*
* @summary API (ADMIN)
*
*/
@Post("command12/{profileId}")
async ExecuteCommand12Async(
@Request() req: RequestWithUser,
@Body() body: {
profileId: string,
date: Date | null,
refCommandNo: string | null,
salaryRef: string | null
}
) {
const profile = await this.profileRepo.findOne({
relations: ['profileSalary'],
where: { id: body.profileId }
});
if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
}
let dateLeave_: any = body.date
profile.isLeave = true;
profile.leaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด";
profile.dateLeave = dateLeave_;
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), {
profileId: body.profileId,
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position: profile.position,
positionType: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionType
: null,
positionLevel: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionLevel
: null,
posNo: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].posNo
: null,
positionLine: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionLine
: null,
positionPathSide: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionPathSide
: null,
positionExecutive: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionExecutive
: null,
amount: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].amount
: null,
positionSalaryAmount: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].positionSalaryAmount
: null,
mouthSalaryAmount: profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length-1].mouthSalaryAmount
: null,
order: profile.profileSalary.length >= 0
? profile.profileSalary.length > 0 ? profile.profileSalary[profile.profileSalary.length-1].order + 1 : 1
: null,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await Promise.all([
this.profileRepo.save(profile),
this.salaryRepository.save(profileSalary),
]);
return new HttpSuccess();
}
/**
* API
*

View file

@ -481,7 +481,7 @@ export class ProfileEmployeeController extends Controller {
});
const Salary = salarys.map((item) => ({
SalaryDate: Extension.ToThaiShortDate(item.date) ?? null,
SalaryDate: item.date ? Extension.ToThaiShortDate(item.date) : null,
Position: item.position ?? null,
PosNo: item.posNo ?? null,
Salary: "",