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

#3924 - Ecert Creation - "Prefer not to answer" Gender #3927

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -183,6 +183,7 @@ describe(
formatDate(coeUpdatedAtDate, "YYYYMMDD"),
);
expect(record1Parsed.postalCode).toBe("V1V 1V1");
expect(record1Parsed.gender).toBe("X");
// TODO Add other fields as needed.
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ describe(
const recordParsed = new PartTimeCertRecordParser(record);
expect(recordParsed.recordType).toBe("02");
expect(recordParsed.hasUser(student.user)).toBe(true);
expect(recordParsed.gender).toBe("X");
expect(recordParsed.disbursementAmount).toBe("000123500");
// TODO include other fields as needed.

Expand All @@ -410,6 +411,70 @@ describe(
expect(scheduleIsSent).toBe(true);
});

it("Should create an e-Cert with valid student profile data when the student has necessary profile data and gender defined as 'Prefer not to answer'.", async () => {
// Arrange
// Student with valid SIN.
const student = await saveFakeStudent(db.dataSource, null, {
initialValue: {
gender: "preferNotToAnswer",
},
});
// Valid MSFAA Number.
const msfaaNumber = await db.msfaaNumber.save(
createFakeMSFAANumber(
{ student },
{
msfaaState: MSFAAStates.Signed,
msfaaInitialValues: {
offeringIntensity: OfferingIntensity.partTime,
},
},
),
);
// Student application eligible for e-Cert.
await saveFakeApplicationDisbursements(
db.dataSource,
{
student,
msfaaNumber,
firstDisbursementValues: [
createFakeDisbursementValue(
DisbursementValueType.CanadaLoan,
"CSLP",
1234.57,
),
],
},
{
offeringIntensity: OfferingIntensity.partTime,
applicationStatus: ApplicationStatus.Completed,
currentAssessmentInitialValues: {
assessmentData: { weeks: 5 } as Assessment,
assessmentDate: new Date(),
},
firstDisbursementInitialValues: {
coeStatus: COEStatus.completed,
},
},
);
// Queued job.
const { job } = mockBullJob<void>();

// Act
await processor.processECert(job);

// Assert
// Assert student profile data.
const uploadedFile = getUploadedFile(sftpClientMock);
expect(uploadedFile.fileLines).toHaveLength(3);
const [, record] = uploadedFile.fileLines;
// TODO: include other student profile fields as needed.
const recordParsed = new PartTimeCertRecordParser(record);
expect(recordParsed.recordType).toBe("02");
expect(recordParsed.hasUser(student.user)).toBe(true);
expect(recordParsed.gender).toBe(" ");
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

});

it("Should adjust tuition remittance when requested tuition remittance is greater than the max tuition remittance.", async () => {
// Arrange

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export abstract class ECertRecordParser {
*/
abstract get lastName(): string;

/**
* Student's gender.
*/
abstract get gender(): string;

/**
* Validate if the first name and last names belongs to the
* provided student user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export class FullTimeCertRecordParser extends ECertRecordParser {
return this.record.substring(151, 176).trim();
}

/**
* Student's gender.
*/
get gender(): string {
return this.record.substring(594, 595);
}

/**
* Federal CSLF amount (loan).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export class PartTimeCertRecordParser extends ECertRecordParser {
return this.record.substring(2, 27).trim();
}

/**
* Student's gender.
*/
get gender(): string {
return this.record.substring(54, 55);
}

/**
* Disbursement amount.
* This field includes 2 decimals in the file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe(
`2000000001000900000000PABCD19950630${processDateFormatted}Doe AAAAAAC John EEEEIIII MMNOOOOO Address Line 1 UUUU Address Line 2 Calgary AB H1H 1H1 Canada [email protected] PT `,
);
expect(msfaaPartTimeOtherCountry).toBe(
`2000000001001900000001PEFDG20000101${processDateFormatted}Other Doe aaaaaac Jane eeeeiiii Snooooo Address Line 1 Some city in the United S United States [email protected] PT `,
`2000000001001900000001PEFDG20000101${processDateFormatted}Other Doe aaaaaac Jane eeeeiiii Snooooo Address Line 1 Some city in the United S United States [email protected] PT `,
);
expect(msfaaPartTimeRelationshipOther).toBe(
`2000000001002900000002PIHKL20011231${processDateFormatted}Other Doe uuuuyy Other John ???? FOAddress Line 1 Address Line 2 Victoria BC H1H 1H1 Canada [email protected] PT `,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class ECertFullTimeFileRecord extends ECertFileRecord {
*/
postalCode?: string;
/**
* Gender (M=man, F=woman, X=nonBinary empty=preferNotToAnswer).
* Gender (M=man, F=woman, X=nonBinary, white space=preferNotToAnswer).
*/
gender: string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class ECertPartTimeFileRecord extends ECertFileRecord {
*/
postalCode?: string;
/**
* Gender (M=man, F=woman, X=nonBinary empty=preferNotToAnswer).
* Gender (M=man, F=woman, X=nonBinary, white space=preferNotToAnswer).
*/
gender: string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SINValidationFileRequest implements FixedFormatFileLine {
*/
lastName: string;
/**
* Gender (M=man, F=woman, X=nonBinary empty=preferNotToAnswer).
* Gender (M=man, F=woman, X=nonBinary, white space=preferNotToAnswer).
*/
gender: string;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function createFakeStudent(
student.birthDate =
options?.initialValue?.birthDate ??
getISODateOnlyString(faker.date.past(18));
student.gender = "nonBinary";
student.gender = options?.initialValue?.gender ?? "nonBinary";
student.contactInfo = options?.initialValue?.contactInfo ?? {
address: {
addressLine1: faker.address.streetAddress(),
Expand Down
5 changes: 4 additions & 1 deletion sources/packages/backend/libs/utilities/src/esdc-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export function getGenderCode(gender: string): string {
case "nonBinary":
return "X";
default:
return "";
// Gender should have at least one character code.
// The default option as an empty space would represent
// the "Prefer not to answer"(preferNotToAnswer) option.
return " ";
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

}
}

Expand Down