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;
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if(salaryOrg.salaryPeriod.period == "APR"){
|
||||
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);
|
||||
}else if(salaryOrg.salaryPeriod.period == "OCT"){
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
||||
.where({
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: 'FULL',
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
if (salaryOrg) {
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if(salaryOrg.salaryPeriod.period == "APR"){
|
||||
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);
|
||||
}else if(salaryOrg.salaryPeriod.period == "OCT"){
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
||||
.where({
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: 'FULL',
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue