คำนวนโควต้าตอนเพิ่มคน
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();
|
.getRawOne();
|
||||||
const calRemainAmount =
|
const calRemainAmount =
|
||||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
salaryProfile.salaryOrg.sixPercentAmount -
|
||||||
|
sumAmountUse.totalAmount -
|
||||||
|
salaryProfile.salaryOrg.spentAmount;
|
||||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||||
|
|
@ -322,7 +324,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
})
|
})
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const calRemainAmount =
|
const calRemainAmount =
|
||||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
salaryProfile.salaryOrg.sixPercentAmount -
|
||||||
|
sumAmountUse.totalAmount -
|
||||||
|
salaryProfile.salaryOrg.spentAmount;
|
||||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||||
|
|
@ -381,7 +385,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
||||||
})
|
})
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
const calRemainAmount =
|
||||||
|
salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount;
|
||||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||||
salaryOrg.remainingAmount = calRemainAmount;
|
salaryOrg.remainingAmount = calRemainAmount;
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
|
@ -555,7 +560,9 @@ export class SalaryPeriodController extends Controller {
|
||||||
})
|
})
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const calRemainAmount =
|
const calRemainAmount =
|
||||||
salaryProfile.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
salaryProfile.salaryOrg.sixPercentAmount -
|
||||||
|
sumAmountUse.totalAmount -
|
||||||
|
salaryProfile.salaryOrg.spentAmount;
|
||||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||||
await this.salaryOrgRepository.save(salaryProfile.salaryOrg);
|
await this.salaryOrgRepository.save(salaryProfile.salaryOrg);
|
||||||
|
|
@ -793,6 +800,10 @@ export class SalaryPeriodController extends Controller {
|
||||||
// หาจำนวน Quota คงเหลือ
|
// หาจำนวน Quota คงเหลือ
|
||||||
if (salaryOrg.snapshot == "SNAP1") {
|
if (salaryOrg.snapshot == "SNAP1") {
|
||||||
if (salaryOrg.salaryPeriod.period == "APR") {
|
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({
|
const amountFullType = await this.salaryProfileRepository.count({
|
||||||
where: {
|
where: {
|
||||||
salaryOrgId: salaryOrg.id,
|
salaryOrgId: salaryOrg.id,
|
||||||
|
|
@ -804,6 +815,10 @@ export class SalaryPeriodController extends Controller {
|
||||||
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 totalProfile = Extension.sumObjectValues(salaryOrg.salaryProfiles, "amount");
|
||||||
|
salaryOrg.currentAmount = totalProfile;
|
||||||
|
salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||||
|
|
||||||
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")
|
||||||
|
|
@ -812,7 +827,8 @@ export class SalaryPeriodController extends Controller {
|
||||||
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
type: In(["HAFT", "FULL", "FULLHAFT"]),
|
||||||
})
|
})
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
const calRemainAmount =
|
||||||
|
salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount;
|
||||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||||
salaryOrg.remainingAmount = calRemainAmount;
|
salaryOrg.remainingAmount = calRemainAmount;
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ export class Salarys extends EntityBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateSalary {
|
export class CreateSalary {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
salaryType: string;
|
salaryType: string;
|
||||||
|
|
||||||
|
|
@ -94,13 +93,13 @@ export class CreateSalary {
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
date?: Date;
|
date?: Date | null;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
startDate?: Date;
|
startDate?: Date | null;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
endDate?: Date;
|
endDate?: Date | null;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
details?: string | null;
|
details?: string | null;
|
||||||
|
|
@ -110,7 +109,6 @@ export class CreateSalary {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateSalary {
|
export class UpdateSalary {
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
salaryType: string;
|
salaryType: string;
|
||||||
|
|
||||||
|
|
@ -124,13 +122,13 @@ export class UpdateSalary {
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
date?: Date;
|
date?: Date | null;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
startDate?: Date;
|
startDate?: Date | null;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
endDate?: Date;
|
endDate?: Date | null;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
details?: string | null;
|
details?: string | null;
|
||||||
|
|
@ -139,4 +137,4 @@ export class UpdateSalary {
|
||||||
isSpecial: boolean;
|
isSpecial: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// export type UpdateSalary = Partial<CreateSalary> ;
|
// export type UpdateSalary = Partial<CreateSalary> ;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue