Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bidyashish committed Nov 18, 2024
1 parent 06eb979 commit 04257ba
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe(
},
]);
});

// TODO: Add test for full-time.
it(
"Should create a notification for the ministry and student for a blocked disbursement when the total assessed award is 0" +
" and there are no previously existing notifications for the disbursement.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CreateBCTotalGrantsStep,
PersistCalculationsStep,
ValidateDisbursementPartTimeStep,
ApplyStopBCFundingRestrictionPartTimeStep,
RestrictionBypassesResolutionStep,
} from "../e-cert-processing-steps";
import { ECertGenerationService } from "../e-cert-generation.service";
Expand All @@ -30,6 +31,7 @@ export class PartTimeCalculationProcess extends ECertCalculationProcess {
private readonly createBCTotalGrantsStep: CreateBCTotalGrantsStep,
private readonly persistCalculationsStep: PersistCalculationsStep,
private readonly restrictionBypassesResolutionStep: RestrictionBypassesResolutionStep,
private readonly applyStopBCFundingRestrictionPartTimeStep: ApplyStopBCFundingRestrictionPartTimeStep,
) {
super(dataSource, eCertNotificationService);
}
Expand Down Expand Up @@ -61,6 +63,7 @@ export class PartTimeCalculationProcess extends ECertCalculationProcess {
this.createBCTotalGrantsStep,
this.persistCalculationsStep,
this.restrictionBypassesResolutionStep,
this.applyStopBCFundingRestrictionPartTimeStep,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Injectable } from "@nestjs/common";
import { EntityManager } from "typeorm";
import { Restriction, RestrictionActionType } from "@sims/sims-db";
import {
getRestrictionByActionType,
shouldStopBCFunding,
} from "./e-cert-steps-utils";
import { ECertProcessStep } from "./e-cert-steps-models";
import { ProcessSummary } from "@sims/utilities/logger";
import { EligibleECertDisbursement } from "../disbursement-schedule.models";

/**
* Check active student restriction that should stop
* any BC funding from being disbursed.
*/
@Injectable()
export class ApplyStopBCFundingRestrictionPartTimeStep
implements ECertProcessStep
{
/**
* Check active student restriction that should stop any BC funding from being disbursed.
* In case some is present, BC awards will be updated to not be disbursed.
* @param eCertDisbursement eligible disbursement to be potentially added to an e-Cert.
* @param _entityManager not used for this step.
* @param log cumulative log summary.
*/
executeStep(
eCertDisbursement: EligibleECertDisbursement,
_entityManager: EntityManager,
log: ProcessSummary,
): boolean {
log.info(
`Checking '${RestrictionActionType.StopPartTimeBCFunding}' restriction.`,
);
for (const disbursementValue of eCertDisbursement.disbursement
.disbursementValues) {
if (shouldStopBCFunding(eCertDisbursement, disbursementValue)) {
log.info(`Applying restriction for ${disbursementValue.valueCode}.`);
const restriction = getRestrictionByActionType(
eCertDisbursement,
RestrictionActionType.StopPartTimeBCFunding,
);
disbursementValue.restrictionAmountSubtracted =
disbursementValue.valueAmount -
(disbursementValue.disbursedAmountSubtracted ?? 0) -
(disbursementValue.overawardAmountSubtracted ?? 0);
disbursementValue.effectiveAmount = 0;
disbursementValue.restrictionSubtracted = {
id: restriction.id,
} as Restriction;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from "./validate-disbursement-base";
export * from "./validate-disbursement-full-time-step";
export * from "./validate-disbursement-part-time-step";
export * from "./restriction-bypasses-resolution-step";
export * from "./apply-stop-bc-funding-restriction-part-time-step";

0 comments on commit 04257ba

Please sign in to comment.