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

#3965 - Separate Sequencing for FT and PT eCert Numbers #4207

Merged
merged 11 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
EducationProgramOffering,
Institution,
InstitutionLocation,
OfferingIntensity,
} from "@sims/sims-db";
import { MONEY_VALUE_FOR_UNKNOWN_MAX_VALUE } from "../../../../utilities";
import { COE_WINDOW, addDays, getISODateOnlyString } from "@sims/utilities";
Expand Down Expand Up @@ -89,6 +90,41 @@ describe("ConfirmationOfEnrollmentInstitutionsController(e2e)-confirmEnrollment"
);
});

it("Should allow the COE confirmation when the application is on Enrolment status and all the conditions are fulfilled for Part Time offering.", async () => {
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
// Arrange
Copy link
Collaborator

@lewischen-aot lewischen-aot Jan 6, 2025

Choose a reason for hiding this comment

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

Not a blocker. As a recommendation, since the PR is to separate FT and PT sequence names, it would be nice to include a test case for FT application to verify the sequence name as "Full Time_DISBURSEMENT_DOCUMENT_NUMBER".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the sequence Control Assert test for Full Time.

const application = await saveFakeApplicationDisbursements(
appDataSource,
{
institution: collegeC,
institutionLocation: collegeCLocation,
},
{
applicationStatus: ApplicationStatus.Enrolment,
offeringIntensity: OfferingIntensity.partTime,
},
);
const [firstDisbursementSchedule] =
application.currentAssessment.disbursementSchedules;
const endpoint = `/institutions/location/${collegeCLocation.id}/confirmation-of-enrollment/disbursement-schedule/${firstDisbursementSchedule.id}/confirm`;
// Act/Assert
await request(app.getHttpServer())
.patch(endpoint)
.send({ tuitionRemittanceAmount: 1 })
.auth(
await getInstitutionToken(InstitutionTokenTypes.CollegeCUser),
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
BEARER_AUTH_TYPE,
)
.expect(HttpStatus.OK);
// Check if the application was updated as expected.
const updatedApplication = await applicationRepo.findOne({
select: { applicationStatus: true },
where: { id: application.id },
});
expect(updatedApplication.applicationStatus).toBe(
ApplicationStatus.Completed,
);
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can also assert that the sequence control record created by the COE operation has the correct sequence name, which is "Part Time_DISBURSEMENT_DOCUMENT_NUMBER", and the sequence number is the document number for the disbursement schedule record of the application.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the sequence Control Assert test.


it("Should allow the second COE confirmation when the application is on Completed status and all the conditions are fulfilled.", async () => {
// Arrange
const application = await saveFakeApplicationDisbursements(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { getSQLFileData } from "../utilities/sqlLoader";

export class RenameSequenceNameDocumentNumber1736193026064
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData("Rename-sequence-name.sql", "SequenceControl"),
lewischen-aot marked this conversation as resolved.
Show resolved Hide resolved
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
getSQLFileData("Rollback-rename-sequence-name.sql", "SequenceControl"),
);
}
}
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE sims.sequence_controls
SET sequence_name = 'Part Time_DISBURSEMENT_DOCUMENT_NUMBER'::varchar(100)
lewischen-aot marked this conversation as resolved.
Show resolved Hide resolved
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
WHERE sequence_name = 'DISBURSEMENT_DOCUMENT_NUMBER'::varchar(100);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE sims.sequence_controls
SET sequence_name = 'DISBURSEMENT_DOCUMENT_NUMBER'::varchar(100)
WHERE sequence_name = 'Part Time_DISBURSEMENT_DOCUMENT_NUMBER'::varchar(100);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DisbursementSchedule,
DisbursementScheduleStatus,
DisbursementValueType,
OfferingIntensity,
User,
} from "@sims/sims-db";
import {
Expand Down Expand Up @@ -34,7 +35,6 @@ import { LoggerService, InjectLogger } from "@sims/utilities/logger";
import { SequenceControlService } from "../sequence-control/sequence-control.service";
import { NotificationActionsService } from "../notifications";
import {
DISBURSEMENT_DOCUMENT_NUMBER_SEQUENCE_GROUP,
ENROLMENT_ALREADY_COMPLETED,
ENROLMENT_CONFIRMATION_DATE_NOT_WITHIN_APPROVAL_PERIOD,
ENROLMENT_INVALID_OPERATION_IN_THE_CURRENT_STATE,
Expand Down Expand Up @@ -229,6 +229,7 @@ export class ConfirmationOfEnrollmentService {
"offering.actualTuitionCosts",
"offering.programRelatedCosts",
"offering.studyEndDate",
"offering.offeringIntensity",
"disbursementValues.valueType",
"disbursementValues.valueCode",
"disbursementValues.valueAmount",
Expand Down Expand Up @@ -352,16 +353,18 @@ export class ConfirmationOfEnrollmentService {
* @param applicationStatus application status of the disbursed application.
* @param tuitionRemittanceRequestedAmount tuition remittance amount requested by the institution.
* @param enrolmentConfirmationDate enrolment confirmation date.
* @param offeringIntensity offering intensity.
*/
private async updateDisbursementAndApplicationCOEApproval(
disbursementScheduleId: number,
userId: number,
applicationId: number,
applicationStatus: ApplicationStatus,
tuitionRemittanceRequestedAmount: number,
offeringIntensity: OfferingIntensity,
enrolmentConfirmationDate?: Date,
): Promise<void> {
const documentNumber = await this.getNextDocumentNumber();
const documentNumber = await this.getNextDocumentNumber(offeringIntensity);
const auditUser = { id: userId } as User;
const coeConfirmationDate = enrolmentConfirmationDate ?? new Date();

Expand Down Expand Up @@ -649,6 +652,8 @@ export class ConfirmationOfEnrollmentService {
disbursementSchedule.studentAssessment.application.id,
disbursementSchedule.studentAssessment.application.applicationStatus,
tuitionRemittanceAmount,
disbursementSchedule.studentAssessment.application.currentAssessment
.offering.offeringIntensity,
options?.enrolmentConfirmationDate,
);
}
Expand Down Expand Up @@ -757,12 +762,16 @@ export class ConfirmationOfEnrollmentService {
/**
* Generates the next document number to be associated
* with a disbursement.
* @param offeringIntensity offering intensity.
* @returns sequence number for disbursement document number.
*/
private async getNextDocumentNumber(): Promise<number> {
private async getNextDocumentNumber(
offeringIntensity: OfferingIntensity,
): Promise<number> {
const sequenceGroupName = `${offeringIntensity}_DISBURSEMENT_DOCUMENT_NUMBER`;
lewischen-aot marked this conversation as resolved.
Show resolved Hide resolved
andrewsignori-aot marked this conversation as resolved.
Show resolved Hide resolved
let nextDocumentNumber: number;
await this.sequenceService.consumeNextSequence(
DISBURSEMENT_DOCUMENT_NUMBER_SEQUENCE_GROUP,
sequenceGroupName,
async (nextSequenceNumber) => {
nextDocumentNumber = nextSequenceNumber;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ export const BC_TOTAL_GRANT_AWARD_CODE = "BCSG";
export const BC_STUDENT_LOAN_AWARD_CODE = "BCSL";
export const CANADA_STUDENT_LOAN_FULL_TIME_AWARD_CODE = "CSLF";
export const CANADA_STUDENT_LOAN_PART_TIME_AWARD_CODE = "CSLP";
export const DISBURSEMENT_DOCUMENT_NUMBER_SEQUENCE_GROUP =
"DISBURSEMENT_DOCUMENT_NUMBER";
Loading