Skip to content

Commit d8c1e3d

Browse files
authored
#1761 - Handling full time BCSL lifetime and federal maximums (#1886)
#1761 - Handling full-time BCSL lifetime and federal maximums (#1886)
1 parent 2cfff52 commit d8c1e3d

File tree

26 files changed

+317
-96
lines changed

26 files changed

+317
-96
lines changed

sources/packages/backend/apps/api/src/app.aest.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import {
7979
DisbursementOverawardService,
8080
ConfirmationOfEnrollmentService,
8181
NoteSharedService,
82+
RestrictionSharedService,
8283
} from "@sims/services";
8384

8485
@Module({
@@ -158,6 +159,7 @@ import {
158159
DisbursementOverawardService,
159160
NoteSharedService,
160161
OverawardControllerService,
162+
RestrictionSharedService,
161163
],
162164
})
163165
export class AppAESTModule {}

sources/packages/backend/apps/api/src/app.institutions.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
StudentRestrictionSharedService,
5454
WorkflowClientService,
5555
NoteSharedService,
56+
RestrictionSharedService,
5657
} from "@sims/services";
5758
import {
5859
SFASIndividualService,
@@ -121,6 +122,7 @@ import { UserControllerService } from "./route-controllers/user/user.controller.
121122
DisbursementOverawardService,
122123
NoteSharedService,
123124
StudentControllerService,
125+
RestrictionSharedService,
124126
],
125127
})
126128
export class AppInstitutionsModule {}

sources/packages/backend/apps/api/src/app.students.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {
5050
StudentRestrictionSharedService,
5151
WorkflowClientService,
5252
NoteSharedService,
53+
RestrictionSharedService,
5354
} from "@sims/services";
5455
import {
5556
SFASIndividualService,
@@ -107,6 +108,7 @@ import { ATBCIntegrationModule } from "@sims/integrations/atbc-integration";
107108
CRAIncomeVerificationService,
108109
SupportingUserService,
109110
StudentRestrictionSharedService,
111+
RestrictionSharedService,
110112
DisbursementOverawardService,
111113
NoteSharedService,
112114
OverawardControllerService,

sources/packages/backend/apps/api/src/app.supporting-users.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
StudentRestrictionSharedService,
2020
WorkflowClientService,
2121
NoteSharedService,
22+
RestrictionSharedService,
2223
} from "@sims/services";
2324
import {
2425
SFASIndividualService,
@@ -48,6 +49,7 @@ import { AuthModule } from "./auth/auth.module";
4849
EducationProgramOfferingValidationService,
4950
WorkflowClientService,
5051
StudentRestrictionSharedService,
52+
RestrictionSharedService,
5153
DisbursementOverawardService,
5254
NoteSharedService,
5355
InstitutionLocationService,

sources/packages/backend/apps/api/src/services/application/application.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ export class ApplicationService extends RecordDataModelService<Application> {
12841284
return !!(await this.repo.findOne({
12851285
where: {
12861286
applicationNumber: applicationNumber,
1287-
student: { id: studentId } as Student,
1287+
student: { id: studentId },
12881288
},
12891289
select: { id: true },
12901290
}));

sources/packages/backend/apps/api/src/services/restriction/restriction.service.ts

-18
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
RestrictionType,
66
} from "@sims/sims-db";
77
import { DataSource } from "typeorm";
8-
import { RestrictionCode } from "./models/restriction.model";
98

109
/**
1110
* Service layer for restrictions.
@@ -74,21 +73,4 @@ export class RestrictionService extends RecordDataModelService<Restriction> {
7473
}
7574
return restrictionQuery.getOne();
7675
}
77-
78-
/**
79-
* Fetch the restriction with requested restriction code.
80-
* @param restrictionCode restriction code.
81-
* @returns restriction.
82-
*/
83-
async getRestrictionByCode(
84-
restrictionCode: RestrictionCode,
85-
): Promise<Restriction> {
86-
return this.repo
87-
.createQueryBuilder("restriction")
88-
.select("restriction.id")
89-
.where("restriction.restrictionCode = :restrictionCode", {
90-
restrictionCode,
91-
})
92-
.getOne();
93-
}
9476
}

sources/packages/backend/apps/api/src/services/restriction/student-restriction.service.ts

