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

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

@ -125,7 +125,7 @@ export class ProfileEmployeeController extends Controller {
const profile = await this.profileRepo.findOne({
relations: [
"profileSalarys",
"profileSalary",
"profileEducations",
"current_holders",
"current_holders.orgRoot",
@ -136,7 +136,7 @@ export class ProfileEmployeeController extends Controller {
],
where: { id: id },
order: {
profileSalarys: {
profileSalary: {
date: "DESC",
},
},
@ -256,16 +256,16 @@ export class ProfileEmployeeController extends Controller {
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateRetire))
: "-",
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())
: "-",
registrationAddress: Extension.ToThaiNumber(
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
),
salaryDate:
profile.profileSalarys.length > 0 && profile.profileSalarys[0].date != null
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(profile.profileSalarys[0].date),
Extension.ToThaiShortDate_monthYear(profile.profileSalary[0].date),
)
: "-",
positionName: profile.position != null ? profile.position : "-",
@ -1783,20 +1783,20 @@ export class ProfileEmployeeController 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}%`,
@ -1804,7 +1804,7 @@ export class ProfileEmployeeController extends Controller {
)
.orWhere(
requestBody.posNo != null && requestBody.posNo != "" && requestBody.position == undefined
? "profileSalarys.posNo LIKE :posNo"
? "profileSalars.posNo LIKE :posNo"
: "1=2",
{
posNo: `%${requestBody.posNo}%`,
@ -1814,8 +1814,8 @@ export class ProfileEmployeeController 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;
});
}
@ -1850,10 +1850,10 @@ export class ProfileEmployeeController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"profileSalarys",
"profileSalary",
],
order: {
profileSalarys: {
profileSalary: {
order: "DESC",
},
},
@ -1976,7 +1976,7 @@ export class ProfileEmployeeController extends Controller {
node: null,
nodeId: null,
salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
};
return new HttpSuccess(_profile);
}
@ -2009,7 +2009,7 @@ export class ProfileEmployeeController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -2028,7 +2028,7 @@ export class ProfileEmployeeController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -2047,7 +2047,7 @@ export class ProfileEmployeeController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -2065,7 +2065,7 @@ export class ProfileEmployeeController extends Controller {
"posType",
"posLevel",
"current_holders",
"profileSalarys",
"profileSalary",
"current_holders.orgRoot",
"current_holders.orgChild1",
"current_holders.orgChild2",
@ -2122,8 +2122,8 @@ export class ProfileEmployeeController 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()),
);
@ -2779,7 +2779,7 @@ export class ProfileEmployeeController 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")
@ -2877,9 +2877,9 @@ export class ProfileEmployeeController 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`,
);
@ -3678,7 +3678,7 @@ export class ProfileEmployeeController extends Controller {
keycloak: IsNull(),
citizenId: Like(`%${body.keyword}%`),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3690,7 +3690,7 @@ export class ProfileEmployeeController extends Controller {
keycloak: IsNull(),
firstName: Like(`%${body.keyword}%`),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3702,7 +3702,7 @@ export class ProfileEmployeeController extends Controller {
keycloak: IsNull(),
lastName: Like(`%${body.keyword}%`),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3713,7 +3713,7 @@ export class ProfileEmployeeController extends Controller {
where: {
keycloak: IsNull(),
},
relations: ["posType", "posLevel", "current_holders", "profileSalarys"],
relations: ["posType", "posLevel", "current_holders", "profileSalary"],
skip,
take,
});
@ -3764,8 +3764,8 @@ export class ProfileEmployeeController 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()),
);
@ -3832,10 +3832,10 @@ export class ProfileEmployeeController extends Controller {
"posType",
"current_holders",
"current_holders.orgRoot",
"profileSalarys",
"profileSalary",
],
order: {
profileSalarys: {
profileSalary: {
order: "DESC",
},
},
@ -3960,24 +3960,29 @@ export class ProfileEmployeeController extends Controller {
nodeId: null,
posNo: shortName,
salary:
profile && profile.profileSalarys.length > 0 ? profile.profileSalarys[0].amount : null,
profile && profile.profileSalary.length > 0 ? profile.profileSalary[0].amount : null,
};
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);
}