Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1761 - Handling full time BCSL lifetime and federal maximums #1886

Merged
merged 12 commits into from
Apr 20, 2023
2 changes: 2 additions & 0 deletions sources/packages/backend/apps/api/src/app.aest.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import {
DisbursementOverawardService,
ConfirmationOfEnrollmentService,
NoteSharedService,
RestrictionSharedService,
} from "@sims/services";

@Module({
Expand Down Expand Up @@ -158,6 +159,7 @@ import {
DisbursementOverawardService,
NoteSharedService,
OverawardControllerService,
RestrictionSharedService,
],
})
export class AppAESTModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
StudentRestrictionSharedService,
WorkflowClientService,
NoteSharedService,
RestrictionSharedService,
} from "@sims/services";
import {
SFASIndividualService,
Expand Down Expand Up @@ -121,6 +122,7 @@ import { UserControllerService } from "./route-controllers/user/user.controller.
DisbursementOverawardService,
NoteSharedService,
StudentControllerService,
RestrictionSharedService,
],
})
export class AppInstitutionsModule {}
2 changes: 2 additions & 0 deletions sources/packages/backend/apps/api/src/app.students.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
StudentRestrictionSharedService,
WorkflowClientService,
NoteSharedService,
RestrictionSharedService,
} from "@sims/services";
import {
SFASIndividualService,
Expand Down Expand Up @@ -107,6 +108,7 @@ import { ATBCIntegrationModule } from "@sims/integrations/atbc-integration";
CRAIncomeVerificationService,
SupportingUserService,
StudentRestrictionSharedService,
RestrictionSharedService,
DisbursementOverawardService,
NoteSharedService,
OverawardControllerService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
StudentRestrictionSharedService,
WorkflowClientService,
NoteSharedService,
RestrictionSharedService,
} from "@sims/services";
import {
SFASIndividualService,
Expand Down Expand Up @@ -48,6 +49,7 @@ import { AuthModule } from "./auth/auth.module";
EducationProgramOfferingValidationService,
WorkflowClientService,
StudentRestrictionSharedService,
RestrictionSharedService,
DisbursementOverawardService,
NoteSharedService,
InstitutionLocationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ export class ApplicationService extends RecordDataModelService<Application> {
return !!(await this.repo.findOne({
where: {
applicationNumber: applicationNumber,
student: { id: studentId } as Student,
student: { id: studentId },
},
select: { id: true },
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
RestrictionType,
} from "@sims/sims-db";
import { DataSource } from "typeorm";
import { RestrictionCode } from "./models/restriction.model";

/**
* Service layer for restrictions.
Expand Down Expand Up @@ -74,21 +73,4 @@ export class RestrictionService extends RecordDataModelService<Restriction> {
}
return restrictionQuery.getOne();
}

/**
* Fetch the restriction with requested restriction code.
* @param restrictionCode restriction code.
* @returns restriction.
*/
async getRestrictionByCode(
restrictionCode: RestrictionCode,
): Promise<Restriction> {
return this.repo
.createQueryBuilder("restriction")
.select("restriction.id")
.where("restriction.restrictionCode = :restrictionCode", {
restrictionCode,
})
.getOne();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import {
User,
Restriction,
Student,
Application,
EducationProgramOffering,
RestrictionActionType,
} from "@sims/sims-db";
import { DataSource, EntityManager } from "typeorm";
import { CustomNamedError } from "@sims/utilities";
import { RestrictionService } from "./restriction.service";
import { RestrictionCode } from "./models/restriction.model";
import {
NoteSharedService,
RestrictionCode,
StudentRestrictionSharedService,
} from "@sims/services";
export const RESTRICTION_NOT_ACTIVE = "RESTRICTION_NOT_ACTIVE";
Expand All @@ -29,9 +27,8 @@ export const RESTRICTION_NOT_PROVINCIAL = "RESTRICTION_NOT_PROVINCIAL";
export class StudentRestrictionService extends RecordDataModelService<StudentRestriction> {
constructor(
readonly dataSource: DataSource,
private readonly restrictionService: RestrictionService,
private readonly noteSharedService: NoteSharedService,
private readonly studentRestrictionsService: StudentRestrictionSharedService,
private readonly studentRestrictionSharedService: StudentRestrictionSharedService,
) {
super(dataSource.getRepository(StudentRestriction));
}
Expand Down Expand Up @@ -145,7 +142,7 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
const newRestriction = await transactionalEntityManager
.getRepository(StudentRestriction)
.save(studentRestriction);
await this.studentRestrictionsService.createNotifications(
await this.studentRestrictionSharedService.createNotifications(
[newRestriction.id],
auditUserId,
transactionalEntityManager,
Expand All @@ -171,7 +168,7 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
const studentRestrictionEntity = await this.repo.findOne({
where: {
id: studentRestrictionId,
student: { id: studentId } as Student,
student: { id: studentId },
isActive: true,
},
relations: { restriction: true },
Expand Down Expand Up @@ -228,7 +225,7 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
restrictionActions: RestrictionActionType[],
checkAll = false,
): Promise<boolean> {
const query = this.studentRestrictionsService
const query = this.studentRestrictionSharedService
.getExistsBlockRestrictionQuery(checkAll, true)
.setParameters({
studentId,
Expand Down Expand Up @@ -262,38 +259,6 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
.getOne());
}

/**
* Create a new student restriction object.
* @param studentId student id.
* @param restrictionCode restriction code.
* @param auditUserId audit user id
* @param applicationId application id.
* @returns a new student restriction object.
*/
async createRestrictionToSave(
studentId: number,
restrictionCode: RestrictionCode,
auditUserId: number,
applicationId: number,
): Promise<StudentRestriction> {
const restriction = await this.restrictionService.getRestrictionByCode(
restrictionCode,
);
if (!restriction) {
throw new Error(
`Requested restriction code ${restrictionCode} not found.`,
);
}
const studentRestriction = new StudentRestriction();
studentRestriction.restriction = {
id: restriction.id,
} as Restriction;
studentRestriction.student = { id: studentId } as Student;
studentRestriction.application = { id: applicationId } as Application;
studentRestriction.creator = { id: auditUserId } as User;
return studentRestriction;
}

/**
* Verify if the student has a valid SIN to apply to the particular offering.
* The SIN number must be a permanent one or a temporary with expiry date later
Expand Down Expand Up @@ -358,16 +323,17 @@ export class StudentRestrictionService extends RecordDataModelService<StudentRes
}

if (mustCreateSINException) {
const restriction = await this.createRestrictionToSave(
studentId,
RestrictionCode.SINF,
auditUserId,
applicationId,
);
const restriction =
await this.studentRestrictionSharedService.createRestrictionToSave(
studentId,
RestrictionCode.SINF,
auditUserId,
applicationId,
);
const newRestriction = await entityManager
.getRepository(StudentRestriction)
.save(restriction);
await this.studentRestrictionsService.createNotifications(
await this.studentRestrictionSharedService.createNotifications(
[newRestriction.id],
auditUserId,
entityManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class StudentFileService extends RecordDataModelService<StudentFile> {
.getRepository(StudentFile)
.update(
{
student: { id: studentId } as Student,
student: { id: studentId },
uniqueFileName: In(uniqueFileNames),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import { ScholasticStanding } from "./student-scholastic-standings.model";
import { StudentAssessmentService } from "../student-assessment/student-assessment.service";
import { StudentRestrictionService } from "../restriction/student-restriction.service";
import { APPLICATION_CHANGE_NOT_ELIGIBLE } from "../../constants";
import { RestrictionCode } from "../restriction/models/restriction.model";
import { SCHOLASTIC_STANDING_MINIMUM_UNSUCCESSFUL_WEEKS } from "../../utilities";
import {
NotificationActionsService,
RestrictionCode,
StudentRestrictionSharedService,
} from "@sims/services";

Expand Down Expand Up @@ -363,7 +363,7 @@ export class StudentScholasticStandingsService extends RecordDataModelService<St
scholasticStandingData.numberOfUnsuccessfulWeeks >=
SCHOLASTIC_STANDING_MINIMUM_UNSUCCESSFUL_WEEKS
) {
return this.studentRestrictionService.createRestrictionToSave(
return this.studentRestrictionSharedService.createRestrictionToSave(
studentId,
RestrictionCode.SSR,
auditUserId,
Expand All @@ -387,7 +387,7 @@ export class StudentScholasticStandingsService extends RecordDataModelService<St
? RestrictionCode.SSR
: RestrictionCode.WTHD;

return this.studentRestrictionService.createRestrictionToSave(
return this.studentRestrictionSharedService.createRestrictionToSave(
studentId,
restrictionCode,
auditUserId,
Expand Down Expand Up @@ -423,7 +423,7 @@ export class StudentScholasticStandingsService extends RecordDataModelService<St
StudentScholasticStandingChangeType.StudentWithdrewFromProgram,
].includes(scholasticStandingData.scholasticStandingChangeType)
) {
return this.studentRestrictionService.createRestrictionToSave(
return this.studentRestrictionSharedService.createRestrictionToSave(
studentId,
RestrictionCode.PTSSR,
auditUserId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Process, Processor } from "@nestjs/bull";
import { Job } from "bull";
import { CancelAssessmentQueueInDTO } from "@sims/services/queue";
import {
DisbursementScheduleService,
DisbursementScheduleSharedService,
WorkflowClientService,
} from "@sims/services";
import { QueueNames } from "@sims/utilities";
Expand All @@ -25,7 +25,7 @@ export class CancelApplicationAssessmentProcessor {
private readonly dataSource: DataSource,
private readonly workflowClientService: WorkflowClientService,
private readonly studentAssessmentService: StudentAssessmentService,
private readonly disbursementScheduleService: DisbursementScheduleService,
private readonly disbursementScheduleSharedService: DisbursementScheduleSharedService,
) {}

/**
Expand Down Expand Up @@ -106,7 +106,7 @@ export class CancelApplicationAssessmentProcessor {
// It must be called after the workflow is cancelled to avoiding further updates on the disbursements after
// the rollback is performed.
await summary.info("Rolling back overawards, if any.");
await this.disbursementScheduleService.rollbackOverawards(
await this.disbursementScheduleSharedService.rollbackOverawards(
assessment.id,
transactionEntityManager,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
ProcessArchiveApplicationsScheduler,
} from "./processors";
import {
DisbursementScheduleService,
DisbursementScheduleSharedService,
RestrictionSharedService,
SequenceControlService,
StudentRestrictionSharedService,
WorkflowClientService,
Expand Down Expand Up @@ -93,8 +94,9 @@ import { ECEProcessIntegrationScheduler } from "./processors/schedulers/institut
MSFAANumberService,
PartTimeMSFAAProcessIntegrationScheduler,
PartTimeECertProcessIntegrationScheduler,
DisbursementScheduleService,
DisbursementScheduleSharedService,
StudentRestrictionSharedService,
RestrictionSharedService,
FullTimeECertProcessIntegrationScheduler,
FullTimeECertFeedbackIntegrationScheduler,
PartTimeECertFeedbackIntegrationScheduler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "zeebe-node";
// TODO: In the upcoming tasks, either DisbursementScheduleService will be renamed at shared library
// or MSFAA related methods will move to shared library.
import { DisbursementScheduleService as DisbursementScheduleSharedService } from "@sims/services";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import { DisbursementScheduleSharedService } from "@sims/services";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the refactor 👍

import { DisbursementScheduleService } from "../../services";
import {
SaveDisbursementSchedulesJobInDTO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from "./services";
import { ZeebeTransportStrategy } from "./zeebe";
import {
DisbursementScheduleService as DisbursementScheduleSharedService,
DisbursementScheduleSharedService,
SequenceControlService,
WorkflowClientService,
ZeebeModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Module } from "@nestjs/common";
import {
ReportService,
RestrictionSharedService,
SequenceControlService,
StudentRestrictionSharedService,
} from "@sims/services";
Expand All @@ -27,6 +28,7 @@ import {
SequenceControlService,
ReportService,
StudentRestrictionSharedService,
RestrictionSharedService,
],
exports: [
DisbursementReceiptProcessingService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
StudentRestrictionSharedService,
NoteSharedService,
ConfirmationOfEnrollmentService,
DisbursementScheduleSharedService,
RestrictionSharedService,
} from "@sims/services";
import { ECertFileHandler } from "./e-cert-file-handler";
import { ECertFullTimeFileFooter } from "./e-cert-full-time-integration/e-cert-files/e-cert-file-footer";
Expand All @@ -18,10 +20,10 @@ import {
DisbursementScheduleErrorsService,
DisbursementScheduleService,
ECertGenerationService,
RestrictionService,
SshService,
} from "../../services";
import { SystemUsersService } from "@sims/services/system-users";
import { SFASApplicationService } from "@sims/services/sfas";

@Module({
imports: [ConfigModule],
Expand All @@ -37,13 +39,15 @@ import { SystemUsersService } from "@sims/services/system-users";
ECertFullTimeFileHeader,
ECertFullTimeFileFooter,
DisbursementScheduleErrorsService,
RestrictionService,
SystemUsersService,
RestrictionSharedService,
StudentRestrictionSharedService,
ECertGenerationService,
DisbursementOverawardService,
NoteSharedService,
ConfirmationOfEnrollmentService,
SFASApplicationService,
DisbursementScheduleSharedService,
],
exports: [ECertFileHandler],
})
Expand Down
Loading