+13-47
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ import {
77
User,
88
Restriction,
99
Student,
10-
Application,
1110
EducationProgramOffering,
1211
RestrictionActionType,
1312
} from "@sims/sims-db";
1413
import { DataSource, EntityManager } from "typeorm";
1514
import { CustomNamedError } from "@sims/utilities";
16-
import { RestrictionService } from "./restriction.service";
17-
import { RestrictionCode } from "./models/restriction.model";
1815
import {
1916
NoteSharedService,
17+
RestrictionCode,
2018
StudentRestrictionSharedService,
2119
} from "@sims/services";
2220
export const RESTRICTION_NOT_ACTIVE = "RESTRICTION_NOT_ACTIVE";
@@ -29,9 +27,8 @@ export const RESTRICTION_NOT_PROVINCIAL = "RESTRICTION_NOT_PROVINCIAL";
2927
export class StudentRestrictionService extends RecordDataModelService<StudentRestriction> {
3028
constructor(
3129
readonly dataSource: DataSource,
32-
private readonly restrictionService: RestrictionService,
3330
private readonly noteSharedService: NoteSharedService,
34-
private readonly studentRestrictionsService: StudentRestrictionSharedService,
31+
private readonly studentRestrictionSharedService: StudentRestrictionSharedService,
3532
) {
3633
super(dataSource.getRepository(StudentRestriction));
3734
}
@@ -145,7 +142,7 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
145142
const newRestriction = await transactionalEntityManager
146143
.getRepository(StudentRestriction)
147144
.save(studentRestriction);
148-
await this.studentRestrictionsService.createNotifications(
145+
await this.studentRestrictionSharedService.createNotifications(
149146
[newRestriction.id],
150147
auditUserId,
151148
transactionalEntityManager,
@@ -171,7 +168,7 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
171168
const studentRestrictionEntity = await this.repo.findOne({
172169
where: {
173170
id: studentRestrictionId,
174-
student: { id: studentId } as Student,
171+
student: { id: studentId },
175172
isActive: true,
176173
},
177174
relations: { restriction: true },
@@ -228,7 +225,7 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
228225
restrictionActions: RestrictionActionType[],
229226
checkAll = false,
230227
): Promise<boolean> {
231-
const query = this.studentRestrictionsService
228+
const query = this.studentRestrictionSharedService
232229
.getExistsBlockRestrictionQuery(checkAll, true)
233230
.setParameters({
234231
studentId,
@@ -262,38 +259,6 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
262259
.getOne());
263260
}
264261

265-
/**
266-
* Create a new student restriction object.
267-
* @param studentId student id.
268-
* @param restrictionCode restriction code.
269-
* @param auditUserId audit user id
270-
* @param applicationId application id.
271-
* @returns a new student restriction object.
272-
*/
273-
async createRestrictionToSave(
274-
studentId: number,
275-
restrictionCode: RestrictionCode,
276-
auditUserId: number,
277-
applicationId: number,
278-
): Promise<StudentRestriction> {
279-
const restriction = await this.restrictionService.getRestrictionByCode(
280-
restrictionCode,
281-
);
282-
if (!restriction) {
283-
throw new Error(
284-
`Requested restriction code ${restrictionCode} not found.`,
285-
);
286-
}
287-
const studentRestriction = new StudentRestriction();
288-
studentRestriction.restriction = {
289-
id: restriction.id,
290-
} as Restriction;
291-
studentRestriction.student = { id: studentId } as Student;
292-
studentRestriction.application = { id: applicationId } as Application;
293-
studentRestriction.creator = { id: auditUserId } as User;
294-
return studentRestriction;
295-
}
296-
297262
/**
298263
* Verify if the student has a valid SIN to apply to the particular offering.
299264
* The SIN number must be a permanent one or a temporary with expiry date later
@@ -358,16 +323,17 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
358323
}
359324

360325
if (mustCreateSINException) {
361-
const restriction = await this.createRestrictionToSave(
362-
studentId,
363-
RestrictionCode.SINF,
364-
auditUserId,
365-
applicationId,
366-
);
326+
const restriction =
327+
await this.studentRestrictionSharedService.createRestrictionToSave(
328+
studentId,
329+
RestrictionCode.SINF,
330+
auditUserId,
331+
applicationId,
332+
);
367333
const newRestriction = await entityManager
368334
.getRepository(StudentRestriction)
369335
.save(restriction);
370-
await this.studentRestrictionsService.createNotifications(
336+
await this.studentRestrictionSharedService.createNotifications(
371337
[newRestriction.id],
372338
auditUserId,
373339
entityManager,

sources/packages/backend/apps/api/src/services/student-file/student-file.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class StudentFileService extends RecordDataModelService<StudentFile> {
128128
.getRepository(StudentFile)
129129
.update(
130130
{
131-
student: { id: studentId } as Student,
131+
student: { id: studentId },
132132
uniqueFileName: In(uniqueFileNames),
133133
},
134134
{

sources/packages/backend/apps/api/src/services/student-scholastic-standings/student-scholastic-standings.service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import { ScholasticStanding } from "./student-scholastic-standings.model";
2323
import { StudentAssessmentService } from "../student-assessment/student-assessment.service";
2424
import { StudentRestrictionService } from "../restriction/student-restriction.service";
2525
import { APPLICATION_CHANGE_NOT_ELIGIBLE } from "../../constants";
26-
import { RestrictionCode } from "../restriction/models/restriction.model";
2726
import { SCHOLASTIC_STANDING_MINIMUM_UNSUCCESSFUL_WEEKS } from "../../utilities";
2827
import {
2928
NotificationActionsService,
29+
RestrictionCode,
3030
StudentRestrictionSharedService,
3131
} from "@sims/services";
3232

@@ -363,7 +363,7 @@ export class StudentScholasticStandingsService extends RecordDataModelService<St
363363
scholasticStandingData.numberOfUnsuccessfulWeeks >=
364364
SCHOLASTIC_STANDING_MINIMUM_UNSUCCESSFUL_WEEKS
365365
) {
366-
return this.studentRestrictionService.createRestrictionToSave(
366+
return this.studentRestrictionSharedService.createRestrictionToSave(
367367
studentId,
368368
RestrictionCode.SSR,
369369
auditUserId,
@@ -387,7 +387,7 @@ export class StudentScholasticStandingsService extends RecordDataModelService<St
387387
? RestrictionCode.SSR
388388
: RestrictionCode.WTHD;
389389

390-
return this.studentRestrictionService.createRestrictionToSave(
390+
return this.studentRestrictionSharedService.createRestrictionToSave(
391391
studentId,
392392
restrictionCode,
393393
auditUserId,
@@ -423,7 +423,7 @@ export class StudentScholasticStandingsService extends RecordDataModelService<St
423423
StudentScholasticStandingChangeType.StudentWithdrewFromProgram,
424424
].includes(scholasticStandingData.scholasticStandingChangeType)
425425
) {
426-
return this.studentRestrictionService.createRestrictionToSave(
426+
return this.studentRestrictionSharedService.createRestrictionToSave(
427427
studentId,
428428
RestrictionCode.PTSSR,
429429
auditUserId,

sources/packages/backend/apps/queue-consumers/src/processors/assessment/cancel-application-assessment.processor.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Process, Processor } from "@nestjs/bull";
22
import { Job } from "bull";
33
import { CancelAssessmentQueueInDTO } from "@sims/services/queue";
44
import {
5-
DisbursementScheduleService,
5+
DisbursementScheduleSharedService,
66
WorkflowClientService,
77
} from "@sims/services";
88
import { QueueNames } from "@sims/utilities";
@@ -25,7 +25,7 @@ export class CancelApplicationAssessmentProcessor {
2525
private readonly dataSource: DataSource,
2626
private readonly workflowClientService: WorkflowClientService,
2727
private readonly studentAssessmentService: StudentAssessmentService,
28-
private readonly disbursementScheduleService: DisbursementScheduleService,
28+
private readonly disbursementScheduleSharedService: DisbursementScheduleSharedService,
2929
) {}
3030

3131
/**
@@ -106,7 +106,7 @@ export class CancelApplicationAssessmentProcessor {
106106
// It must be called after the workflow is cancelled to avoiding further updates on the disbursements after
107107
// the rollback is performed.
108108
await summary.info("Rolling back overawards, if any.");
109-
await this.disbursementScheduleService.rollbackOverawards(
109+
await this.disbursementScheduleSharedService.rollbackOverawards(
110110
assessment.id,
111111
transactionEntityManager,
112112
);

sources/packages/backend/apps/queue-consumers/src/queue-consumers.module.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import {
2525
ProcessArchiveApplicationsScheduler,
2626
} from "./processors";
2727
import {
28-
DisbursementScheduleService,
28+
DisbursementScheduleSharedService,
29+
RestrictionSharedService,
2930
SequenceControlService,
3031
StudentRestrictionSharedService,
3132
WorkflowClientService,
@@ -93,8 +94,9 @@ import { ECEProcessIntegrationScheduler } from "./processors/schedulers/institut
9394
MSFAANumberService,
9495
PartTimeMSFAAProcessIntegrationScheduler,
9596
PartTimeECertProcessIntegrationScheduler,
96-
DisbursementScheduleService,
97+
DisbursementScheduleSharedService,
9798
StudentRestrictionSharedService,
99+
RestrictionSharedService,
98100
FullTimeECertProcessIntegrationScheduler,
99101
FullTimeECertFeedbackIntegrationScheduler,
100102
PartTimeECertFeedbackIntegrationScheduler,

sources/packages/backend/apps/workers/src/controllers/disbursement/disbursement.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from "zeebe-node";
99
// TODO: In the upcoming tasks, either DisbursementScheduleService will be renamed at shared library
1010
// or MSFAA related methods will move to shared library.
11-
import { DisbursementScheduleService as DisbursementScheduleSharedService } from "@sims/services";
11+
import { DisbursementScheduleSharedService } from "@sims/services";
1212
import { DisbursementScheduleService } from "../../services";
1313
import {
1414
SaveDisbursementSchedulesJobInDTO,

sources/packages/backend/apps/workers/src/workers.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from "./services";
2020
import { ZeebeTransportStrategy } from "./zeebe";
2121
import {
22-
DisbursementScheduleService as DisbursementScheduleSharedService,
22+
DisbursementScheduleSharedService,
2323
SequenceControlService,
2424
WorkflowClientService,
2525
ZeebeModule,

sources/packages/backend/libs/integrations/src/esdc-integration/disbursement-receipt-integration/disbursement-receipt-integration.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Module } from "@nestjs/common";
22
import {
33
ReportService,
4+
RestrictionSharedService,
45
SequenceControlService,
56
StudentRestrictionSharedService,
67
} from "@sims/services";
@@ -27,6 +28,7 @@ import {
2728
SequenceControlService,
2829
ReportService,
2930
StudentRestrictionSharedService,
31+
RestrictionSharedService,
3032
],
3133
exports: [
3234
DisbursementReceiptProcessingService,

sources/packages/backend/libs/integrations/src/esdc-integration/e-cert-integration/e-cert-integration.module.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
StudentRestrictionSharedService,
66
NoteSharedService,
77
ConfirmationOfEnrollmentService,
8+
DisbursementScheduleSharedService,
9+
RestrictionSharedService,
810
} from "@sims/services";
911
import { ECertFileHandler } from "./e-cert-file-handler";
1012
import { ECertFullTimeFileFooter } from "./e-cert-full-time-integration/e-cert-files/e-cert-file-footer";
@@ -18,10 +20,10 @@ import {
1820
DisbursementScheduleErrorsService,
1921
DisbursementScheduleService,
2022
ECertGenerationService,
21-
RestrictionService,
2223
SshService,
2324
} from "../../services";
2425
import { SystemUsersService } from "@sims/services/system-users";
26+
import { SFASApplicationService } from "@sims/services/sfas";
2527

2628
@Module({
2729
imports: [ConfigModule],
@@ -37,13 +39,15 @@ import { SystemUsersService } from "@sims/services/system-users";
3739
ECertFullTimeFileHeader,
3840
ECertFullTimeFileFooter,
3941
DisbursementScheduleErrorsService,
40-
RestrictionService,
4142
SystemUsersService,
43+
RestrictionSharedService,
4244
StudentRestrictionSharedService,
4345
ECertGenerationService,
4446
DisbursementOverawardService,
4547
NoteSharedService,
4648
ConfirmationOfEnrollmentService,
49+
SFASApplicationService,
50+
DisbursementScheduleSharedService,
4751
],
4852
exports: [ECertFileHandler],
4953
})

0 commit comments

Comments
 (0)