Skip to content

Commit

Permalink
fix logic to accomodate new field
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-solo committed Nov 12, 2024
1 parent 95240fd commit 4374084
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions components/StepperPage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ export const keyToStepMap = {
partnerLivingCountry: 4,
partnerLivedOnlyInCanada: 4,
partnerYearsInCanadaSince18: 4,
partnerYearsInCanadaSinceOAS: 4,
}
3 changes: 2 additions & 1 deletion utils/api/benefitHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
5 changes: 0 additions & 5 deletions utils/api/definitions/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand All @@ -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,
})
Expand Down
1 change: 1 addition & 0 deletions utils/api/definitions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface RequestInput {
partnerLegalStatus: LegalStatus
partnerLivedOnlyInCanada: boolean
partnerYearsInCanadaSince18: number
partnerYearsInCanadaSinceOAS?: number
_language?: Language
}

Expand Down
1 change: 1 addition & 0 deletions utils/api/fieldsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion utils/api/futureHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 4374084

Please sign in to comment.