Merge branch 'develop' of github.com:Frappet/bma-ehr-salary into develop
# Conflicts: # src/controllers/SalaryPeriodController.ts
This commit is contained in:
commit
a44c8659fa
1 changed files with 81 additions and 82 deletions
|
|
@ -153,34 +153,33 @@ export class SalaryPeriodController extends Controller {
|
|||
// await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
} else if (salaryProfile.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 =
|
||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}
|
||||
// if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
} else if (salaryProfile.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 = salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}
|
||||
// }
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -288,34 +287,33 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
} else if (salaryProfile.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 =
|
||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}
|
||||
// if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
} else if (salaryProfile.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 = salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}
|
||||
// }
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -344,9 +342,9 @@ export class SalaryPeriodController extends Controller {
|
|||
|
||||
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryOrg) {
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
|
|
@ -372,6 +370,7 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -692,31 +691,31 @@ export class SalaryPeriodController extends Controller {
|
|||
|
||||
// หาจำนวน 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.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(salaryProfile.id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue