เพิ่มเวลาลูกจ้าง

This commit is contained in:
kittapath 2024-11-07 15:55:23 +07:00
parent b1c365a4da
commit 2c1e1dd8ff
9 changed files with 390 additions and 244 deletions

View file

@ -123,7 +123,7 @@ export class ProfileEmployeeTempController extends Controller {
const profile = await this.profileRepo.findOne({
relations: [
"profileSalarys",
"profileSalary",
"profileEducations",
"current_holders",
"current_holders.orgRoot",
@ -211,8 +211,8 @@ export class ProfileEmployeeTempController extends Controller {
: "",
RegistrationAddress: `${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
SalaryAmount:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].amount != null
? Extension.ToThaiNumber(profile.profileSalarys[0].amount.toLocaleString())
profile.profileSalary.length > 0 && profile.profileSalary[0].amount != null
? Extension.ToThaiNumber(profile.profileSalary[0].amount.toLocaleString())
: "",
Education:
profile.profileEducations.length > 0 &&
@ -221,8 +221,8 @@ export class ProfileEmployeeTempController extends Controller {
: "",
AppointText: profile.dateAppoint != null ? profile.dateAppoint : "",
SalaryDate:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalarys[0].date))
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
? Extension.ToThaiNumber(Extension.ToThaiFullDate(profile.profileSalary[0].date))
: "",
PositionName: profile.position != null ? profile.position : "",
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
@ -1481,20 +1481,20 @@ export class ProfileEmployeeTempController extends Controller {
) {
const profiles = await this.profileRepo
.createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.profileSalarys", "profileSalarys")
.leftJoinAndSelect("profileEmployee.profileSalary", "profileSalary")
.select([
"profileEmployee.id",
"profileEmployee.prefix",
"profileEmployee.firstName",
"profileEmployee.lastName",
"profileEmployee.citizenId",
"profileSalarys.position",
"profileSalarys.posNo",
"profileSalarys.date",
"profileSalary.position",
"profileSalary.posNo",
"profileSalary.date",
])
.andWhere(
requestBody.position != null && requestBody.position != "" && requestBody.posNo == undefined
? "profileSalarys.position LIKE :position"
? "profileSalary.position LIKE :position"
: "1=2",
{
position: `%${requestBody.position}%`,
@ -1502,7 +1502,7 @@ export class ProfileEmployeeTempController extends Controller {
)
.orWhere(
requestBody.posNo != null && requestBody.posNo != "" && requestBody.position == undefined
? "profileSalarys.posNo LIKE :posNo"
? "profileSalary.posNo LIKE :posNo"
: "1=2",
{
posNo: `%${requestBody.posNo}%`,
@ -1512,8 +1512,8 @@ export class ProfileEmployeeTempController extends Controller {
const mapData = profiles.map((profile) => {
let profileSalary;
if (profile.profileSalarys && profile.profileSalarys.length > 0) {
profileSalary = profile.profileSalarys.reduce((latest, current) => {
if (profile.profileSalary && profile.profileSalary.length > 0) {
profileSalary = profile.profileSalary.reduce((latest, current) => {
return new Date(current.date) > new Date(latest.date) ? current : latest;
});
}
@ -1548,10 +1548,10 @@ export class ProfileEmployeeTempController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"profileSalarys",
"profileSalary",
],
order: {
profileSalarys: {
profileSalary: {
order: "DESC",
},
},
@ -1663,8 +1663,7 @@ export class ProfileEmployeeTempController extends Controller {
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4
.orgChild4Name,
salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
salary: profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
};
return new HttpSuccess(_profile);
}
@ -1697,7 +1696,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -1716,7 +1715,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -1735,7 +1734,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -1753,7 +1752,7 @@ export class ProfileEmployeeTempController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -1810,8 +1809,8 @@ export class ProfileEmployeeTempController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
let salary: any = "";
if (item != null && item.profileSalarys != null && item.profileSalarys.length > 0) {
let _salary: any = item.profileSalarys.sort(
if (item != null && item.profileSalary != null && item.profileSalary.length > 0) {
let _salary: any = item.profileSalary.sort(
(a, b) =>
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
);
@ -2401,7 +2400,7 @@ export class ProfileEmployeeTempController extends Controller {
.leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("employeePosMaster.positions", "positions")
.leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys")
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
.leftJoinAndSelect("current_holder.posType", "posType")
@ -2499,9 +2498,9 @@ export class ProfileEmployeeTempController extends Controller {
}
const amount =
item.current_holder == null || item.current_holder.profileSalarys.length == 0
item.current_holder == null || item.current_holder.profileSalary.length == 0
? null
: item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount;
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);
@ -3267,7 +3266,7 @@ export class ProfileEmployeeTempController extends Controller {
keycloak: IsNull(),
citizenId: Like(`%${body.keyword}%`),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3279,7 +3278,7 @@ export class ProfileEmployeeTempController extends Controller {
keycloak: IsNull(),
firstName: Like(`%${body.keyword}%`),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3291,7 +3290,7 @@ export class ProfileEmployeeTempController extends Controller {
keycloak: IsNull(),
lastName: Like(`%${body.keyword}%`),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3302,7 +3301,7 @@ export class ProfileEmployeeTempController extends Controller {
where: {
keycloak: IsNull(),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3353,8 +3352,8 @@ export class ProfileEmployeeTempController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
let salary: any = "";
if (item != null && item.profileSalarys != null && item.profileSalarys.length > 0) {
let _salary: any = item.profileSalarys.sort(
if (item != null && item.profileSalary != null && item.profileSalary.length > 0) {
let _salary: any = item.profileSalary.sort(
(a, b) =>
(b.date == null ? 0 : b.date.getTime()) - (a.date == null ? 0 : a.date.getTime()),
);
@ -3542,18 +3541,23 @@ export class ProfileEmployeeTempController extends Controller {
if (_profile.child4Id != null) {
_profile.node = 4;
_profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
} else if (_profile.child3Id != null) {
_profile.node = 3;
_profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
} else if (_profile.child2Id != null) {
_profile.node = 2;
_profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
} else if (_profile.child1Id != null) {
_profile.node = 1;
_profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
} else if (_profile.rootId != null) {
_profile.node = 0;
_profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
}
return new HttpSuccess(_profile);
}