Skip to content

Commit 2088b3f

Browse files
#1815 - Ignore restrictions for specific disbursement(s) within an assessment (#3679)
- Created the `restrictionBypassesResolutionStep` to resolve active bypasses when needed as the last step in the e-Cert generation process for part-time and full-time. - Changed the `getEligibleDisbursements` query adding the information from the active bypasses and the restriction bypassed. - Method `getRestrictionByActionType` was changed to use the effective restrictions (active restrictions not bypassed) instead of the active restrictions. - The BCLM step is ignored at the beginning of its execution. If the BCLM restriction is in place the method would not be executed (logic already in place). The condition based on the bypass was added either way to ensure that whatever happens to the BCLM logic the bypass will guarantee that the store step will be ignored. - A log was created to list all the active restrictions known during the e-Cert calculation. The log records the restriction code and the student restriction ID for easier troubleshooting. - Created factories for the new table `ApplicationRestrictionBypass`. ### E2E Tests #### Full-time - Should generate BC awards amounts with no restriction deductions and resolve the restriction bypass when a student has an active 'BCLM' restriction and it is bypassed with behavior 'Next disbursement only'. - Should have the e-Cert generated for a full-time application and the bypass active when a student has an active 'Stop full time disbursement' restriction and it is bypassed with behavior 'All disbursements'. - Should prevent an e-Cert generation and keep the bypass active when multiple 'Stop full time disbursement' restrictions exist and only one is bypassed and it is bypassed with behavior 'Next disbursement only'. #### Part-time - Should have the e-Cert generated for a part-time application and the bypass resolved when a student has an active 'Stop part time disbursement' restriction and it is bypassed with behavior 'Next disbursement only'. - Should prevent an e-Cert generation and keep the bypass active when multiple 'Stop part time disbursement' restrictions exist and only one is bypassed and it is bypassed with behavior 'Next disbursement only'. ### Log sample without the bypass ![image](https://github.com/user-attachments/assets/cc75c575-df20-49b3-aefc-ebaac508b9f3) ### Log sample with a bypass in place. ![image](https://github.com/user-attachments/assets/be96088b-458e-41d2-abf1-f56d5d610d1b) ### Noted generated when a bypass is resolved by the system AC was adjusted later to include the application number. ![image](https://github.com/user-attachments/assets/49f3180e-ae52-4f08-b169-9fe5ac93628d)
1 parent 51351a1 commit 2088b3f

22 files changed

+1081
-26
lines changed

Diff for: sims.code-workspace

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"cSpell.words": [
9292
"AEST",
9393
"bcag",
94+
"BCLM",
9495
"BCSC",
9596
"BCSG",
9697
"bcsl",

Diff for: sources/packages/backend/apps/api/src/route-controllers/assessment/_tests_/e2e/assessment.students.controller.confirmAssessmentNOA.e2e-spec.ts

+41
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ import {
1717
createFakeDisbursementValue,
1818
createFakeMSFAANumber,
1919
MSFAAStates,
20+
saveFakeApplicationRestrictionBypass,
21+
createFakeUser,
2022
} from "@sims/test-utils";
2123
import {
24+
Application,
2225
ApplicationStatus,
2326
AssessmentStatus,
2427
AssessmentTriggerType,
2528
COEStatus,
2629
DisbursementScheduleStatus,
2730
DisbursementValueType,
2831
OfferingIntensity,
32+
RestrictionActionType,
33+
RestrictionBypassBehaviors,
34+
User,
2935
WorkflowData,
3036
} from "@sims/sims-db";
3137
import { TestingModule } from "@nestjs/testing";
@@ -34,13 +40,16 @@ describe("AssessmentStudentsController(e2e)-confirmAssessmentNOA", () => {
3440
let app: INestApplication;
3541
let db: E2EDataSources;
3642
let appModule: TestingModule;
43+
let sharedMinistryUser: User;
3744

3845
beforeAll(async () => {
3946
const { nestApplication, dataSource, module } =
4047
await createTestingAppModule();
4148
app = nestApplication;
4249
appModule = module;
4350
db = createE2EDataSources(dataSource);
51+
// Create a Ministry user to b used, for instance, for audit.
52+
sharedMinistryUser = await db.user.save(createFakeUser());
4453
});
4554

4655
it("Should allow NOA approval for the current application assessment when the application has multiple assessments.", async () => {
@@ -120,13 +129,44 @@ describe("AssessmentStudentsController(e2e)-confirmAssessmentNOA", () => {
120129
});
121130
});
122131

132+
it(`Should allow NOA approval when the current assessment is blocked by a '${RestrictionActionType.StopPartTimeDisbursement}' restriction but the application has a restriction bypass.`, async () => {
133+
// Arrange
134+
const { application } = await createApplicationAndAssessments();
135+
// Create a student restriction and a bypass to allow the NOA to be accepted.
136+
await saveFakeApplicationRestrictionBypass(
137+
db,
138+
{
139+
application,
140+
bypassCreatedBy: sharedMinistryUser,
141+
creator: sharedMinistryUser,
142+
},
143+
{
144+
restrictionActionType: RestrictionActionType.StopPartTimeDisbursement,
145+
initialValues: {
146+
bypassBehavior: RestrictionBypassBehaviors.NextDisbursementOnly,
147+
},
148+
},
149+
);
150+
const studentUserToken = await getStudentToken(
151+
FakeStudentUsersTypes.FakeStudentUserType1,
152+
);
153+
const endpoint = `/students/assessment/${application.currentAssessment.id}/confirm-assessment`;
154+
155+
// Act/Assert
156+
await request(app.getHttpServer())
157+
.patch(endpoint)
158+
.auth(studentUserToken, BEARER_AUTH_TYPE)
159+
.expect(HttpStatus.OK);
160+
});
161+
123162
/**
124163
* Creates an application with two assessments.
125164
* @returns Old and new Assessment ID.
126165
*/
127166
async function createApplicationAndAssessments(): Promise<{
128167
currentAssessmentId: number;
129168
oldAssessmentId: number;
169+
application: Application;
130170
}> {
131171
// Create the new student to be mocked as the authenticated one.
132172
const student = await saveFakeStudent(db.dataSource);
@@ -192,6 +232,7 @@ describe("AssessmentStudentsController(e2e)-confirmAssessmentNOA", () => {
192232
return {
193233
currentAssessmentId: newCurrentAssessment.id,
194234
oldAssessmentId: oldAssessment.id,
235+
application,
195236
};
196237
}
197238

0 commit comments

Comments
 (0)