update_table_salaryProfile_add_isNext
This commit is contained in:
parent
8d492370b6
commit
20c5e39ff7
3 changed files with 250 additions and 27 deletions
|
|
@ -239,6 +239,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
if (!salarys) {
|
if (!salarys) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
|
let type = salaryProfile.type;
|
||||||
//SalaryRank
|
//SalaryRank
|
||||||
let salaryRanks: any = null;
|
let salaryRanks: any = null;
|
||||||
if (salaryProfile.amount != null) {
|
if (salaryProfile.amount != null) {
|
||||||
|
|
@ -246,19 +247,82 @@ export class SalaryPeriodController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
salaryId: salarys.id,
|
salaryId: salarys.id,
|
||||||
salary: salaryProfile.amount,
|
salary: salaryProfile.amount,
|
||||||
|
isNext: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (salaryRanks == null) {
|
||||||
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: MoreThan(salaryProfile.amount),
|
||||||
|
isNext: false,
|
||||||
|
},
|
||||||
|
order: { salary: "DESC" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (salaryProfile.type == "HAFT") {
|
||||||
|
if (salaryRanks.salaryHalfSpecial != null && salaryRanks.salaryHalfSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (salaryProfile.type == "FULL") {
|
||||||
|
if (salaryRanks.salaryFullSpecial != null && salaryRanks.salaryFullSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
if (salaryRanks.salaryHalfSpecial == null && salaryRanks.salaryHalfSpecial == 0) {
|
||||||
|
type = "HAFT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (salaryProfile.type == "FULLHAFT") {
|
||||||
|
if (salaryRanks.salaryFullHalfSpecial != null && salaryRanks.salaryFullHalfSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
if (salaryRanks.salaryFullSpecial == null && salaryRanks.salaryFullSpecial == 0) {
|
||||||
|
type = "HAFT";
|
||||||
|
} else if (
|
||||||
|
salaryRanks.salaryHalfSpecial == null &&
|
||||||
|
salaryRanks.salaryHalfSpecial == 0
|
||||||
|
) {
|
||||||
|
type = "FULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (salaryProfile.type == "NONE") {
|
salaryProfile.isNext = false;
|
||||||
|
if (type == "NONE") {
|
||||||
salaryProfile.amountSpecial = 0;
|
salaryProfile.amountSpecial = 0;
|
||||||
salaryProfile.amountUse = 0;
|
salaryProfile.amountUse = 0;
|
||||||
salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount;
|
salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount;
|
||||||
} else if (salaryProfile.type == "PENDING") {
|
} else if (type == "PENDING") {
|
||||||
salaryProfile.amountSpecial = 0;
|
salaryProfile.amountSpecial = 0;
|
||||||
salaryProfile.amountUse = 0;
|
salaryProfile.amountUse = 0;
|
||||||
salaryProfile.positionSalaryAmount = 0;
|
salaryProfile.positionSalaryAmount = 0;
|
||||||
} else if (salaryProfile.type == "HAFT") {
|
} else if (type == "HAFT") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryHalfSpecial == null
|
salaryRanks == null || salaryRanks.salaryHalfSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -272,7 +336,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryHalf - salaryProfile.amount;
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
|
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
|
||||||
} else if (salaryProfile.type == "FULL") {
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
|
} else if (type == "FULL") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryFullSpecial == null
|
salaryRanks == null || salaryRanks.salaryFullSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -286,7 +351,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFull - salaryProfile.amount;
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
|
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
|
||||||
} else if (salaryProfile.type == "FULLHAFT") {
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
|
} else if (type == "FULLHAFT") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryFullHalfSpecial == null
|
salaryRanks == null || salaryRanks.salaryFullHalfSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -300,6 +366,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
|
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
|
||||||
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
} else {
|
} else {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
|
|
@ -479,6 +546,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
if (!salarys) {
|
if (!salarys) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
|
salaryProfile.type = body.type;
|
||||||
|
salaryProfile.isReserve = body.isReserve;
|
||||||
|
let type = salaryProfile.type;
|
||||||
//SalaryRank
|
//SalaryRank
|
||||||
let salaryRanks: any = null;
|
let salaryRanks: any = null;
|
||||||
if (salaryProfile.amount != null) {
|
if (salaryProfile.amount != null) {
|
||||||
|
|
@ -486,18 +556,82 @@ export class SalaryPeriodController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
salaryId: salarys.id,
|
salaryId: salarys.id,
|
||||||
salary: salaryProfile.amount,
|
salary: salaryProfile.amount,
|
||||||
|
isNext: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (salaryRanks == null) {
|
||||||
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: MoreThan(salaryProfile.amount),
|
||||||
|
isNext: false,
|
||||||
|
},
|
||||||
|
order: { salary: "DESC" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (salaryProfile.type == "HAFT") {
|
||||||
|
if (salaryRanks.salaryHalfSpecial != null && salaryRanks.salaryHalfSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (salaryProfile.type == "FULL") {
|
||||||
|
if (salaryRanks.salaryFullSpecial != null && salaryRanks.salaryFullSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
if (salaryRanks.salaryHalfSpecial == null && salaryRanks.salaryHalfSpecial == 0) {
|
||||||
|
type = "HAFT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (salaryProfile.type == "FULLHAFT") {
|
||||||
|
if (salaryRanks.salaryFullHalfSpecial != null && salaryRanks.salaryFullHalfSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
if (salaryRanks.salaryFullSpecial == null && salaryRanks.salaryFullSpecial == 0) {
|
||||||
|
type = "HAFT";
|
||||||
|
} else if (
|
||||||
|
salaryRanks.salaryHalfSpecial == null &&
|
||||||
|
salaryRanks.salaryHalfSpecial == 0
|
||||||
|
) {
|
||||||
|
type = "FULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (body.type == "NONE") {
|
|
||||||
|
salaryProfile.isNext = false;
|
||||||
|
if (type == "NONE") {
|
||||||
salaryProfile.amountSpecial = 0;
|
salaryProfile.amountSpecial = 0;
|
||||||
salaryProfile.amountUse = 0;
|
salaryProfile.amountUse = 0;
|
||||||
salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount;
|
salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount;
|
||||||
} else if (body.type == "PENDING") {
|
} else if (type == "PENDING") {
|
||||||
salaryProfile.amountSpecial = 0;
|
salaryProfile.amountSpecial = 0;
|
||||||
salaryProfile.amountUse = 0;
|
salaryProfile.amountUse = 0;
|
||||||
salaryProfile.positionSalaryAmount = 0;
|
salaryProfile.positionSalaryAmount = 0;
|
||||||
} else if (body.type == "HAFT") {
|
} else if (type == "HAFT") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryHalfSpecial == null
|
salaryRanks == null || salaryRanks.salaryHalfSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -511,7 +645,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryHalf - salaryProfile.amount;
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
|
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
|
||||||
} else if (body.type == "FULL") {
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
|
} else if (type == "FULL") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryFullSpecial == null
|
salaryRanks == null || salaryRanks.salaryFullSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -525,7 +660,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFull - salaryProfile.amount;
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
|
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
|
||||||
} else if (body.type == "FULLHAFT") {
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
|
} else if (type == "FULLHAFT") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryFullHalfSpecial == null
|
salaryRanks == null || salaryRanks.salaryFullHalfSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -539,11 +675,10 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
|
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
|
||||||
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
} else {
|
} else {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
salaryProfile.type = body.type;
|
|
||||||
salaryProfile.isReserve = body.isReserve;
|
|
||||||
await this.salaryProfileRepository.save(salaryProfile);
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
|
||||||
if (salaryProfile.salaryOrg) {
|
if (salaryProfile.salaryOrg) {
|
||||||
|
|
@ -744,34 +879,35 @@ export class SalaryPeriodController extends Controller {
|
||||||
delete salaryProfile.id;
|
delete salaryProfile.id;
|
||||||
salaryProfile.type = salaryProfile.type.toUpperCase();
|
salaryProfile.type = salaryProfile.type.toUpperCase();
|
||||||
//Type & Level
|
//Type & Level
|
||||||
const type = await this.posTypeRepository.findOne({
|
const posType = await this.posTypeRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeName: salaryProfile.posType,
|
posTypeName: salaryProfile.posType,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!type) {
|
if (!posType) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบประเภทตำแหน่ง");
|
||||||
}
|
}
|
||||||
const level = await this.posLevelRepository.findOne({
|
const posLevel = await this.posLevelRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeId: type.id,
|
posTypeId: posType.id,
|
||||||
posLevelName: salaryProfile.posLevel,
|
posLevelName: salaryProfile.posLevel,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!level) {
|
if (!posLevel) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
//Salary
|
//Salary
|
||||||
const salarys = await this.salaryRepository.findOne({
|
const salarys = await this.salaryRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
posTypeId: level.posTypeId,
|
posTypeId: posLevel.posTypeId,
|
||||||
posLevelId: level.id,
|
posLevelId: posLevel.id,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!salarys) {
|
if (!salarys) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง");
|
||||||
}
|
}
|
||||||
|
let type = salaryProfile.type;
|
||||||
//SalaryRank
|
//SalaryRank
|
||||||
let salaryRanks: any = null;
|
let salaryRanks: any = null;
|
||||||
if (salaryProfile.amount != null) {
|
if (salaryProfile.amount != null) {
|
||||||
|
|
@ -779,19 +915,82 @@ export class SalaryPeriodController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
salaryId: salarys.id,
|
salaryId: salarys.id,
|
||||||
salary: salaryProfile.amount,
|
salary: salaryProfile.amount,
|
||||||
|
isNext: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (salaryRanks == null) {
|
||||||
|
salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: MoreThan(salaryProfile.amount),
|
||||||
|
isNext: false,
|
||||||
|
},
|
||||||
|
order: { salary: "DESC" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (salaryProfile.type == "HAFT") {
|
||||||
|
if (salaryRanks.salaryHalfSpecial != null && salaryRanks.salaryHalfSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (salaryProfile.type == "FULL") {
|
||||||
|
if (salaryRanks.salaryFullSpecial != null && salaryRanks.salaryFullSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
if (salaryRanks.salaryHalfSpecial == null && salaryRanks.salaryHalfSpecial == 0) {
|
||||||
|
type = "HAFT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (salaryProfile.type == "FULLHAFT") {
|
||||||
|
if (salaryRanks.salaryFullHalfSpecial != null && salaryRanks.salaryFullHalfSpecial > 0) {
|
||||||
|
let _salaryRanks = await this.salaryRankRepository.findOne({
|
||||||
|
where: {
|
||||||
|
salaryId: salarys.id,
|
||||||
|
salary: salaryProfile.amount,
|
||||||
|
isNext: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (_salaryRanks != null) {
|
||||||
|
salaryRanks = _salaryRanks;
|
||||||
|
if (salaryRanks.salaryFullSpecial == null && salaryRanks.salaryFullSpecial == 0) {
|
||||||
|
type = "HAFT";
|
||||||
|
} else if (
|
||||||
|
salaryRanks.salaryHalfSpecial == null &&
|
||||||
|
salaryRanks.salaryHalfSpecial == 0
|
||||||
|
) {
|
||||||
|
type = "FULL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (salaryProfile.type == "NONE") {
|
salaryProfile.isNext = false;
|
||||||
|
if (type == "NONE") {
|
||||||
salaryProfile.amountSpecial = 0;
|
salaryProfile.amountSpecial = 0;
|
||||||
salaryProfile.amountUse = 0;
|
salaryProfile.amountUse = 0;
|
||||||
salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount;
|
salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount;
|
||||||
} else if (salaryProfile.type == "PENDING") {
|
} else if (type == "PENDING") {
|
||||||
salaryProfile.amountSpecial = 0;
|
salaryProfile.amountSpecial = 0;
|
||||||
salaryProfile.amountUse = 0;
|
salaryProfile.amountUse = 0;
|
||||||
salaryProfile.positionSalaryAmount = 0;
|
salaryProfile.positionSalaryAmount = 0;
|
||||||
} else if (salaryProfile.type == "HAFT") {
|
} else if (type == "HAFT") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryHalfSpecial == null
|
salaryRanks == null || salaryRanks.salaryHalfSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -805,7 +1004,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryHalf - salaryProfile.amount;
|
: salaryRanks.salaryHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
|
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
|
||||||
} else if (salaryProfile.type == "FULL") {
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
|
} else if (type == "FULL") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryFullSpecial == null
|
salaryRanks == null || salaryRanks.salaryFullSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -819,7 +1019,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFull - salaryProfile.amount;
|
: salaryRanks.salaryFull - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
|
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
|
||||||
} else if (salaryProfile.type == "FULLHAFT") {
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
|
} else if (type == "FULLHAFT") {
|
||||||
salaryProfile.amountSpecial =
|
salaryProfile.amountSpecial =
|
||||||
salaryRanks == null || salaryRanks.salaryFullHalfSpecial == null
|
salaryRanks == null || salaryRanks.salaryFullHalfSpecial == null
|
||||||
? 0
|
? 0
|
||||||
|
|
@ -833,10 +1034,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
: salaryRanks.salaryFullHalf - salaryProfile.amount;
|
||||||
salaryProfile.positionSalaryAmount =
|
salaryProfile.positionSalaryAmount =
|
||||||
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
|
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
|
||||||
|
salaryProfile.isNext = salaryRanks == null ? 0 : salaryRanks.isNext;
|
||||||
} else {
|
} else {
|
||||||
salaryProfile.amountSpecial = 0;
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
salaryProfile.amountUse = 0;
|
|
||||||
salaryProfile.positionSalaryAmount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
salaryProfile.salaryOrgId = salaryOrg.id;
|
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||||
|
|
@ -1210,6 +1410,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||||
salaryProfileNew.positionSalaryAmount =
|
salaryProfileNew.positionSalaryAmount =
|
||||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||||
|
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
||||||
}
|
}
|
||||||
await this.salaryProfileRepository.save(salaryProfileNew);
|
await this.salaryProfileRepository.save(salaryProfileNew);
|
||||||
}
|
}
|
||||||
|
|
@ -1492,6 +1693,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||||
salaryProfileNew.positionSalaryAmount =
|
salaryProfileNew.positionSalaryAmount =
|
||||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||||
|
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
||||||
}
|
}
|
||||||
await this.salaryProfileRepository.save(salaryProfileNew);
|
await this.salaryProfileRepository.save(salaryProfileNew);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,13 @@ export class SalaryProfile extends EntityBase {
|
||||||
})
|
})
|
||||||
isReserve: boolean;
|
isReserve: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ทะลุขั้น",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isNext: boolean;
|
||||||
|
|
||||||
@ManyToOne(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryProfiles)
|
@ManyToOne(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryProfiles)
|
||||||
@JoinColumn({ name: "salaryOrgId" })
|
@JoinColumn({ name: "salaryOrgId" })
|
||||||
salaryOrg: SalaryOrg;
|
salaryOrg: SalaryOrg;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableSalaryProfileAddIsNext1709807736632 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableSalaryProfileAddIsNext1709807736632'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` ADD \`isNext\` tinyint NULL COMMENT 'ทะลุขั้น' DEFAULT 0`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryProfile\` DROP COLUMN \`isNext\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue