คำนวนโควต้าตอนเพิ่มคน
This commit is contained in:
parent
972539cc6b
commit
8c7ea64985
2 changed files with 28 additions and 14 deletions
|
|
@ -175,7 +175,9 @@ export class SalaryPeriodController extends Controller {
|
|||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount =
|
||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.sixPercentAmount -
|
||||
sumAmountUse.totalAmount -
|
||||
salaryProfile.salaryOrg.spentAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
|
|
@ -322,7 +324,9 @@ export class SalaryPeriodController extends Controller {
|
|||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount =
|
||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.sixPercentAmount -
|
||||
sumAmountUse.totalAmount -
|
||||
salaryProfile.salaryOrg.spentAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
|
|
@ -381,7 +385,8 @@ export class SalaryPeriodController extends Controller {
|
|||
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
const calRemainAmount =
|
||||
salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount;
|
||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
|
|
@ -555,7 +560,9 @@ export class SalaryPeriodController extends Controller {
|
|||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount =
|
||||
salaryProfile.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.sixPercentAmount -
|
||||
sumAmountUse.totalAmount -
|
||||
salaryProfile.salaryOrg.spentAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile.salaryOrg);
|
||||
|
|
@ -793,6 +800,10 @@ export class SalaryPeriodController extends Controller {
|
|||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryOrg.salaryPeriod.period == "APR") {
|
||||
salaryOrg.total = salaryOrg.salaryProfiles.length;
|
||||
salaryOrg.fifteenPercent = Math.floor((salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
salaryOrg.fifteenPoint = (salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg.id,
|
||||
|
|
@ -804,6 +815,10 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
} else if (salaryOrg.salaryPeriod.period == "OCT") {
|
||||
const totalProfile = Extension.sumObjectValues(salaryOrg.salaryProfiles, "amount");
|
||||
salaryOrg.currentAmount = totalProfile;
|
||||
salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select("SUM(salaryProfile.amountUse)", "totalAmount")
|
||||
|
|
@ -812,7 +827,8 @@ export class SalaryPeriodController extends Controller {
|
|||
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
const calRemainAmount =
|
||||
salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount;
|
||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ export class Salarys extends EntityBase {
|
|||
}
|
||||
|
||||
export class CreateSalary {
|
||||
|
||||
@Column()
|
||||
salaryType: string;
|
||||
|
||||
|
|
@ -94,13 +93,13 @@ export class CreateSalary {
|
|||
isActive: boolean;
|
||||
|
||||
@Column()
|
||||
date?: Date;
|
||||
date?: Date | null;
|
||||
|
||||
@Column()
|
||||
startDate?: Date;
|
||||
startDate?: Date | null;
|
||||
|
||||
@Column()
|
||||
endDate?: Date;
|
||||
endDate?: Date | null;
|
||||
|
||||
@Column()
|
||||
details?: string | null;
|
||||
|
|
@ -110,7 +109,6 @@ export class CreateSalary {
|
|||
}
|
||||
|
||||
export class UpdateSalary {
|
||||
|
||||
@Column()
|
||||
salaryType: string;
|
||||
|
||||
|
|
@ -124,13 +122,13 @@ export class UpdateSalary {
|
|||
isActive: boolean;
|
||||
|
||||
@Column()
|
||||
date?: Date;
|
||||
date?: Date | null;
|
||||
|
||||
@Column()
|
||||
startDate?: Date;
|
||||
startDate?: Date | null;
|
||||
|
||||
@Column()
|
||||
endDate?: Date;
|
||||
endDate?: Date | null;
|
||||
|
||||
@Column()
|
||||
details?: string | null;
|
||||
|
|
@ -139,4 +137,4 @@ export class UpdateSalary {
|
|||
isSpecial: boolean;
|
||||
}
|
||||
|
||||
// export type UpdateSalary = Partial<CreateSalary> ;
|
||||
// export type UpdateSalary = Partial<CreateSalary> ;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue