add function emp

This commit is contained in:
AdisakKanthawilang 2024-06-18 16:10:46 +07:00
parent 2a4c3e745f
commit 7871e18130

View file

@ -2674,6 +2674,7 @@ export class ProfileEmployeeController extends Controller {
@Path() id: string,
@Body()
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
@Request() request: { user: Record<string, any> },
) {
const profile = await this.profileRepo.findOne({
where: { id: id },
@ -2684,6 +2685,27 @@ export class ProfileEmployeeController extends Controller {
profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave;
await this.profileRepo.save(profile);
const profileSalary = await this.salaryRepository.findOne({
where: { profileEmployeeId: id },
order: { createdAt: "DESC" },
});
await new CallAPI().PostData(request, "org/profile-employee/salary", {
profileEmployeeId: profile.id,
date: requestBody.dateLeave,
amount: profileSalary?.amount,
positionSalaryAmount: profileSalary?.positionSalaryAmount,
mouthSalaryAmount: profileSalary?.mouthSalaryAmount,
posNo: profileSalary?.posNo,
position: profileSalary?.position,
positionType: profileSalary?.positionType,
positionLevel: profileSalary?.positionLevel,
refCommandNo: null,
templateDoc: requestBody.leaveReason,
});
return new HttpSuccess();
}