diff --git a/__tests__/pages/api/index.test.ts b/__tests__/pages/api/index.test.ts index f8e784368..7ac764b14 100644 --- a/__tests__/pages/api/index.test.ts +++ b/__tests__/pages/api/index.test.ts @@ -3041,11 +3041,11 @@ describe('Help Me Find Out scenarios', () => { expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.NONE) expect(res.body.results.gis.eligibility.result).toEqual(ResultKey.ELIGIBLE) expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.NONE) - expect(res.body.results.gis.entitlement.result).toEqual(0.68) + expect(res.body.results.gis.entitlement.result).toEqual(0.68) // table 3 }) - it('works when client old, partner old (partner=partialOas, therefore gis income limit 46656, gis table unavailable)', async () => { + it(`works when client old, partner old (partner=partialOas, therefore gis income limit ${MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW}, gis table unavailable)`, async () => { const input = { - income: 46656, + income: MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW, age: 65, maritalStatus: MaritalStatus.MARRIED, livingCountry: LivingCountry.CANADA, @@ -3075,7 +3075,7 @@ describe('Help Me Find Out scenarios', () => { expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.INCOME) res = await mockGetRequest({ ...input, - income: 46655, + income: MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW - 1, }) expect(res.body.results.oas.eligibility.result).toEqual(ResultKey.ELIGIBLE) expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.NONE) @@ -3121,7 +3121,7 @@ describe('Help Me Find Out scenarios', () => { expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.NONE) expect(res.body.results.gis.eligibility.result).toEqual(ResultKey.ELIGIBLE) expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.NONE) - expect(res.body.results.gis.entitlement.result).toEqual(0.33) + expect(res.body.results.gis.entitlement.result).toEqual(0.33) // table 2 }) it(`works when client old, partner young (partner=noAllowance, therefore gis table 3)`, async () => { const input = { @@ -3228,4 +3228,91 @@ describe('Help Me Find Out scenarios', () => { ResultReason.MARITAL ) }) + it('works when client young, partner old (partner=gis, therefore client alw eligible)', async () => { + const input = { + income: 0, + age: 60, + maritalStatus: MaritalStatus.MARRIED, + livingCountry: LivingCountry.CANADA, + legalStatus: LegalStatus.CANADIAN_CITIZEN, + legalStatusOther: undefined, + canadaWholeLife: true, + yearsInCanadaSince18: undefined, + everLivedSocialCountry: undefined, + partnerBenefitStatus: PartnerBenefitStatus.HELP_ME, + partnerIncome: 0, + partnerAge: 65, + partnerLivingCountry: LivingCountry.CANADA, + partnerLegalStatus: LegalStatus.CANADIAN_CITIZEN, + partnerCanadaWholeLife: false, + partnerYearsInCanadaSince18: 40, + partnerEverLivedSocialCountry: undefined, + } + let res = await mockGetRequest(input) + expect(res.body.summary.state).toEqual( + EstimationSummaryState.AVAILABLE_ELIGIBLE + ) + expect(res.body.results.oas.eligibility.result).toEqual( + ResultKey.INELIGIBLE + ) + expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.AGE) + expect(res.body.results.gis.eligibility.result).toEqual( + ResultKey.INELIGIBLE + ) + expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.OAS) + expect(res.body.results.alw.eligibility.result).toEqual(ResultKey.ELIGIBLE) + expect(res.body.results.alw.eligibility.reason).toEqual(ResultReason.NONE) + expect(res.body.results.alw.entitlement.result).toEqual(1219.68) // table 4 + expect(res.body.results.afs.eligibility.result).toEqual( + ResultKey.INELIGIBLE + ) + expect(res.body.results.afs.eligibility.reason).toEqual( + ResultReason.MARITAL + ) + }) + it('works when client young, partner old (partner=noGis, therefore client alw ineligible)', async () => { + const input = { + income: 0, + age: 60, + maritalStatus: MaritalStatus.MARRIED, + livingCountry: LivingCountry.CANADA, + legalStatus: LegalStatus.CANADIAN_CITIZEN, + legalStatusOther: undefined, + canadaWholeLife: true, + yearsInCanadaSince18: undefined, + everLivedSocialCountry: undefined, + partnerBenefitStatus: PartnerBenefitStatus.HELP_ME, + partnerIncome: 0, + partnerAge: 65, + partnerLivingCountry: LivingCountry.NO_AGREEMENT, // gis ineligible + partnerLegalStatus: LegalStatus.CANADIAN_CITIZEN, + partnerCanadaWholeLife: false, + partnerYearsInCanadaSince18: 40, + partnerEverLivedSocialCountry: undefined, + } + let res = await mockGetRequest(input) + expect(res.body.summary.state).toEqual( + EstimationSummaryState.AVAILABLE_INELIGIBLE + ) + expect(res.body.results.oas.eligibility.result).toEqual( + ResultKey.INELIGIBLE + ) + expect(res.body.results.oas.eligibility.reason).toEqual(ResultReason.AGE) + expect(res.body.results.gis.eligibility.result).toEqual( + ResultKey.INELIGIBLE + ) + expect(res.body.results.gis.eligibility.reason).toEqual(ResultReason.OAS) + expect(res.body.results.alw.eligibility.result).toEqual( + ResultKey.INELIGIBLE + ) + expect(res.body.results.alw.eligibility.reason).toEqual( + ResultReason.PARTNER + ) + expect(res.body.results.afs.eligibility.result).toEqual( + ResultKey.INELIGIBLE + ) + expect(res.body.results.afs.eligibility.reason).toEqual( + ResultReason.MARITAL + ) + }) }) diff --git a/utils/api/benefits/gisBenefit.ts b/utils/api/benefits/gisBenefit.ts index 868e4038c..d0f7e2d95 100644 --- a/utils/api/benefits/gisBenefit.ts +++ b/utils/api/benefits/gisBenefit.ts @@ -46,7 +46,6 @@ export class GisBenefit extends BaseBenefit { ? MAX_GIS_INCOME_PARTNER_OAS : MAX_GIS_INCOME_PARTNER_NO_OAS_NO_ALW : MAX_GIS_INCOME_SINGLE - console.log('using max income ', maxIncome) const meetsReqIncome = this.income < maxIncome // main checks diff --git a/utils/api/helpers/requestHandler.ts b/utils/api/helpers/requestHandler.ts index 1d2efc4e2..b9fc49acc 100644 --- a/utils/api/helpers/requestHandler.ts +++ b/utils/api/helpers/requestHandler.ts @@ -246,9 +246,12 @@ export class RequestHandler { allResults.partner.oas.eligibility = partnerOas.eligibility allResults.partner.oas.entitlement = partnerOas.entitlement - // Save the result to the client's partnerBenefitStatus field, which is used TBD + // Save the partner result to the client's partnerBenefitStatus field, which is used for client's GIS input.client.partnerBenefitStatus.oasResultEntitlement = partnerOas.entitlement + // Save the client result to the partner's partnerBenefitStatus field, which is not yet used for anything + input.partner.partnerBenefitStatus.oasResultEntitlement = + clientOas.entitlement } // All done with OAS, move onto GIS, but only do GIS eligibility for now. @@ -268,10 +271,10 @@ export class RequestHandler { ) allResults.partner.gis.eligibility = partnerGis.eligibility - // Save the result to the client's partnerBenefitStatus field, which is used TBD + // Save the partner result to the client's partnerBenefitStatus field, which is used for client's ALW input.client.partnerBenefitStatus.gisResultEligibility = partnerGis.eligibility - // Save the result to the partner's partnerBenefitStatus field, which is used for partner's alw eligibility + // Save the client result to the partner's partnerBenefitStatus field, which is used for partner's ALW, and therefore client's GIS input.partner.partnerBenefitStatus.gisResultEligibility = clientGis.eligibility } @@ -283,12 +286,14 @@ export class RequestHandler { // If the client needs help, check their partner's ALW eligibility. if (input.client.partnerBenefitStatus.helpMe) { const partnerAlw = new AlwBenefit(input.partner, translations) - allResults.partner.alw.eligibility = partnerAlw.eligibility - // Save the result to the client's partnerBenefitStatus field, which is used TBD + // Save the partner result to the client's partnerBenefitStatus field, which is used for client's GIS input.client.partnerBenefitStatus.alwResultEligibility = partnerAlw.eligibility + // Save the client result to the partner's partnerBenefitStatus field, which is not yet used for anything + input.partner.partnerBenefitStatus.alwResultEligibility = + clientAlw.eligibility } // Moving onto AFS, again only doing eligibility.