From 4374084cff603c9c3249a2f2e2dff1542b2c7897 Mon Sep 17 00:00:00 2001 From: Alex Soloviev Date: Tue, 12 Nov 2024 05:14:57 -0700 Subject: [PATCH] fix logic to accomodate new field --- components/StepperPage/utils.ts | 1 + utils/api/benefitHandler.ts | 3 ++- utils/api/definitions/schemas.ts | 5 ----- utils/api/definitions/types.ts | 1 + utils/api/fieldsHandler.ts | 1 + utils/api/futureHandler.ts | 4 +++- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/StepperPage/utils.ts b/components/StepperPage/utils.ts index 9b2666da2..ebdc9684a 100644 --- a/components/StepperPage/utils.ts +++ b/components/StepperPage/utils.ts @@ -258,4 +258,5 @@ export const keyToStepMap = { partnerLivingCountry: 4, partnerLivedOnlyInCanada: 4, partnerYearsInCanadaSince18: 4, + partnerYearsInCanadaSinceOAS: 4, } diff --git a/utils/api/benefitHandler.ts b/utils/api/benefitHandler.ts index 96af218ee..38796939c 100644 --- a/utils/api/benefitHandler.ts +++ b/utils/api/benefitHandler.ts @@ -121,7 +121,8 @@ export class BenefitHandler { if (!this.future) { const partnerEliObj = OasEligibility( this.input.partner.age, - this.input.partner.yearsInCanadaSince18, + this.input.partner.yearsInCanadaSince18 || + this.input.partner.yearsInCanadaSinceOAS, this.input.partner.livedOnlyInCanada, this.rawInput.partnerLivingCountry ) diff --git a/utils/api/definitions/schemas.ts b/utils/api/definitions/schemas.ts index 66430a082..6f295b3a6 100644 --- a/utils/api/definitions/schemas.ts +++ b/utils/api/definitions/schemas.ts @@ -324,12 +324,9 @@ export const RequestSchema = Joi.object({ }) } - //TODO FROM HERE if (partnerLivingCountry === LivingCountry.CANADA) { - // if < 10 if (partnerYearsInCanadaSinceOAS !== undefined) { if (partnerYearsInCanadaSinceOAS < 10) { - // under 10 message return helpers.message({ custom: ValidationErrors.partnerResCanadaNotEnough10, }) @@ -344,10 +341,8 @@ export const RequestSchema = Joi.object({ } } } else { - // if < 20 if (partnerYearsInCanadaSinceOAS !== undefined) { if (partnerYearsInCanadaSinceOAS < 20) { - // under 20 message return helpers.message({ custom: ValidationErrors.partnerResCanadaNotEnough20, }) diff --git a/utils/api/definitions/types.ts b/utils/api/definitions/types.ts index 6bdd93c5a..0e454b1d3 100644 --- a/utils/api/definitions/types.ts +++ b/utils/api/definitions/types.ts @@ -52,6 +52,7 @@ export interface RequestInput { partnerLegalStatus: LegalStatus partnerLivedOnlyInCanada: boolean partnerYearsInCanadaSince18: number + partnerYearsInCanadaSinceOAS?: number _language?: Language } diff --git a/utils/api/fieldsHandler.ts b/utils/api/fieldsHandler.ts index 622047140..dc09d7ced 100644 --- a/utils/api/fieldsHandler.ts +++ b/utils/api/fieldsHandler.ts @@ -145,6 +145,7 @@ export class FieldsHandler { yearsInCanadaSince18: this.rawInput.partnerLivedOnlyInCanada //assume 40 when live only in Canada ? 40 : this.rawInput.partnerYearsInCanadaSince18, + yearsInCanadaSinceOAS: this.rawInput.partnerYearsInCanadaSinceOAS, everLivedSocialCountry: false, // required by ProcessedInput partnerBenefitStatus: new PartnerBenefitStatusHelper( PartnerBenefitStatus.HELP_ME diff --git a/utils/api/futureHandler.ts b/utils/api/futureHandler.ts index 884462b67..48f3c9ab4 100644 --- a/utils/api/futureHandler.ts +++ b/utils/api/futureHandler.ts @@ -161,7 +161,9 @@ export class FutureHandler { const clientRes = Number(this.query.yearsInCanadaSince18) || Number(this.query.yearsInCanadaSinceOAS) - const partnerRes = Number(this.query.partnerYearsInCanadaSince18) + const partnerRes = + Number(this.query.partnerYearsInCanadaSince18) || + Number(this.query.partnerYearsInCanadaSinceOAS) const partnerOnlyCanada = this.query.partnerLivedOnlyInCanada const clientDeferralMeta =