Merge branch 'develop'

This commit is contained in:
kittapath 2024-12-26 19:37:00 +07:00
commit 6ed9e5ab1f
2 changed files with 76 additions and 30 deletions

View file

@ -1780,8 +1780,7 @@ export class CommandController extends Controller {
},
select: ["orgRootId"],
});
}
else {
} else {
posMaster = await this.posMasterRepository.find({
where: {
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
@ -1790,12 +1789,12 @@ export class CommandController extends Controller {
select: ["orgRootId"],
});
}
let _posMaster: any;
if (["C-PM-38", "C-PM-40"].includes(commandCode)) {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x:any) => x.orgRootId)),
orgRootId: In(posMaster.map((x: any) => x.orgRootId)),
orgChild1: IsNull(),
orgChild2: IsNull(),
orgChild3: IsNull(),
@ -1809,7 +1808,7 @@ export class CommandController extends Controller {
} else {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x:any) => x.orgRootId)),
orgRootId: In(posMaster.map((x: any) => x.orgRootId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
@ -4166,28 +4165,28 @@ export class CommandController extends Controller {
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
if (profile != null) {
profile.position = position?.positionName ?? "";
profile.posTypeId = position?.posTypeId ?? "";
profile.posLevelId = position?.posLevelId ?? "";
profile.lastUpdateUserId = req.user.sub;
profile.lastUpdateFullName = req.user.name;
profile.lastUpdatedAt = new Date();
await this.profileRepository.save(profile);
}
// if (profile != null) {
// profile.position = position?.positionName ?? "";
// profile.posTypeId = position?.posTypeId ?? "";
// profile.posLevelId = position?.posLevelId ?? "";
// profile.lastUpdateUserId = req.user.sub;
// profile.lastUpdateFullName = req.user.name;
// profile.lastUpdatedAt = new Date();
// await this.profileRepository.save(profile);
// }
}
}),
);
const posMasters = await this.posMasterRepository.find({
where: { id: In(body.refIds.map((x) => x.refId)) },
});
const data = posMasters.map((_data) => ({
..._data,
current_holderId: _data.next_holderId,
next_holderId: null,
statusReport: "PENDING",
}));
await this.posMasterRepository.save(data);
// const posMasters = await this.posMasterRepository.find({
// where: { id: In(body.refIds.map((x) => x.refId)) },
// });
// const data = posMasters.map((_data) => ({
// ..._data,
// current_holderId: _data.next_holderId,
// next_holderId: null,
// statusReport: "PENDING",
// }));
// await this.posMasterRepository.save(data);
return new HttpSuccess();
}

View file

@ -222,10 +222,44 @@ export class ProfileController extends Controller {
let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`;
let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`;
const salary_raw = await this.salaryRepository.find({
select: [
"date",
"position",
"posNo",
"positionType",
"positionLevel",
"positionSalaryAmount",
"refCommandNo",
"amount",
"templateDoc",
],
where: { profileId: id },
order: { date: "ASC" },
});
const salarys =
salary_raw.length > 1
? salary_raw.slice(1).map((item) => ({
date: item.date
? Extension.ToThaiNumber(Extension.ToThaiShortDate(item.date))
: null,
positionLine: item.positionLine != null ? item.positionLine : "-",
posNo: item.posNo != null ? Extension.ToThaiNumber(item.posNo) : null,
}))
: [
{
date: "-",
positionLine: "-",
posNo: "-",
},
];
const educations = await this.educationRepository.find({
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
where: { profileId: id },
order: { lastUpdatedAt: "DESC" },
order: { startDate: "ASC" },
});
const Education =
educations && educations.length > 0
@ -265,19 +299,32 @@ export class ProfileController extends Controller {
registrationAddress: Extension.ToThaiNumber(
`${_regisAddres}${_subDistrict}${_district}${_province}${registrationZipCode}`,
),
salaryDate:
profile.profileSalary.length > 0 && profile.profileSalary[0].date != null
date:
salary_raw.length > 0 && salary_raw[0].date != null
? Extension.ToThaiNumber(
Extension.ToThaiShortDate_monthYear(profile.profileSalary[0].date),
Extension.ToThaiShortDate(salary_raw[0].date),
)
: "-",
positionName: profile.position != null ? profile.position : "-",
appointText:
profile.dateAppoint != null
? Extension.ToThaiNumber(Extension.ToThaiShortDate_monthYear(profile.dateAppoint))
? Extension.ToThaiNumber(Extension.ToThaiShortDate(profile.dateAppoint))
: "-",
posNo:
salary_raw.length > 0 && salary_raw[0].posNo != null
? Extension.ToThaiNumber(
Extension.ToThaiNumber(salary_raw[0].posNo),
)
: "-",
positionLine:
salary_raw.length > 0 && salary_raw[0].positionLine != null
? Extension.ToThaiNumber(
Extension.ToThaiNumber(salary_raw[0].positionLine),
)
: "-",
ocFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
educations: Education,
salarys: salarys,
url: ImgUrl ? ImgUrl : `${process.env.VITE_URL_SSO}/assets/avatar_user-89f22423.jpg`,
};
@ -561,7 +608,7 @@ export class ProfileController extends Controller {
const salarys =
salary_raw.length > 0
? salary_raw.map((item) => ({
salaryDate: item.date
salaryDate: item.date
? Extension.ToThaiNumber(Extension.ToThaiFullDate2(item.date))
: null,
position: item.position != null ? Extension.ToThaiNumber(item.position) : null,