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

#4270 - SFAS Bridge File - Expand Individual and Application data Import #4316

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
100AESTSFAS TO SIMS BRIDGE 20250130092935
2000000094541BENJAMIN FRANKLIN 19491116108796293N N 98765432112024071376543220020000005000000000500000011040000001104000000110400000011040000001104000000110400000000000020000000002123456789020241231A 1511 new street My address line 2 Victoria BC CAN 0000001231231234P4K 1K000000350000000024500
30000000945410000014541202412012025022820242025000025000000002500000000000000000000000000001500000000000000000000000000000000000000000000202501302024123456NMA 20031024YN0007200000AUAARECD421000000000110000000012000000001300000000140000000015000000001600000000170000000018000000001900000000210000000022020240220QUITY
999000048090000009580094900
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const DEPENDANT_AND_DISBURSEMENT_RECORDS_FILENAME =
"SFAS-TO-SIMS-DEPENDANT_AND_DISBURSEMENT_ALL_VALUES-RECORDS.txt";
const INVALID_RECORD_TYPE_FILENAME =
"SFAS-TO-SIMS-INVALID_RECORD_TYPE-RECORD.txt";
const SFAS_INDIVIDUAL_AND_APPLICATION_ALL_VALUES_FILENAME =
"SFAS-TO-SIMS-INDIVIDUAL_AND_APPLICATION_ALL_VALUES-RECORDS.txt";
describe(describeProcessorRootTest(QueueNames.SFASIntegration), () => {
let app: INestApplication;
let processor: SFASIntegrationScheduler;
Expand Down Expand Up @@ -816,6 +818,198 @@ describe(describeProcessorRootTest(QueueNames.SFASIntegration), () => {
},
);

it(
"Should import SFAS individual and application records with all the values " +
"when the SFAS file has values for almost all the fields for individual and application records.",
async () => {
// Arrange
// Queued job.
const mockedJob = mockBullJob<void>();
mockDownloadFiles(sftpClientMock, [
SFAS_INDIVIDUAL_AND_APPLICATION_ALL_VALUES_FILENAME,
]);

// Act
await processor.processQueue(mockedJob.job);

// Assert
// Expect the file was archived on SFTP.
expect(sftpClientMock.rename).toHaveBeenCalled();
// Expect the file contains 4 records.
expect(
mockedJob.containLogMessages([
"File contains 2 records.",
"Updating student ids for SFAS individuals.",
"Student ids updated.",
"Updating and inserting new disbursement overaward balances from sfas to disbursement overawards table.",
"New disbursement overaward balances inserted to disbursement overawards table.",
"Inserting student restrictions from SFAS restrictions data.",
"Inserted student restrictions from SFAS restrictions data.",
]),
).toBe(true);
// Verify the SFAS Individual created.
const expectedSFASIndividual: Partial<SFASIndividual> = {
id: 94541,
firstName: "BENJAMIN",
lastName: "FRANKLIN",
birthDate: "1949-11-16",
sin: "108796293",
pdStatus: false,
msfaaNumber: "9876543211",
msfaaSignedDate: "2024-07-13",
neb: 50,
bcgg: 5000,
lfp: 11040,
pal: 11040,
cslOveraward: 11040,
bcslOveraward: 11040,
cmsOveraward: 11040,
grantOveraward: 11040,
withdrawals: 2,
unsuccessfulCompletion: 2,
partTimeMSFAANumber: "1234567890",
partTimeMSFAAEffectiveDate: "2024-12-31",
initials: "A",
addressLine1: "1511 new street",
addressLine2: "My address line 2",
city: "Victoria",
provinceState: "BC",
country: "CAN",
phoneNumber: 1231231234,
postalZipCode: "P4K 1K0",
lmptAwardAmount: 350,
lmpuAwardAmount: 245,
};
const sfasIndividual = await db.sfasIndividual.findOne({
select: {
id: true,
firstName: true,
lastName: true,
birthDate: true,
sin: true,
pdStatus: true,
msfaaNumber: true,
msfaaSignedDate: true,
neb: true,
bcgg: true,
lfp: true,
pal: true,
cslOveraward: true,
bcslOveraward: true,
cmsOveraward: true,
grantOveraward: true,
withdrawals: true,
unsuccessfulCompletion: true,
partTimeMSFAANumber: true,
partTimeMSFAAEffectiveDate: true,
initials: true,
addressLine1: true,
addressLine2: true,
city: true,
provinceState: true,
country: true,
phoneNumber: true,
postalZipCode: true,
lmptAwardAmount: true,
lmpuAwardAmount: true,
},
where: { id: expectedSFASIndividual.id },
});
expect(sfasIndividual).toEqual(expectedSFASIndividual);

// Verify the SFAS Application created.
const expectedSFASApplication: Partial<SFASApplication> = {
id: 14541,
individual: { id: 94541 } as SFASIndividual,
startDate: "2024-12-01",
endDate: "2025-02-28",
programYearId: 20242025,
bslAward: 2500,
cslAward: 2500,
bcagAward: 0,
bgpdAward: 0,
csfgAward: 1500,
csgtAward: 0,
csgdAward: 0,
csgpAward: 0,
sbsdAward: 0,
applicationCancelDate: "2025-01-30",
applicationNumber: 2024123456,
livingArrangements: "N",
maritalStatus: "MA",
marriageDate: "2003-10-24",
bcResidencyFlag: "Y",
permanentResidencyFlag: "N",
grossIncomePreviousYear: 72000,
institutionCode: "AUAA",
applicationStatusCode: "RECD",
educationPeriodWeeks: 42,
courseLoad: 100,
assessedCostsLivingAllowance: 110,
assessedCostsExtraShelter: 120,
assessedCostsChildCare: 130,
assessedCostsAlimony: 140,
assessedCostsLocalTransport: 150,
assessedCostsReturnTransport: 160,
assessedCostsTuition: 170,
assessedCostsBooksAndSupplies: 180,
assessedCostsExceptionalExpenses: 190,
assessedCostsOther: 210,
assessedCostsDiscretionaryExpenses: 220,
withdrawalDate: "2024-02-20",
withdrawalReason: "QUIT",
withdrawalActiveFlag: "Y",
};
const sfasApplication = await db.sfasApplication.findOne({
select: {
id: true,
individual: { id: true },
startDate: true,
endDate: true,
programYearId: true,
bslAward: true,
cslAward: true,
bcagAward: true,
bgpdAward: true,
csfgAward: true,
csgtAward: true,
csgdAward: true,
csgpAward: true,
sbsdAward: true,
applicationCancelDate: true,
applicationNumber: true,
livingArrangements: true,
maritalStatus: true,
marriageDate: true,
bcResidencyFlag: true,
permanentResidencyFlag: true,
grossIncomePreviousYear: true,
institutionCode: true,
applicationStatusCode: true,
educationPeriodWeeks: true,
courseLoad: true,
assessedCostsLivingAllowance: true,
assessedCostsExtraShelter: true,
assessedCostsChildCare: true,
assessedCostsAlimony: true,
assessedCostsLocalTransport: true,
assessedCostsReturnTransport: true,
assessedCostsTuition: true,
assessedCostsBooksAndSupplies: true,
assessedCostsExceptionalExpenses: true,
assessedCostsOther: true,
assessedCostsDiscretionaryExpenses: true,
withdrawalDate: true,
withdrawalReason: true,
withdrawalActiveFlag: true,
},
relations: { individual: true },
where: { id: expectedSFASApplication.id },
});
expect(sfasApplication).toEqual(expectedSFASApplication);
},
);

/**
* Delete all the legacy data for clean data execution.
* @param db data source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,43 @@ export class SFASApplicationImportService
sfasApplication.applicationCancelDate,
);
application.extractedAt = getUTC(extractedDate);
application.applicationNumber = sfasApplication.applicationNumber;
application.livingArrangements = sfasApplication.livingArrangements;
application.maritalStatus = sfasApplication.maritalStatus;
application.marriageDate = getISODateOnlyString(
sfasApplication.marriageDate,
);
application.bcResidencyFlag = sfasApplication.bcResidencyFlag;
application.permanentResidencyFlag = sfasApplication.permanentResidencyFlag;
application.grossIncomePreviousYear =
sfasApplication.grossIncomePreviousYear;
application.institutionCode = sfasApplication.institutionCode;
application.applicationStatusCode = sfasApplication.applicationStatusCode;
application.educationPeriodWeeks = sfasApplication.educationPeriodWeeks;
application.courseLoad = sfasApplication.courseLoad;
application.assessedCostsLivingAllowance =
sfasApplication.assessedCostsLivingAllowance;
application.assessedCostsExtraShelter =
sfasApplication.assessedCostsExtraShelter;
application.assessedCostsChildCare = sfasApplication.assessedCostsChildCare;
application.assessedCostsAlimony = sfasApplication.assessedCostsAlimony;
application.assessedCostsLocalTransport =
sfasApplication.assessedCostsLocalTransport;
application.assessedCostsReturnTransport =
sfasApplication.assessedCostsReturnTransport;
application.assessedCostsTuition = sfasApplication.assessedCostsTuition;
application.assessedCostsBooksAndSupplies =
sfasApplication.assessedCostsBooksAndSupplies;
application.assessedCostsExceptionalExpenses =
sfasApplication.assessedCostsExceptionalExpenses;
application.assessedCostsOther = sfasApplication.assessedCostsOther;
application.assessedCostsDiscretionaryExpenses =
sfasApplication.assessedCostsDiscretionaryExpenses;
application.withdrawalDate = getISODateOnlyString(
sfasApplication.withdrawalDate,
);
application.withdrawalReason = sfasApplication.withdrawalReason;
application.withdrawalActiveFlag = sfasApplication.withdrawalActiveFlag;
await this.repo.save(application, { reload: false, transaction: false });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ export class SFASIndividualImportService
individual.partTimeMSFAAEffectiveDate = getISODateOnlyString(
sfasIndividual.partTimeMSFAAEffectiveDate,
);
individual.initials = sfasIndividual.initials;
individual.addressLine1 = sfasIndividual.addressLine1;
individual.addressLine2 = sfasIndividual.addressLine2;
individual.city = sfasIndividual.city;
individual.provinceState = sfasIndividual.provinceState;
individual.country = sfasIndividual.country;
individual.phoneNumber = sfasIndividual.phoneNumber;
individual.postalZipCode = sfasIndividual.postalZipCode;
individual.lmptAwardAmount = sfasIndividual.lmptAwardAmount;
individual.lmpuAwardAmount = sfasIndividual.lmpuAwardAmount;
await this.repo.save(individual, { reload: false, transaction: false });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class SFASApplicationDependantRecord extends SFASRecordIdentification {
* First and last name of the child (may include other names as well).
*/
get dependantName(): string {
return this.line.substring(23, 23 + 25)?.trim();
return this.line.substring(23, 23 + 25).trim();
}
/**
* Date of birth of the dependant (applicant_dependent.dep_date_of_birth).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class SFASApplicationDisbursementRecord extends SFASRecordIdentification
* Program code used by SFAS (award_disbursement.program_cde).
*/
get fundingType(): string {
return this.line.substring(23, 23 + 4)?.trim();
return this.line.substring(23, 23 + 4).trim();
}
/**
* Amount of funding for this specific disbursement (award_disbursement.disbursement_amt).
Expand Down
Loading
Loading