api คำขอแก้ไข

This commit is contained in:
Kittapath 2024-07-19 11:08:47 +07:00
parent 0696672f86
commit 85c6093970
8 changed files with 546 additions and 30 deletions

View file

@ -20,7 +20,11 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { Brackets, Double, In, IsNull, Like, Not } from "typeorm";
import { OrgRevision } from "../entities/OrgRevision";
import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils";
import {
calculateRetireDate,
calculateRetireLaw,
removeProfileInOrganize,
} from "../interfaces/utils";
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import {
ProfileEmployee,
@ -360,7 +364,7 @@ export class ProfileEmployeeController extends Controller {
District: "",
Area: "",
Province: "",
Telephone:
Telephone:
profiles.telephoneNumber != null ? Extension.ToThaiNumber(profiles.telephoneNumber) : "",
CoupleLastNameOld: profileFamilyCouple?.coupleLastNameOld ?? null,
CouplePrefix: profileFamilyCouple?.couplePrefix ?? "",
@ -400,8 +404,8 @@ export class ProfileEmployeeController extends Controller {
profiles.dateRetireLaw != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(profiles.dateRetireLaw))
: "",
CurrentAddress:
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
CurrentAddress:
profiles.currentAddress != null ? Extension.ToThaiNumber(profiles.currentAddress) : "",
CurrentSubDistrict:
profiles.currentSubDistrict != null
? Extension.ToThaiNumber(profiles.currentSubDistrict.name)
@ -438,9 +442,7 @@ export class ProfileEmployeeController extends Controller {
? ""
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate)),
End:
item.endDate == null
? ""
: Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)),
item.endDate == null ? "" : Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate)),
Date:
item.startDate && item.endDate
? `${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.startDate))} - ${Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.endDate))}`
@ -455,7 +457,7 @@ export class ProfileEmployeeController extends Controller {
where: { profileEmployeeId: id },
});
const Discipline = disciplines.map((item) => ({
DisciplineYear:
DisciplineYear:
Extension.ToThaiNumber(new Date(item.refCommandDate).getFullYear().toString()) ?? null,
DisciplineDetail: item.detail ?? null,
RefNo: Extension.ToThaiNumber(item.refCommandNo) ?? null,
@ -468,11 +470,11 @@ export class ProfileEmployeeController extends Controller {
});
const Education = educations.map((item) => ({
Institute: item.institute ?? null,
Start:
Start:
item.startDate == null
? ""
: Extension.ToThaiNumber(new Date(item.startDate).getFullYear().toString()),
End:
End:
item.endDate == null
? ""
: Extension.ToThaiNumber(new Date(item.endDate).getFullYear().toString()),
@ -1329,8 +1331,8 @@ export class ProfileEmployeeController extends Controller {
.map((x) => x.next_holderId),
});
}),
)
.andWhere("profileEmployee.employeeClass = :employeeClass", {employeeClass:"PERM"})
)
.andWhere("profileEmployee.employeeClass = :employeeClass", { employeeClass: "PERM" })
.skip((requestBody.page - 1) * requestBody.pageSize)
.take(requestBody.pageSize)
.getManyAndCount();
@ -2757,6 +2759,9 @@ export class ProfileEmployeeController extends Controller {
profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason;
profile.dateLeave = requestBody.dateLeave;
if (requestBody.isLeave == true) {
await removeProfileInOrganize(profile.id);
}
await this.profileRepo.save(profile);
const profileSalary = await this.salaryRepository.findOne({