fix
This commit is contained in:
parent
134fb53fce
commit
a1b0936bf6
1 changed files with 28 additions and 27 deletions
|
|
@ -343,33 +343,34 @@ export class SalaryPeriodController extends Controller {
|
||||||
|
|
||||||
salaryProfile.salaryOrgId = salaryOrg.id;
|
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||||
await this.salaryProfileRepository.save(salaryProfile);
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
if (salaryOrg) {
|
||||||
// หาจำนวน Quota คงเหลือ
|
// หาจำนวน Quota คงเหลือ
|
||||||
if (salaryOrg.snapshot == "SNAP1") {
|
if (salaryOrg.snapshot == "SNAP1") {
|
||||||
if(salaryOrg.salaryPeriod.period == "APR"){
|
if(salaryOrg.salaryPeriod.period == "APR"){
|
||||||
const amountFullType = await this.salaryProfileRepository.count({
|
const amountFullType = await this.salaryProfileRepository.count({
|
||||||
where: {
|
where: {
|
||||||
salaryOrgId: salaryOrg.id,
|
salaryOrgId: salaryOrg.id,
|
||||||
type: "FULL",
|
type: "FULL",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
||||||
salaryOrg.quantityUsed = amountFullType;
|
salaryOrg.quantityUsed = amountFullType;
|
||||||
salaryOrg.remainQuota = calRemainQuota;
|
salaryOrg.remainQuota = calRemainQuota;
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
}else if(salaryOrg.salaryPeriod.period == "OCT"){
|
}else if(salaryOrg.salaryPeriod.period == "OCT"){
|
||||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||||
.createQueryBuilder("salaryProfile")
|
.createQueryBuilder("salaryProfile")
|
||||||
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
||||||
.where({
|
.where({
|
||||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||||
type: 'FULL',
|
type: 'FULL',
|
||||||
})
|
})
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||||
salaryOrg.remainingAmount = calRemainAmount;
|
salaryOrg.remainingAmount = calRemainAmount;
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue