cal Quota and fix bug
This commit is contained in:
parent
aeb034a654
commit
037fa442a5
1 changed files with 41 additions and 25 deletions
|
|
@ -145,8 +145,11 @@ export class SalaryPeriodController extends Controller {
|
|||
if (!salaryProfile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ");
|
||||
}
|
||||
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if(salaryProfile?.salaryOrg.snapshot == "SNAP1"){
|
||||
if(salaryProfile.salaryOrg.snapshot == "SNAP1"){
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where:{
|
||||
salaryOrgId:salaryProfile?.salaryOrg.id,
|
||||
|
|
@ -158,8 +161,7 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}
|
||||
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -224,6 +226,10 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.amountSpecial = 0;
|
||||
salaryProfile.amountUse = 0;
|
||||
salaryProfile.positionSalaryAmount = salaryProfile.amount;
|
||||
} else if (salaryProfile.type == "PENDING") {
|
||||
salaryProfile.amountSpecial = 0;
|
||||
salaryProfile.amountUse = 0;
|
||||
salaryProfile.positionSalaryAmount = 0;
|
||||
} else if (salaryProfile.type == "HAFT") {
|
||||
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryHalfSpecial;
|
||||
salaryProfile.amountUse =
|
||||
|
|
@ -257,6 +263,9 @@ export class SalaryPeriodController extends Controller {
|
|||
} else {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if(salaryProfile?.salaryOrg.snapshot == "SNAP1"){
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
|
|
@ -270,8 +279,6 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}
|
||||
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -298,8 +305,11 @@ export class SalaryPeriodController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มการขอเลื่อนเงินเดือน");
|
||||
}
|
||||
|
||||
//หาจำนวน Quota คงเหลือ
|
||||
if(salaryOrg.snapshot == "SNAP1"){
|
||||
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
//หาจำนวน Quota คงเหลือ
|
||||
if(salaryOrg.snapshot == "SNAP1"){
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where:{
|
||||
salaryOrgId:salaryOrg.id,
|
||||
|
|
@ -311,9 +321,6 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}
|
||||
|
||||
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -377,6 +384,10 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.amountSpecial = 0;
|
||||
salaryProfile.amountUse = 0;
|
||||
salaryProfile.positionSalaryAmount = salaryProfile.amount;
|
||||
} else if (body.type == "PENDING") {
|
||||
salaryProfile.amountSpecial = 0;
|
||||
salaryProfile.amountUse = 0;
|
||||
salaryProfile.positionSalaryAmount = 0;
|
||||
} else if (body.type == "HAFT") {
|
||||
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryHalfSpecial;
|
||||
salaryProfile.amountUse =
|
||||
|
|
@ -500,20 +511,6 @@ export class SalaryPeriodController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
|
||||
}
|
||||
|
||||
//หาจำนวน Quota คงเหลือ
|
||||
if(salaryOrg.snapshot == "SNAP1"){
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where:{
|
||||
salaryOrgId:salaryOrg.id,
|
||||
type:"FULL"
|
||||
}
|
||||
});
|
||||
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryOrg.quantityUsed = amountFullType;
|
||||
salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}
|
||||
|
||||
const salaryOrgAll = await this.salaryOrgRepository.find({
|
||||
where: {
|
||||
salaryPeriodId: salaryOrg.salaryPeriodId,
|
||||
|
|
@ -585,7 +582,11 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.amountSpecial = 0;
|
||||
salaryProfile.amountUse = 0;
|
||||
salaryProfile.positionSalaryAmount = salaryProfile.amount;
|
||||
} else if (salaryProfile.type == "HAFT") {
|
||||
} else if (salaryProfile.type == "PENDING") {
|
||||
salaryProfile.amountSpecial = 0;
|
||||
salaryProfile.amountUse = 0;
|
||||
salaryProfile.positionSalaryAmount = 0;
|
||||
}else if (salaryProfile.type == "HAFT") {
|
||||
salaryProfile.amountSpecial = salaryRanks == null ? 0 : salaryRanks.salaryHalfSpecial;
|
||||
salaryProfile.amountUse =
|
||||
salaryRanks == null ||
|
||||
|
|
@ -627,6 +628,21 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.lastUpdateUserId = request.user.sub;
|
||||
salaryProfile.lastUpdateFullName = request.user.name;
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
//หาจำนวน Quota คงเหลือ
|
||||
if(salaryOrg.snapshot == "SNAP1"){
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where:{
|
||||
salaryOrgId:salaryOrg.id,
|
||||
type:"FULL"
|
||||
}
|
||||
});
|
||||
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryOrg.quantityUsed = amountFullType;
|
||||
salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}
|
||||
|
||||
return new HttpSuccess(salaryProfile.id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue