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

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 (step == null || step == 0) {
if (salaryFormula != null) { 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({ let salaryRankMin = await this.salaryRankRepository.findOne({
where: { where: {
salaryMonth: salaryMonth: salary,
salaryProfile.amount != null && salaryProfile.amount > 0
? salaryProfile.amount
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? salaryFormula.salaryMin
: 0,
salaryEmployee_: { salaryEmployee_: {
isActive: true, isActive: true,
group: group, group: group,
@ -387,15 +401,11 @@ export class SalaryPeriodEmployeeController extends Controller {
}, },
order: { salaryMonth: "ASC" }, order: { salaryMonth: "ASC" },
}); });
if (salaryRankMin == null) { if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({ salaryRankMin = await this.salaryRankRepository.findOne({
where: { where: {
salaryMonth: salaryMonth: MoreThan(salary),
salaryProfile.amount != null && salaryProfile.amount > 0
? MoreThanOrEqual(salaryProfile.amount)
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? MoreThanOrEqual(salaryFormula.salaryMin)
: 0,
salaryEmployee_: { salaryEmployee_: {
isActive: true, isActive: true,
group: group, group: group,
@ -403,12 +413,42 @@ export class SalaryPeriodEmployeeController extends Controller {
}, },
order: { salaryMonth: "ASC" }, 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 { } else {
step = salaryRankMin.step; step = salaryRankMin.step;
} }
} else { } else {
step = 1; step = 0.5;
} }
} }
@ -741,15 +781,29 @@ export class SalaryPeriodEmployeeController extends Controller {
} }
if (step == null || step == 0) { if (step == null || step == 0) {
if (salaryFormula != null) { 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({ let salaryRankMin = await this.salaryRankRepository.findOne({
where: { where: {
salaryMonth: salaryMonth: salary,
salaryProfile.amount != null && salaryProfile.amount > 0
? salaryProfile.amount
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? salaryFormula.salaryMin
: 0,
salaryEmployee_: { salaryEmployee_: {
isActive: true, isActive: true,
group: group, group: group,
@ -757,15 +811,11 @@ export class SalaryPeriodEmployeeController extends Controller {
}, },
order: { salaryMonth: "ASC" }, order: { salaryMonth: "ASC" },
}); });
if (salaryRankMin == null) { if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({ salaryRankMin = await this.salaryRankRepository.findOne({
where: { where: {
salaryMonth: salaryMonth: MoreThan(salary),
salaryProfile.amount != null && salaryProfile.amount > 0
? MoreThanOrEqual(salaryProfile.amount)
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? MoreThanOrEqual(salaryFormula.salaryMin)
: 0,
salaryEmployee_: { salaryEmployee_: {
isActive: true, isActive: true,
group: group, group: group,
@ -773,12 +823,42 @@ export class SalaryPeriodEmployeeController extends Controller {
}, },
order: { salaryMonth: "ASC" }, 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 { } else {
step = salaryRankMin.step; step = salaryRankMin.step;
} }
} else { } else {
step = 1; step = 0.5;
} }
} }
@ -1069,7 +1149,7 @@ export class SalaryPeriodEmployeeController extends Controller {
isLeave: item.isLeave, isLeave: item.isLeave,
isRetired: item.isRetired, isRetired: item.isRetired,
isReserve: item.isReserve, isReserve: item.isReserve,
isNext: item.isNext isNext: item.isNext,
})); }));
return new HttpSuccess({ data: mapSalaryProfile, total }); return new HttpSuccess({ data: mapSalaryProfile, total });
} }
@ -1220,15 +1300,29 @@ export class SalaryPeriodEmployeeController extends Controller {
} }
if (step == null || step == 0) { if (step == null || step == 0) {
if (salaryFormula != null) { 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({ let salaryRankMin = await this.salaryRankRepository.findOne({
where: { where: {
salaryMonth: salaryMonth: salary,
salaryProfile.amount != null && salaryProfile.amount > 0
? salaryProfile.amount
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? salaryFormula.salaryMin
: 0,
salaryEmployee_: { salaryEmployee_: {
isActive: true, isActive: true,
group: group, group: group,
@ -1236,15 +1330,11 @@ export class SalaryPeriodEmployeeController extends Controller {
}, },
order: { salaryMonth: "ASC" }, order: { salaryMonth: "ASC" },
}); });
if (salaryRankMin == null) { if (salaryRankMin == null) {
salaryRankMin = await this.salaryRankRepository.findOne({ salaryRankMin = await this.salaryRankRepository.findOne({
where: { where: {
salaryMonth: salaryMonth: MoreThan(salary),
salaryProfile.amount != null && salaryProfile.amount > 0
? MoreThanOrEqual(salaryProfile.amount)
: salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0
? MoreThanOrEqual(salaryFormula.salaryMin)
: 0,
salaryEmployee_: { salaryEmployee_: {
isActive: true, isActive: true,
group: group, group: group,
@ -1252,12 +1342,42 @@ export class SalaryPeriodEmployeeController extends Controller {
}, },
order: { salaryMonth: "ASC" }, 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 { } else {
step = salaryRankMin.step; step = salaryRankMin.step;
} }
} else { } else {
step = 1; step = 0.5;
} }
} }

View file

@ -20,7 +20,7 @@ export class SalaryFormulaEmployee extends EntityBase {
comment: "ขั้นต่ำสุด", comment: "ขั้นต่ำสุด",
default: null, default: null,
}) })
salaryMin?: number | null; salaryMin: number | null;
@Column({ @Column({
nullable: true, nullable: true,
@ -115,7 +115,7 @@ export class UpdateSalaryFormulaEmployee {
position: string; position: string;
@Column() @Column()
salaryMin?: number | null; salaryMin: number | null;
@Column() @Column()
salary?: number | null; salary?: number | null;