sort salary temp

This commit is contained in:
mamoss 2025-03-21 10:56:12 +07:00
parent f033205e1d
commit 968d5f6dad

View file

@ -311,7 +311,9 @@ export class ProfileSalaryTempController extends Controller {
orgRevisionId: findRevision.id,
})
.andWhere(
statusCheckEdit != undefined && statusCheckEdit != null && statusCheckEdit.toUpperCase() != "ALL"
statusCheckEdit != undefined &&
statusCheckEdit != null &&
statusCheckEdit.toUpperCase() != "ALL"
? "profile.statusCheckEdit = :statusCheckEdit"
: "1=1",
{
@ -568,9 +570,11 @@ export class ProfileSalaryTempController extends Controller {
// await this.salaryRepo.remove(salary);
// let salaryOld = await this.salaryOldRepo.find({
// where: { profileId: profileId },
// order: { order: "ASC" },
// });
// salaryOld.forEach((item: any) => {
// item.salaryId = item.id;
// item.order = i + 1;
// });
// let salaryNew = salaryOld.map(({ id, ...rest }: ProfileSalary) => ({
// ...rest,
@ -590,9 +594,11 @@ export class ProfileSalaryTempController extends Controller {
// await this.salaryRepo.remove(salary);
// let salaryOld = await this.salaryOldRepo.find({
// where: { profileEmployeeId: profileId },
// order: { order: "ASC" },
// });
// salaryOld.forEach((item: any) => {
// item.salaryId = item.id;
// item.order = i + 1;
// });
// let salaryNew = salaryOld.map(({ id, ...rest }: ProfileSalary) => ({
// ...rest,
@ -649,9 +655,11 @@ export class ProfileSalaryTempController extends Controller {
if (salary.length <= 0) {
let salaryOld = await this.salaryOldRepo.find({
where: { profileId: profileId },
order: { order: "ASC" },
});
salaryOld.forEach((item: any) => {
salaryOld.forEach((item: any, i) => {
item.salaryId = item.id;
item.order = i + 1;
});
let salaryNew = salaryOld.map(({ id, ...rest }: ProfileSalary) => ({
...rest,
@ -672,7 +680,12 @@ export class ProfileSalaryTempController extends Controller {
})),
);
}
return new HttpSuccess(salary);
return new HttpSuccess(
salary.map((item) => ({
...item,
status: item.isDelete == true ? "DELETE" : item.isEdit == true ? "EDIT" : "PENDING",
})),
);
} else {
const salary = await this.salaryRepo.find({
where: { profileEmployeeId: profileId },
@ -681,9 +694,11 @@ export class ProfileSalaryTempController extends Controller {
if (salary.length <= 0) {
let salaryOld = await this.salaryOldRepo.find({
where: { profileEmployeeId: profileId },
order: { order: "ASC" },
});
salaryOld.forEach((item: any) => {
salaryOld.forEach((item: any, i) => {
item.salaryId = item.id;
item.order = i + 1;
});
let salaryNew = salaryOld.map(({ id, ...rest }: ProfileSalary) => ({
...rest,
@ -728,7 +743,7 @@ export class ProfileSalaryTempController extends Controller {
if (type.toLocaleUpperCase() == "OFFICER") {
const salary = await this.salaryRepo.find({
where: { profileId: profileId, isDelete: false },
order: { order: "ASC" }
order: { order: "ASC" },
});
if (!salary) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
@ -742,7 +757,7 @@ export class ProfileSalaryTempController extends Controller {
} else {
const salary = await this.salaryRepo.find({
where: { profileEmployeeId: profileId, isDelete: false },
order: { order: "ASC" }
order: { order: "ASC" },
});
if (!salary) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");