Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
guru-aot committed Dec 20, 2024
1 parent 2073729 commit 4d9751b
Showing 1 changed file with 4 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -981,15 +981,15 @@ describe("AssessmentController(e2e)-verifyAssessmentCalculationOrder", () => {
});
});

it("Should sum the grants from past applications with different offering intensities and awards from SFAS and SFAS applications data when the applications are for the same student and program year and the student submits a full-time application.", async () => {
it("Should sum the contributions from past applications with full-time offering intensities when the applications are for the same student and program year and the student submits a full-time application.", async () => {
// Arrange

// Create the student and program year to be shared across the applications.
const student = await saveFakeStudent(db.dataSource);
// Get the program year for the start date.
const programYear = await db.programYear.findOne({ where: { id: 2 } });

// Past part-time application with federal and provincial loans and grants.
// Past full-time application with federal and provincial loans and grants.
// Loans will be ignored.
await saveFakeApplicationDisbursements(
db.dataSource,
Expand All @@ -998,32 +998,13 @@ describe("AssessmentController(e2e)-verifyAssessmentCalculationOrder", () => {
firstDisbursementValues: [
createFakeDisbursementValue(
DisbursementValueType.CanadaLoan,
"CSLP",
"CSLF",
1,
),
createFakeDisbursementValue(
DisbursementValueType.CanadaGrant,
"CSPT",
2,
),
createFakeDisbursementValue(
DisbursementValueType.CanadaGrant,
"CSGD",
3,
),
createFakeDisbursementValue(
DisbursementValueType.CanadaGrant,
"CSGP",
4,
),
// Should not be disbursed due to BCLM restriction.
createFakeDisbursementValue(DisbursementValueType.BCGrant, "SBSD", 6),
// Should not be disbursed due to BCLM restriction.
createFakeDisbursementValue(DisbursementValueType.BCGrant, "BCAG", 7),
],
},
{
offeringIntensity: OfferingIntensity.partTime,
offeringIntensity: OfferingIntensity.fullTime,
applicationStatus: ApplicationStatus.Completed,
currentAssessmentInitialValues: {
assessmentWorkflowId: "some fake id",
Expand Down Expand Up @@ -1052,27 +1033,6 @@ describe("AssessmentController(e2e)-verifyAssessmentCalculationOrder", () => {
"CSLF",
8,
),
createFakeDisbursementValue(
DisbursementValueType.CanadaGrant,
"CSGD",
9,
),
createFakeDisbursementValue(
DisbursementValueType.CanadaGrant,
"CSGP",
10,
),
createFakeDisbursementValue(DisbursementValueType.BCLoan, "BCSL", 11),
createFakeDisbursementValue(
DisbursementValueType.BCGrant,
"SBSD",
12,
),
createFakeDisbursementValue(
DisbursementValueType.BCGrant,
"BCAG",
13,
),
],
},
{
Expand Down Expand Up @@ -1107,23 +1067,6 @@ describe("AssessmentController(e2e)-verifyAssessmentCalculationOrder", () => {
},
},
);
const firstAssessmentDate =
currentApplication.currentAssessment.assessmentDate;
// The start date for the first SFAS and SFAS part time application record is set to the date before the first assessment date of the current application.
const firstLegacyApplicationStartDate = faker.date.between(
programYear.startDate,
addDays(-1, firstAssessmentDate),
);
const firstLegacyApplicationEndDate = addDays(30, firstAssessmentDate);
// The start date for the second SFAS and SFAS part time application record is set to the date after the end date of the first SFAS application.
const secondLegacyApplicationStartDate = faker.date.between(
firstLegacyApplicationEndDate,
addDays(10, firstLegacyApplicationEndDate),
);
const secondLegacyApplicationEndDate = addDays(
40,
firstLegacyApplicationEndDate,
);
const secondAssessment = createFakeStudentAssessment(
{
auditUser: currentApplication.student.user,
Expand All @@ -1140,80 +1083,6 @@ describe("AssessmentController(e2e)-verifyAssessmentCalculationOrder", () => {
currentApplication.currentAssessment = secondAssessment;
await db.application.save(currentApplication);

// SFAS Individual.
const sfasIndividual = await saveFakeSFASIndividual(db.dataSource, {
initialValues: {
lastName: student.user.lastName,
birthDate: student.birthDate,
sin: student.sinValidation.sin,
},
});
// First SFAS application with the start date before the first assessment date of the current application.
const firstFakeSFASApplication = createFakeSFASApplication(
{ individual: sfasIndividual },
{
initialValues: {
startDate: getISODateOnlyString(firstLegacyApplicationStartDate),
endDate: getISODateOnlyString(firstLegacyApplicationEndDate),
csgdAward: 9,
csgpAward: 10,
sbsdAward: 12,
bcagAward: 13,
},
},
);
// Second SFAS application with the start date after the end date of the first SFAS application.
const secondFakeSFASApplication = createFakeSFASApplication(
{ individual: sfasIndividual },
{
initialValues: {
startDate: getISODateOnlyString(secondLegacyApplicationStartDate),
endDate: getISODateOnlyString(secondLegacyApplicationEndDate),
csgdAward: 9,
csgpAward: 10,
sbsdAward: 12,
bcagAward: 13,
},
},
);
await db.sfasApplication.save([
firstFakeSFASApplication,
secondFakeSFASApplication,
]);
// First SFAS part time application with the start date before the first assessment date of the current application.
const firstFakeSFASPartTimeApplication = createFakeSFASPartTimeApplication(
{ individual: sfasIndividual },
{
initialValues: {
startDate: getISODateOnlyString(firstLegacyApplicationStartDate),
endDate: getISODateOnlyString(firstLegacyApplicationEndDate),
csptAward: 2,
csgdAward: 3,
csgpAward: 4,
sbsdAward: 6,
bcagAward: 7,
},
},
);
// Second SFAS part time application with the start date after the end date of the first SFAS part time application.
const secondFakeSFASPartTimeApplication = createFakeSFASPartTimeApplication(
{ individual: sfasIndividual },
{
initialValues: {
startDate: getISODateOnlyString(secondLegacyApplicationStartDate),
endDate: getISODateOnlyString(secondLegacyApplicationEndDate),
csptAward: 2,
csgdAward: 3,
csgpAward: 4,
sbsdAward: 6,
bcagAward: 7,
},
},
);
await db.sfasPartTimeApplications.save([
firstFakeSFASPartTimeApplication,
secondFakeSFASPartTimeApplication,
]);
// Act
const result = await assessmentController.verifyAssessmentCalculationOrder(
createFakeVerifyAssessmentCalculationOrderPayload(
Expand All @@ -1227,22 +1096,11 @@ describe("AssessmentController(e2e)-verifyAssessmentCalculationOrder", () => {
// The calculation will only take SFAS and SFAS part time application data where the start date is the date before the first assessment date of the current application.
expect(FakeWorkerJobResult.getOutputVariables(result)).toStrictEqual({
isReadyForCalculation: true,
// Full-time.
programYearTotalFullTimeCSGD: 18,
programYearTotalFullTimeCSGP: 20,
programYearTotalFullTimeSBSD: 24,
programYearTotalFullTimeBCAG: 26,
// Student contribution total.
programYearTotalFederalFSC: 6000,
programYearTotalProvincialFSC: 8000,
programYearTotalScholarshipBursaries: 4000,
programYearTotalSpouseContributionWeeks: 2000,
// Part-time.
programYearTotalPartTimeCSPT: 4,
programYearTotalPartTimeCSGD: 6,
programYearTotalPartTimeCSGP: 8,
programYearTotalPartTimeSBSD: 12,
programYearTotalPartTimeBCAG: 14,
});
});
});

0 comments on commit 4d9751b

Please sign in to comment.