add function leave/{id} with profile/salary
This commit is contained in:
parent
e2d5f7e13d
commit
2a4c3e745f
1 changed files with 137 additions and 86 deletions
|
|
@ -47,10 +47,11 @@ import { ProfileCertificate } from "../entities/ProfileCertificate";
|
||||||
import { ProfileTraining } from "../entities/ProfileTraining";
|
import { ProfileTraining } from "../entities/ProfileTraining";
|
||||||
import { ProfileDiscipline } from "../entities/ProfileDiscipline";
|
import { ProfileDiscipline } from "../entities/ProfileDiscipline";
|
||||||
import { ProfileEducation } from "../entities/ProfileEducation";
|
import { ProfileEducation } from "../entities/ProfileEducation";
|
||||||
import { ProfileSalary } from "../entities/ProfileSalary";
|
import { CreateProfileSalary, ProfileSalary } from "../entities/ProfileSalary";
|
||||||
import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
||||||
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||||
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||||
|
import CallAPI from "../interfaces/call-api";
|
||||||
import Extension from "../interfaces/extension";
|
import Extension from "../interfaces/extension";
|
||||||
|
|
||||||
@Route("api/v1/org/profile")
|
@Route("api/v1/org/profile")
|
||||||
|
|
@ -460,7 +461,9 @@ export class ProfileController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
const Salary = salarys.map((item) => ({
|
const Salary = salarys.map((item) => ({
|
||||||
SalaryDate: item.date ? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.date)) : null,
|
SalaryDate: item.date
|
||||||
|
? Extension.ToThaiNumber(Extension.ToThaiShortDate_noPrefix(item.date))
|
||||||
|
: null,
|
||||||
Position: item.position ?? null,
|
Position: item.position ?? null,
|
||||||
PosNo: item.posNo ?? null,
|
PosNo: item.posNo ?? null,
|
||||||
Salary: item.amount ?? null,
|
Salary: item.amount ?? null,
|
||||||
|
|
@ -754,16 +757,17 @@ export class ProfileController extends Controller {
|
||||||
@Post("command11/{profileId}")
|
@Post("command11/{profileId}")
|
||||||
async ExecuteCommand11Async(
|
async ExecuteCommand11Async(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: {
|
@Body()
|
||||||
profileId: string,
|
body: {
|
||||||
date: Date | null,
|
profileId: string;
|
||||||
refCommandNo: string | null,
|
date: Date | null;
|
||||||
salaryRef: string | null
|
refCommandNo: string | null;
|
||||||
}
|
salaryRef: string | null;
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
relations: ['profileSalary'],
|
relations: ["profileSalary"],
|
||||||
where: { id: body.profileId }
|
where: { id: body.profileId },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
||||||
|
|
@ -771,7 +775,7 @@ export class ProfileController extends Controller {
|
||||||
// const posType = await this.posTypeRepo.findOneBy({ id: String(profile.posTypeId) })
|
// const posType = await this.posTypeRepo.findOneBy({ id: String(profile.posTypeId) })
|
||||||
// const posLevel = await this.posLevelRepo.findOneBy({ id: String(profile.posLevelId) })
|
// const posLevel = await this.posLevelRepo.findOneBy({ id: String(profile.posLevelId) })
|
||||||
|
|
||||||
if(profile.isProbation != false) {
|
if (profile.isProbation != false) {
|
||||||
profile.isProbation = false;
|
profile.isProbation = false;
|
||||||
profile.lastUpdateUserId = req.user.sub;
|
profile.lastUpdateUserId = req.user.sub;
|
||||||
profile.lastUpdateFullName = req.user.name;
|
profile.lastUpdateFullName = req.user.name;
|
||||||
|
|
@ -781,36 +785,48 @@ export class ProfileController extends Controller {
|
||||||
refCommandNo: body.refCommandNo,
|
refCommandNo: body.refCommandNo,
|
||||||
templateDoc: body.salaryRef,
|
templateDoc: body.salaryRef,
|
||||||
position: profile.position,
|
position: profile.position,
|
||||||
positionType: profile.profileSalary.length > 0
|
positionType:
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionType
|
profile.profileSalary.length > 0
|
||||||
: null,
|
? profile.profileSalary[profile.profileSalary.length - 1].positionType
|
||||||
positionLevel: profile.profileSalary.length > 0
|
: null,
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionLevel
|
positionLevel:
|
||||||
: null,
|
profile.profileSalary.length > 0
|
||||||
posNo: profile.profileSalary.length > 0
|
? profile.profileSalary[profile.profileSalary.length - 1].positionLevel
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].posNo
|
: null,
|
||||||
: null,
|
posNo:
|
||||||
positionLine: profile.profileSalary.length > 0
|
profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionLine
|
? profile.profileSalary[profile.profileSalary.length - 1].posNo
|
||||||
: null,
|
: null,
|
||||||
positionPathSide: profile.profileSalary.length > 0
|
positionLine:
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionPathSide
|
profile.profileSalary.length > 0
|
||||||
: null,
|
? profile.profileSalary[profile.profileSalary.length - 1].positionLine
|
||||||
positionExecutive: profile.profileSalary.length > 0
|
: null,
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionExecutive
|
positionPathSide:
|
||||||
: null,
|
profile.profileSalary.length > 0
|
||||||
amount: profile.profileSalary.length > 0
|
? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].amount
|
: null,
|
||||||
: null,
|
positionExecutive:
|
||||||
positionSalaryAmount: profile.profileSalary.length > 0
|
profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionSalaryAmount
|
? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive
|
||||||
: null,
|
: null,
|
||||||
mouthSalaryAmount: profile.profileSalary.length > 0
|
amount:
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].mouthSalaryAmount
|
profile.profileSalary.length > 0
|
||||||
: null,
|
? profile.profileSalary[profile.profileSalary.length - 1].amount
|
||||||
order: profile.profileSalary.length >= 0
|
: null,
|
||||||
? profile.profileSalary.length > 0 ? profile.profileSalary[profile.profileSalary.length-1].order + 1 : 1
|
positionSalaryAmount:
|
||||||
: null,
|
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,
|
createdUserId: req.user.sub,
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
|
|
@ -823,7 +839,7 @@ export class ProfileController extends Controller {
|
||||||
}
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ออกคำสั่ง คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
|
* API ออกคำสั่ง คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
|
||||||
*
|
*
|
||||||
|
|
@ -833,23 +849,25 @@ export class ProfileController extends Controller {
|
||||||
@Post("command12/{profileId}")
|
@Post("command12/{profileId}")
|
||||||
async ExecuteCommand12Async(
|
async ExecuteCommand12Async(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body() body: {
|
@Body()
|
||||||
profileId: string,
|
body: {
|
||||||
date: Date | null,
|
profileId: string;
|
||||||
refCommandNo: string | null,
|
date: Date | null;
|
||||||
salaryRef: string | null
|
refCommandNo: string | null;
|
||||||
}
|
salaryRef: string | null;
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
relations: ['profileSalary'],
|
relations: ["profileSalary"],
|
||||||
where: { id: body.profileId }
|
where: { id: body.profileId },
|
||||||
});
|
});
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์");
|
||||||
}
|
}
|
||||||
let dateLeave_: any = body.date
|
let dateLeave_: any = body.date;
|
||||||
profile.isLeave = true;
|
profile.isLeave = true;
|
||||||
profile.leaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด";
|
profile.leaveReason =
|
||||||
|
"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด";
|
||||||
profile.dateLeave = dateLeave_;
|
profile.dateLeave = dateLeave_;
|
||||||
profile.lastUpdateUserId = req.user.sub;
|
profile.lastUpdateUserId = req.user.sub;
|
||||||
profile.lastUpdateFullName = req.user.name;
|
profile.lastUpdateFullName = req.user.name;
|
||||||
|
|
@ -859,45 +877,54 @@ export class ProfileController extends Controller {
|
||||||
refCommandNo: body.refCommandNo,
|
refCommandNo: body.refCommandNo,
|
||||||
templateDoc: body.salaryRef,
|
templateDoc: body.salaryRef,
|
||||||
position: profile.position,
|
position: profile.position,
|
||||||
positionType: profile.profileSalary.length > 0
|
positionType:
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionType
|
profile.profileSalary.length > 0
|
||||||
: null,
|
? profile.profileSalary[profile.profileSalary.length - 1].positionType
|
||||||
positionLevel: profile.profileSalary.length > 0
|
: null,
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionLevel
|
positionLevel:
|
||||||
: null,
|
profile.profileSalary.length > 0
|
||||||
posNo: profile.profileSalary.length > 0
|
? profile.profileSalary[profile.profileSalary.length - 1].positionLevel
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].posNo
|
: null,
|
||||||
: null,
|
posNo:
|
||||||
positionLine: profile.profileSalary.length > 0
|
profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionLine
|
? profile.profileSalary[profile.profileSalary.length - 1].posNo
|
||||||
: null,
|
: null,
|
||||||
positionPathSide: profile.profileSalary.length > 0
|
positionLine:
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionPathSide
|
profile.profileSalary.length > 0
|
||||||
: null,
|
? profile.profileSalary[profile.profileSalary.length - 1].positionLine
|
||||||
positionExecutive: profile.profileSalary.length > 0
|
: null,
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionExecutive
|
positionPathSide:
|
||||||
: null,
|
profile.profileSalary.length > 0
|
||||||
amount: profile.profileSalary.length > 0
|
? profile.profileSalary[profile.profileSalary.length - 1].positionPathSide
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].amount
|
: null,
|
||||||
: null,
|
positionExecutive:
|
||||||
positionSalaryAmount: profile.profileSalary.length > 0
|
profile.profileSalary.length > 0
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].positionSalaryAmount
|
? profile.profileSalary[profile.profileSalary.length - 1].positionExecutive
|
||||||
: null,
|
: null,
|
||||||
mouthSalaryAmount: profile.profileSalary.length > 0
|
amount:
|
||||||
? profile.profileSalary[profile.profileSalary.length-1].mouthSalaryAmount
|
profile.profileSalary.length > 0
|
||||||
: null,
|
? profile.profileSalary[profile.profileSalary.length - 1].amount
|
||||||
order: profile.profileSalary.length >= 0
|
: null,
|
||||||
? profile.profileSalary.length > 0 ? profile.profileSalary[profile.profileSalary.length-1].order + 1 : 1
|
positionSalaryAmount:
|
||||||
: null,
|
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,
|
createdUserId: req.user.sub,
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
lastUpdateFullName: req.user.name,
|
lastUpdateFullName: req.user.name,
|
||||||
});
|
});
|
||||||
await Promise.all([
|
await Promise.all([this.profileRepo.save(profile), this.salaryRepository.save(profileSalary)]);
|
||||||
this.profileRepo.save(profile),
|
|
||||||
this.salaryRepository.save(profileSalary),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -3283,6 +3310,7 @@ export class ProfileController extends Controller {
|
||||||
@Path() id: string,
|
@Path() id: string,
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
|
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
) {
|
) {
|
||||||
const profile = await this.profileRepo.findOne({
|
const profile = await this.profileRepo.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -3293,6 +3321,29 @@ export class ProfileController extends Controller {
|
||||||
profile.leaveReason = requestBody.leaveReason;
|
profile.leaveReason = requestBody.leaveReason;
|
||||||
profile.dateLeave = requestBody.dateLeave;
|
profile.dateLeave = requestBody.dateLeave;
|
||||||
await this.profileRepo.save(profile);
|
await this.profileRepo.save(profile);
|
||||||
|
|
||||||
|
const profileSalary = await this.salaryRepository.findOne({
|
||||||
|
where: { profileId: id },
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
|
});
|
||||||
|
|
||||||
|
await new CallAPI().PostData(request, "org/profile/salary", {
|
||||||
|
profileId: profile.id,
|
||||||
|
date: requestBody.dateLeave,
|
||||||
|
amount: profileSalary?.amount,
|
||||||
|
positionSalaryAmount: profileSalary?.positionSalaryAmount,
|
||||||
|
mouthSalaryAmount: profileSalary?.mouthSalaryAmount,
|
||||||
|
posNo: profileSalary?.posNo,
|
||||||
|
position: profileSalary?.position,
|
||||||
|
positionLine: profileSalary?.positionLine,
|
||||||
|
positionPathSide: profileSalary?.positionPathSide,
|
||||||
|
positionExecutive: profileSalary?.positionExecutive,
|
||||||
|
positionType: profileSalary?.positionType,
|
||||||
|
positionLevel: profileSalary?.positionLevel,
|
||||||
|
refCommandNo: null,
|
||||||
|
templateDoc: requestBody.leaveReason,
|
||||||
|
});
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue