คำนวนเงินเดือนลูกจ้าง

This commit is contained in:
Kittapath 2024-04-03 11:27:52 +07:00
parent 6104dc5224
commit 9b1ce59201
2 changed files with 166 additions and 46 deletions

View file

@ -371,15 +371,29 @@ export class SalaryPeriodEmployeeController extends Controller {
}
if (step == null || step == 0) {
if (salaryFormula != null) {
//หาเงินตำ่สุดที่คำนวนเงิน
let salary = 0;
if (
salaryProfile.amount != null &&
salaryProfile.amount > 0 &&
salaryFormula.salaryMin != null &&
salaryFormula.salaryMin > 0
) {
if (salaryProfile.amount > salaryFormula.salaryMin) {
salary = salaryProfile.amount;
} else {
salary = salaryFormula.salaryMin;
}
} else {
if (salaryProfile.amount != null && salaryProfile.amount > 0)
salary = salaryProfile.amount;
if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0)
salary = salaryFormula.salaryMin;
}
//หาขั้นต่ำสุดตามเกณฑ์
let salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth:
salaryProfile.amount != null && salaryProfile.amount > 0
? salaryProfile.amount
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? salaryFormula.salaryMin
: 0,
salaryMonth: salary,
salaryEmployee_: {
isActive: true,
group: group,
@ -387,15 +401,11 @@ export class SalaryPeriodEmployeeController extends Controller {
},
order: { salaryMonth: "ASC" },
});
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth:
salaryProfile.amount != null && salaryProfile.amount > 0
? MoreThanOrEqual(salaryProfile.amount)
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? MoreThanOrEqual(salaryFormula.salaryMin)
: 0,
salaryMonth: MoreThan(salary),
salaryEmployee_: {
isActive: true,
group: group,
@ -403,12 +413,42 @@ export class SalaryPeriodEmployeeController extends Controller {
},
order: { salaryMonth: "ASC" },
});
step = salaryRankMin == null ? 1 : salaryRankMin.step - 0.5;
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth: salary,
salaryEmployee_: {
isActive: true,
group: salaryFormula.salaryEmployee.group,
},
},
order: { salaryMonth: "ASC" },
});
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth: MoreThan(salary),
salaryEmployee_: {
isActive: true,
group: salaryFormula.salaryEmployee.group,
},
},
order: { salaryMonth: "ASC" },
});
step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5;
group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group;
} else {
step = salaryRankMin.step;
group = salaryFormula.salaryEmployee.group;
}
} else {
step = salaryRankMin.step - 0.5;
}
} else {
step = salaryRankMin.step;
}
} else {
step = 1;
step = 0.5;
}
}
@ -741,15 +781,29 @@ export class SalaryPeriodEmployeeController extends Controller {
}
if (step == null || step == 0) {
if (salaryFormula != null) {
//หาเงินตำ่สุดที่คำนวนเงิน
let salary = 0;
if (
salaryProfile.amount != null &&
salaryProfile.amount > 0 &&
salaryFormula.salaryMin != null &&
salaryFormula.salaryMin > 0
) {
if (salaryProfile.amount > salaryFormula.salaryMin) {
salary = salaryProfile.amount;
} else {
salary = salaryFormula.salaryMin;
}
} else {
if (salaryProfile.amount != null && salaryProfile.amount > 0)
salary = salaryProfile.amount;
if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0)
salary = salaryFormula.salaryMin;
}
//หาขั้นต่ำสุดตามเกณฑ์
let salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth:
salaryProfile.amount != null && salaryProfile.amount > 0
? salaryProfile.amount
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? salaryFormula.salaryMin
: 0,
salaryMonth: salary,
salaryEmployee_: {
isActive: true,
group: group,
@ -757,15 +811,11 @@ export class SalaryPeriodEmployeeController extends Controller {
},
order: { salaryMonth: "ASC" },
});
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth:
salaryProfile.amount != null && salaryProfile.amount > 0
? MoreThanOrEqual(salaryProfile.amount)
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? MoreThanOrEqual(salaryFormula.salaryMin)
: 0,
salaryMonth: MoreThan(salary),
salaryEmployee_: {
isActive: true,
group: group,
@ -773,12 +823,42 @@ export class SalaryPeriodEmployeeController extends Controller {
},
order: { salaryMonth: "ASC" },
});
step = salaryRankMin == null ? 1 : salaryRankMin.step - 0.5;
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth: salary,
salaryEmployee_: {
isActive: true,
group: salaryFormula.salaryEmployee.group,
},
},
order: { salaryMonth: "ASC" },
});
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth: MoreThan(salary),
salaryEmployee_: {
isActive: true,
group: salaryFormula.salaryEmployee.group,
},
},
order: { salaryMonth: "ASC" },
});
step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5;
group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group;
} else {
step = salaryRankMin.step;
group = salaryFormula.salaryEmployee.group;
}
} else {
step = salaryRankMin.step - 0.5;
}
} else {
step = salaryRankMin.step;
}
} else {
step = 1;
step = 0.5;
}
}
@ -1036,7 +1116,7 @@ export class SalaryPeriodEmployeeController extends Controller {
position: item.position,
posType: item.posType,
posTypeShort: item.posTypeShort,
posLevel:
posLevel:
item.posTypeShort != null && item.posLevel != null
? `${item.posTypeShort} ${item.posLevel}`
: null,
@ -1069,7 +1149,7 @@ export class SalaryPeriodEmployeeController extends Controller {
isLeave: item.isLeave,
isRetired: item.isRetired,
isReserve: item.isReserve,
isNext: item.isNext
isNext: item.isNext,
}));
return new HttpSuccess({ data: mapSalaryProfile, total });
}
@ -1220,15 +1300,29 @@ export class SalaryPeriodEmployeeController extends Controller {
}
if (step == null || step == 0) {
if (salaryFormula != null) {
//หาเงินตำ่สุดที่คำนวนเงิน
let salary = 0;
if (
salaryProfile.amount != null &&
salaryProfile.amount > 0 &&
salaryFormula.salaryMin != null &&
salaryFormula.salaryMin > 0
) {
if (salaryProfile.amount > salaryFormula.salaryMin) {
salary = salaryProfile.amount;
} else {
salary = salaryFormula.salaryMin;
}
} else {
if (salaryProfile.amount != null && salaryProfile.amount > 0)
salary = salaryProfile.amount;
if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0)
salary = salaryFormula.salaryMin;
}
//หาขั้นต่ำสุดตามเกณฑ์
let salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth:
salaryProfile.amount != null && salaryProfile.amount > 0
? salaryProfile.amount
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? salaryFormula.salaryMin
: 0,
salaryMonth: salary,
salaryEmployee_: {
isActive: true,
group: group,
@ -1236,15 +1330,11 @@ export class SalaryPeriodEmployeeController extends Controller {
},
order: { salaryMonth: "ASC" },
});
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth:
salaryProfile.amount != null && salaryProfile.amount > 0
? MoreThanOrEqual(salaryProfile.amount)
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? MoreThanOrEqual(salaryFormula.salaryMin)
: 0,
salaryMonth: MoreThan(salary),
salaryEmployee_: {
isActive: true,
group: group,
@ -1252,12 +1342,42 @@ export class SalaryPeriodEmployeeController extends Controller {
},
order: { salaryMonth: "ASC" },
});
step = salaryRankMin == null ? 1 : salaryRankMin.step - 0.5;
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth: salary,
salaryEmployee_: {
isActive: true,
group: salaryFormula.salaryEmployee.group,
},
},
order: { salaryMonth: "ASC" },
});
if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({
where: {
salaryMonth: MoreThan(salary),
salaryEmployee_: {
isActive: true,
group: salaryFormula.salaryEmployee.group,
},
},
order: { salaryMonth: "ASC" },
});
step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5;
group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group;
} else {
step = salaryRankMin.step;
group = salaryFormula.salaryEmployee.group;
}
} else {
step = salaryRankMin.step - 0.5;
}
} else {
step = salaryRankMin.step;
}
} else {
step = 1;
step = 0.5;
}
}