ออกคำสั่ง 19,20,25,26,27,28,29,30,31,32

This commit is contained in:
Bright 2024-06-19 11:23:12 +07:00
parent 7ad713116f
commit f7c553ec1d

View file

@ -784,7 +784,10 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position: profile.position,
position: //profile.position,
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType
@ -876,7 +879,930 @@ export class ProfileController extends Controller {
date: body.date,
refCommandNo: body.refCommandNo,
templateDoc: body.salaryRef,
position: profile.position,
position:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command19/{profileId}")
async ExecuteCommand19Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command20/{profileId}")
async ExecuteCommand20Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command25/{profileId}")
async ExecuteCommand25Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command26/{profileId}")
async ExecuteCommand26Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command27/{profileId}")
async ExecuteCommand27Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command28/{profileId}")
async ExecuteCommand28Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command29/{profileId}")
async ExecuteCommand29Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command30/{profileId}")
async ExecuteCommand30Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command32/{profileId}")
async ExecuteCommand32Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
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("command31/{profileId}")
async ExecuteCommand31Async(
@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.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].position
: null,
positionType:
profile.profileSalary.length > 0
? profile.profileSalary[profile.profileSalary.length - 1].positionType