diff --git a/__tests__/pages/api/benefits.test.ts b/__tests__/pages/api/benefits.test.ts index 9f4e898bd..7a320684c 100644 --- a/__tests__/pages/api/benefits.test.ts +++ b/__tests__/pages/api/benefits.test.ts @@ -433,6 +433,28 @@ describe('consolidated benefit tests: eligible: 65+', () => { expectAlwAfsTooOld(res) }) + it('returns "eligible" - single, 20 years in Canada, high income (partial gis edge case)', async () => { + const res = await mockGetRequest({ + incomeAvailable: true, + income: 100000, + ...age65NoDefer, + maritalStatus: MaritalStatus.SINGLE, + livingCountry: LivingCountry.CANADA, + legalStatus: LegalStatus.CANADIAN_CITIZEN, + livedOutsideCanada: true, + yearsInCanadaSince18: 20, + everLivedSocialCountry: undefined, + ...partnerUndefined, + }) + expectOasGisEligible( + res, + EntitlementResultType.PARTIAL, + roundToTwo(legalValues.oas.amount / 2), + 324.34 + ) + expectAlwAfsTooOld(res) + }) + it('returns "eligible" - single, living in Agreement, 20 years in Canada', async () => { const res = await mockGetRequest({ ...income10k, diff --git a/i18n/api/en.ts b/i18n/api/en.ts index 16691819e..59c2da1bd 100644 --- a/i18n/api/en.ts +++ b/i18n/api/en.ts @@ -310,6 +310,6 @@ const en: Translations = { }, yes: 'Yes', no: 'No', - years: 'years', + year: 'year', } export default en diff --git a/i18n/api/fr.ts b/i18n/api/fr.ts index 2cc85c039..49b7a6686 100644 --- a/i18n/api/fr.ts +++ b/i18n/api/fr.ts @@ -327,6 +327,6 @@ const fr: Translations = { }, yes: 'Oui', no: 'Non', - years: 'ans', + year: 'an', } export default fr diff --git a/i18n/api/index.ts b/i18n/api/index.ts index 02037f5e3..144e6c71d 100644 --- a/i18n/api/index.ts +++ b/i18n/api/index.ts @@ -117,7 +117,7 @@ export interface Translations { } yes: string no: string - years: string + year: string } export function getTranslations(language: Language): Translations { diff --git a/utils/api/benefits/entitlementFormula.ts b/utils/api/benefits/entitlementFormula.ts index 95c3f764d..53bc63e40 100644 --- a/utils/api/benefits/entitlementFormula.ts +++ b/utils/api/benefits/entitlementFormula.ts @@ -182,9 +182,10 @@ export class EntitlementFormula { this.calculationMethod === 'LOW' ? 3 : 1 - return roundToTwo( + const calculated = roundToTwo( this.actualMaxAmount - this.incomeDifferential * differentialMultiplier ) + return Math.max(0, calculated) } /** diff --git a/utils/api/definitions/textReplacementRules.ts b/utils/api/definitions/textReplacementRules.ts index 5fca3a317..3528299d2 100644 --- a/utils/api/definitions/textReplacementRules.ts +++ b/utils/api/definitions/textReplacementRules.ts @@ -26,10 +26,12 @@ export const textReplacementRules: TextReplacementRules = { handler.benefitResults.oas?.entitlement.deferral.increase ?? 0, handler.translations._locale )}`, - OAS_DEFERRAL_YEARS: (handler) => - `${String( - handler.benefitResults.oas?.entitlement.deferral.years ?? 0 - )} ${handler.translations.years}`, + OAS_DEFERRAL_YEARS: (handler) => { + const years = handler.benefitResults.oas?.entitlement.deferral.years + return `${years ?? 0} ${handler.translations.year}${ + years !== 1 ? 's' : '' + }` + }, OAS_DEFERRAL_AGE: (handler) => String(handler.benefitResults.oas.entitlement.deferral.age), OAS_CLAWBACK: (handler) =>