-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06eb979
commit 04257ba
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ment-schedule/e-cert-processing-steps/apply-stop-bc-funding-restriction-part-time-step.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters