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

#3620 - Change Request - Partner Current Year Income (financial information) option #3799

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe("StudentAppealStudentsController(e2e)-submitStudentAppeal", () => {
let studentFileRepo: Repository<StudentFile>;
const FINANCIAL_INFORMATION_FORM_NAME = "studentfinancialinformationappeal";
const DEPENDANT_INFORMATION_FORM_NAME = "studentDependantsAppeal";
const PARTNER_INFORMATION_FORM_NAME = "partnerinformationandincomeappeal";

beforeAll(async () => {
const { nestApplication, module, dataSource } =
Expand Down Expand Up @@ -501,6 +502,107 @@ describe("StudentAppealStudentsController(e2e)-submitStudentAppeal", () => {
);
});

it("Should save the current year partner income when the student submits an appeal for the current year partner income.", async () => {
// Arrange
const application = await saveFakeApplication(appDataSource, undefined, {
applicationStatus: ApplicationStatus.Completed,
});
// Create a current year partner income file.
const partnerIncomeFile = await saveFakeStudentFileUpload(
appDataSource,
{
student: application.student,
creator: application.student.user,
},
{ fileOrigin: FileOriginType.Temporary },
);
// Prepare the data to request a change of current year partner income.
const partnerIncomeInformationData = {
programYear: application.programYear.programYear,
relationshipStatus: "married",
partnerEstimatedIncome: 1000,
currentYearPartnerIncome: 2000,
reasonsignificantdecreaseInPartnerIncome: "other",
decreaseInPartnerIncomeSupportingDocuments: [
{
storage: "url",
originalName: partnerIncomeFile.fileName,
name: partnerIncomeFile.uniqueFileName,
url: "student/files/" + partnerIncomeFile.uniqueFileName,
size: 0,
type: "text/plain",
hash: "1cb251ec0d568de6a929b520c4aed8d1",
},
],
otherExceptionalPartnerCircumstance: "any",
};

const payload: StudentAppealAPIInDTO = {
studentAppealRequests: [
{
formName: PARTNER_INFORMATION_FORM_NAME,
formData: partnerIncomeInformationData,
files: [partnerIncomeFile.uniqueFileName],
},
],
};
// Mock user service to return the saved student.
await mockUserLoginInfo(appModule, application.student);
// Get any student user token.
const studentToken = await getStudentToken(
FakeStudentUsersTypes.FakeStudentUserType1,
);
// Mock the form service to validate the dry-run submission result.
const formService = await getProviderInstanceForModule(
appModule,
AppStudentsModule,
FormService,
);
const dryRunSubmissionMock = jest.fn().mockResolvedValue({
valid: true,
formName: PARTNER_INFORMATION_FORM_NAME,
data: { data: partnerIncomeInformationData },
});

formService.dryRunSubmission = dryRunSubmissionMock;

const endpoint = `/students/appeal/application/${application.id}`;

// Act/Assert
let createdAppealId: number;
await request(app.getHttpServer())
.post(endpoint)
.auth(studentToken, BEARER_AUTH_TYPE)
.send(payload)
.expect(HttpStatus.CREATED)
.expect((response) => {
expect(response.body.id).toBeGreaterThan(0);
createdAppealId = +response.body.id;
});

// Expect created student appeal request data to be the same in the payload.
const newStudentAppealRequest = await studentAppealRequestRepo.findOne({
where: { studentAppeal: { id: createdAppealId } },
});
expect(newStudentAppealRequest.submittedData).toStrictEqual(
payload.studentAppealRequests[0].formData,
);
// Expect the file origin type to be Appeal for the updated current year partner income file.
const updatedPartnerIncomeFile = await studentFileRepo.findOne({
where: { id: partnerIncomeFile.id },
});
expect(updatedPartnerIncomeFile.fileOrigin).toBe(FileOriginType.Appeal);

// Expect to call the dry run submission.
expect(dryRunSubmissionMock).toHaveBeenCalledWith(
PARTNER_INFORMATION_FORM_NAME,
{
...partnerIncomeInformationData,
programYear: application.programYear.programYear,
},
);
});

afterAll(async () => {
await app?.close();
});
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,56 @@ describe(`E2E Test Workflow parttime-assessment-${PROGRAM_YEAR}-partner-informat
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBeNull();
});

it("Should calculate partner income as current year partner income value when there is a request a change for current year partner income.", async () => {
// Arrange
const assessmentConsolidatedData =
createFakeConsolidatedPartTimeData(PROGRAM_YEAR);
assessmentConsolidatedData.partner1CRAReportedIncome = 3000;
dheepak-aot marked this conversation as resolved.
Show resolved Hide resolved
assessmentConsolidatedData.appealsPartnerInformationAndIncomeAppealData = {
relationshipStatus: "married",
partnerEstimatedIncome: 1000,
currentYearPartnerIncome: 2000,
};

// Act
const calculatedAssessment = await executePartTimeAssessmentForProgramYear(
PROGRAM_YEAR,
assessmentConsolidatedData,
);

// Assert
expect(
calculatedAssessment.variables.calculatedDataCurrentYearPartnerIncome,
).toBe(2000);
expect(
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBe(2000);
});

it("Should calculate partner income as current year partner income value when there is a request a change for current year partner income and the partner's total income is provided.", async () => {
// Arrange
const assessmentConsolidatedData =
createFakeConsolidatedPartTimeData(PROGRAM_YEAR);
assessmentConsolidatedData.partner1TotalIncome = 4000;
assessmentConsolidatedData.appealsPartnerInformationAndIncomeAppealData = {
relationshipStatus: "married",
partnerEstimatedIncome: 1000,
currentYearPartnerIncome: 2000,
};

// Act
const calculatedAssessment = await executePartTimeAssessmentForProgramYear(
PROGRAM_YEAR,
assessmentConsolidatedData,
);

// Assert
expect(
calculatedAssessment.variables.calculatedDataCurrentYearPartnerIncome,
).toBe(2000);
expect(
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBe(2000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,56 @@ describe(`E2E Test Workflow parttime-assessment-${PROGRAM_YEAR}-partner-informat
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBeNull();
});

it("Should calculate partner income as current year partner income value when there is a request a change for current year partner income.", async () => {
// Arrange
const assessmentConsolidatedData =
createFakeConsolidatedPartTimeData(PROGRAM_YEAR);
assessmentConsolidatedData.partner1CRAReportedIncome = 3000;
assessmentConsolidatedData.appealsPartnerInformationAndIncomeAppealData = {
relationshipStatus: "married",
partnerEstimatedIncome: 1000,
currentYearPartnerIncome: 2000,
};

// Act
const calculatedAssessment = await executePartTimeAssessmentForProgramYear(
PROGRAM_YEAR,
assessmentConsolidatedData,
);

// Assert
expect(
calculatedAssessment.variables.calculatedDataCurrentYearPartnerIncome,
).toBe(2000);
expect(
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBe(2000);
});

it("Should calculate partner income as current year partner income value when there is a request a change for current year partner income and the partner's total income is provided.", async () => {
// Arrange
const assessmentConsolidatedData =
createFakeConsolidatedPartTimeData(PROGRAM_YEAR);
assessmentConsolidatedData.partner1TotalIncome = 4000;
assessmentConsolidatedData.appealsPartnerInformationAndIncomeAppealData = {
relationshipStatus: "married",
partnerEstimatedIncome: 1000,
currentYearPartnerIncome: 2000,
};

// Act
const calculatedAssessment = await executePartTimeAssessmentForProgramYear(
PROGRAM_YEAR,
assessmentConsolidatedData,
);

// Assert
expect(
calculatedAssessment.variables.calculatedDataCurrentYearPartnerIncome,
).toBe(2000);
expect(
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBe(2000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,56 @@ describe(`E2E Test Workflow parttime-assessment-${PROGRAM_YEAR}-partner-informat
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBeNull();
});

it("Should calculate partner income as current year partner income value when there is a request a change for current year partner income.", async () => {
// Arrange
const assessmentConsolidatedData =
createFakeConsolidatedPartTimeData(PROGRAM_YEAR);
assessmentConsolidatedData.partner1CRAReportedIncome = 3000;
assessmentConsolidatedData.appealsPartnerInformationAndIncomeAppealData = {
relationshipStatus: "married",
partnerEstimatedIncome: 1000,
currentYearPartnerIncome: 2000,
};

// Act
const calculatedAssessment = await executePartTimeAssessmentForProgramYear(
PROGRAM_YEAR,
assessmentConsolidatedData,
);

// Assert
expect(
calculatedAssessment.variables.calculatedDataCurrentYearPartnerIncome,
).toBe(2000);
expect(
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBe(2000);
});

it("Should calculate partner income as current year partner income value when there is a request a change for current year partner income and the partner's total income is provided.", async () => {
// Arrange
const assessmentConsolidatedData =
createFakeConsolidatedPartTimeData(PROGRAM_YEAR);
assessmentConsolidatedData.partner1TotalIncome = 4000;
assessmentConsolidatedData.appealsPartnerInformationAndIncomeAppealData = {
relationshipStatus: "married",
partnerEstimatedIncome: 1000,
currentYearPartnerIncome: 2000,
};

// Act
const calculatedAssessment = await executePartTimeAssessmentForProgramYear(
PROGRAM_YEAR,
assessmentConsolidatedData,
);

// Assert
expect(
calculatedAssessment.variables.calculatedDataCurrentYearPartnerIncome,
).toBe(2000);
expect(
calculatedAssessment.variables.calculatedDataPartner1TotalIncome,
).toBe(2000);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface StudentFinancialInformationAppealData extends JSONDoc {
currentYearIncome?: number;
daycareCosts12YearsOrOver?: number;
daycareCosts11YearsOrUnder?: number;
currentYearPartnerIncome?: number;
}

export enum TransportationCostSituation {
Expand All @@ -44,6 +45,7 @@ export type RelationshipStatusType = "single" | "other" | "married";
export interface PartnerInformationAndIncomeAppealData extends JSONDoc {
relationshipStatus: RelationshipStatusType;
partnerEstimatedIncome?: number;
currentYearPartnerIncome?: number;
}

export enum CredentialType {
Expand Down Expand Up @@ -273,6 +275,8 @@ export interface CalculatedAssessmentModel {
calculatedDataTaxReturnIncome: number;
calculatedDataCurrentYearIncome: number;
calculatedDataStudentTotalIncome: number;
calculatedDataCurrentYearPartnerIncome: number;
partner1CRAReportedIncome?: number;

// Common variables used in both full-time and part-time.
// CSGP
Expand Down
Loading