Skip to content

Commit

Permalink
New partner questions, along with major refactor to support (#111)
Browse files Browse the repository at this point in the history
* add additional partner questions when partnerBenefitStatus is helpMeFindOut

* major refactoring to support the above

* simplify allowance partner benefit status check, now just requires GIS

* summary text now explains when reason is income

* add more relevant reason when alw ineligible because partner not receiving gis
  • Loading branch information
JeremyKennedy authored Jan 26, 2022
1 parent 255d194 commit dde5fe7
Show file tree
Hide file tree
Showing 37 changed files with 3,549 additions and 1,884 deletions.
1,511 changes: 1,280 additions & 231 deletions __tests__/pages/api/index.test.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client-state/models/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const Form = types
parent.setOAS(data.results.oas)
parent.setGIS(data.results.gis)
parent.setAFS(data.results.afs)
parent.setAllowance(data.results.allowance)
parent.setAllowance(data.results.alw)

parent.setSummary(data.summary)

Expand Down
69 changes: 21 additions & 48 deletions client-state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ import {
} from '../utils/api/definitions/enums'
import { Form } from './models/Form'

export const Eligibility = types.model({
eligibilityResult: types.maybe(types.enumeration(Object.values(ResultKey))),
entitlementResult: types.maybe(types.number),
reason: types.maybe(types.string),
export const EligibilityResult = types.model({
detail: types.maybe(types.string),
reason: types.maybe(types.string),
result: types.maybe(types.enumeration(Object.values(ResultKey))),
})

export const EntitlementResult = types.model({
type: types.maybe(types.string),
result: types.maybe(types.number),
})

export const Eligibility = types.model({
eligibility: types.maybe(EligibilityResult),
entitlement: types.maybe(EntitlementResult),
})

export const OAS = Eligibility.named('OAS')
Expand Down Expand Up @@ -49,63 +58,27 @@ export const RootStore = types
.views((self) => ({
get totalEntitlementInDollars() {
return (
self.oas.entitlementResult +
(self.gis.entitlementResult !== -1 ? self.gis.entitlementResult : 0) + // gis can return a -1 for an unavailable calculation, correct for this
self.allowance?.entitlementResult +
self.afs?.entitlementResult
self.oas.entitlement.result +
(self.gis.entitlement.result !== -1 ? self.gis.entitlement.result : 0) + // gis can return a -1 for an unavailable calculation, correct for this
self.allowance?.entitlement.result +
self.afs?.entitlement.result
).toFixed(2)
},
}))
.actions((self) => ({
setActiveTab(num: number) {
self.activeTab = num
},
setOAS(
input: ModelCreationType<
ExtractCFromProps<{
eligibilityResult: IMaybe<ISimpleType<ResultKey>>
entitlementResult: IMaybe<ISimpleType<number>>
reason: IMaybe<ISimpleType<string>>
detail: IMaybe<ISimpleType<string>>
}>
>
) {
setOAS(input) {
self.oas = OAS.create(input)
},
setGIS(
input: ModelCreationType<
ExtractCFromProps<{
eligibilityResult: IMaybe<ISimpleType<ResultKey>>
entitlementResult: IMaybe<ISimpleType<number>>
reason: IMaybe<ISimpleType<string>>
detail: IMaybe<ISimpleType<string>>
}>
>
) {
setGIS(input) {
self.gis = GIS.create(input)
},
setAFS(
input: ModelCreationType<
ExtractCFromProps<{
eligibilityResult: IMaybe<ISimpleType<ResultKey>>
entitlementResult: IMaybe<ISimpleType<number>>
reason: IMaybe<ISimpleType<string>>
detail: IMaybe<ISimpleType<string>>
}>
>
) {
setAFS(input) {
self.afs = AFS.create(input)
},
setAllowance(
input: ModelCreationType<
ExtractCFromProps<{
eligibilityResult: IMaybe<ISimpleType<ResultKey>>
entitlementResult: IMaybe<ISimpleType<number>>
reason: IMaybe<ISimpleType<string>>
detail: IMaybe<ISimpleType<string>>
}>
>
) {
setAllowance(input) {
self.allowance = Allowance.create(input)
},
setSummary(
Expand Down
2 changes: 1 addition & 1 deletion components/ResultsTable/EligibilityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const EligibilityDetails: React.VFC<{
eligibilityType: EligibilityType
}> = ({ eligibilityType }) => (
<>
{eligibilityType.detail.split('\n').map((str, i) => (
{eligibilityType.eligibility.detail.split('\n').map((str, i) => (
<p key={i} className={i == 0 ? `inline` : ''}>
{str}
</p>
Expand Down
18 changes: 9 additions & 9 deletions components/ResultsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ export const ResultsTable = observer(() => {
<td>
<EligibilityDetails eligibilityType={root.oas} />
</td>
<td>${root.oas.entitlementResult}</td>
<td>${root.oas.entitlement.result}</td>
</tr>
<tr className="bg-[#E8F2F4]">
<td>Guaranteed Income Supplement (GIS)</td>
<td>
<EligibilityDetails eligibilityType={root.gis} />
</td>
<td>
{root.gis.entitlementResult !== -1
? `$${root.gis.entitlementResult}`
{root.gis.entitlement.result !== -1
? `$${root.gis.entitlement.result}`
: 'Unavailable'}
</td>
</tr>
Expand All @@ -39,14 +39,14 @@ export const ResultsTable = observer(() => {
<td>
<EligibilityDetails eligibilityType={root.allowance} />
</td>
<td>${root.allowance && root.allowance.entitlementResult}</td>
<td>${root.allowance && root.allowance.entitlement.result}</td>
</tr>
<tr className="bg-[#E8F2F4]">
<td>Allowance for Survivor</td>
<td>
<EligibilityDetails eligibilityType={root.afs} />
</td>
<td>${root.afs && root.afs.entitlementResult}</td>
<td>${root.afs && root.afs.entitlement.result}</td>
</tr>
<tr className="border-t border-content font-semibold ">
<td colSpan={2}>Estimated Total Monthly Benefit Amount</td>
Expand All @@ -65,7 +65,7 @@ export const ResultsTable = observer(() => {
</p>
<p className="px-1.5 py-1.5">
<span className="font-bold">Estimated Monthly Amount (CAD): </span>$
{root.oas.entitlementResult}
{root.oas.entitlement.result}
</p>
</div>
<div className="mb-4">
Expand All @@ -78,7 +78,7 @@ export const ResultsTable = observer(() => {
</p>
<p className="px-1.5 py-1.5">
<span className="font-bold">Estimated Monthly Amount (CAD): </span>$
{root.gis.entitlementResult}
{root.gis.entitlement.result}
</p>
</div>
<div className="mb-4">
Expand All @@ -91,7 +91,7 @@ export const ResultsTable = observer(() => {
</p>
<p className="px-1.5 py-1.5">
<span className="font-bold">Estimated Monthly Amount (CAD): </span>$
{root.allowance.entitlementResult}
{root.allowance.entitlement.result}
</p>
</div>
<div className="mb-4">
Expand All @@ -104,7 +104,7 @@ export const ResultsTable = observer(() => {
</p>
<p className="px-1.5 py-1.5">
<span className="font-bold">Estimated Monthly Amount (CAD): </span>$
{root.afs.entitlementResult}
{root.afs.entitlement.result}
</p>
</div>
<div className="mb-4">
Expand Down
21 changes: 15 additions & 6 deletions i18n/api/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ const en: Translations = {
partnerBenefitStatus: 'Which of the following applies to you?',
partnerIncome:
"What is your partner's annual net income in Canadian dollars?",
partnerAge: "What is your partner's current age?",
partnerLivingCountry: 'What country is your partner currently living in?',
partnerLegalStatus: "What is your partner's current legal status?",
partnerCanadaWholeLife:
'Has your partner only lived in Canada since the age of 18?',
partnerYearsInCanadaSince18:
'How many years has your partner lived in Canada since the age of 18?',
partnerEverLivedSocialCountry:
'Has your partner ever lived in a country with an established <a href="https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/payroll-deductions-contributions/canada-pension-plan-cpp/foreign-employees-employers/canada-s-social-agreements-other-countries.html" target="_blank">social security agreement</a>?',
},
questionOptions: {
legalStatus: [
Expand Down Expand Up @@ -68,7 +77,7 @@ const en: Translations = {
{ key: 'fullOasGis', text: 'My partner receives full OAS and GIS' },
{ key: 'partialOas', text: 'My partner receives partial OAS' },
{ key: 'partialOasGis', text: 'My partner receives partial OAS and GIS' },
{ key: 'allowance', text: 'My partner receives the Allowance' },
{ key: 'alw', text: 'My partner receives the Allowance' },
{ key: 'none', text: 'None of the above' },
{ key: 'helpMe', text: 'Help me find out' },
],
Expand Down Expand Up @@ -295,8 +304,8 @@ const en: Translations = {
'You must be a surviving partner or widowed to be eligible for this benefit.',
mustBePartnered:
'You must be common-law or married to be eligible for this benefit.',
mustHavePartnerWithOas:
'Your partner must be receiving Old Age Security to be eligible for this benefit.',
mustHavePartnerWithGis:
'Your partner must be receiving the Guaranteed Income Supplement to be eligible for this benefit.',
mustMeetIncomeReq:
'Your income is too high to be eligible for this benefit.',
mustMeetYearReq:
Expand Down Expand Up @@ -378,7 +387,7 @@ const en: Translations = {
url: 'https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/guaranteed-income-supplement/eligibility.htm',
order: 8,
},
allowanceQualify: {
alwQualify: {
text: 'You may qualify for the Allowance program',
url: 'https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/guaranteed-income-supplement/allowance.htm',
order: 9,
Expand All @@ -403,12 +412,12 @@ const en: Translations = {
url: 'https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/payments.htm',
order: 13,
},
allowanceGisEntitlement: {
alwGisEntitlement: {
text: 'Guaranteed Income Supplement (GIS) and Allowance amounts ',
url: 'https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/payments/tab4-1.htm',
order: 14,
},
allowanceInfo: {
alwInfo: {
text: 'Guaranteed Income Supplement (GIS) - Allowance',
url: 'https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/guaranteed-income-supplement/allowance/benefit-amount.htm',
order: 15,
Expand Down
22 changes: 16 additions & 6 deletions i18n/api/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ const fr: Translations = {
partnerBenefitStatus: "Laquelle des options suivantes s'applique à vous?",
partnerIncome:
'Quel est le revenu net annuel de votre partenaire en dollars canadiens?',
partnerAge: "Quel est l'âge actuel de votre partenaire?",
partnerLivingCountry:
'Dans quel pays habite actuellement votre partenaire?',
partnerLegalStatus: 'Quel est le statut légal actuel de votre partenaire?',
partnerCanadaWholeLife:
"Est-ce que votre partenaire a seulement habité au Canada depuis l'âge de 18 ans?",
partnerYearsInCanadaSince18:
"Combien d'années votre partenaire a-t-il(elle) habité au Canada depuis l'âge de 18 ans?",
partnerEverLivedSocialCountry:
'FRENCH: Has your partner ever lived in a country with an established <a href="https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/payroll-deductions-contributions/canada-pension-plan-cpp/foreign-employees-employers/canada-s-social-agreements-other-countries.html" target="_blank">social security agreement</a>?',
},
questionOptions: {
legalStatus: [
Expand Down Expand Up @@ -83,7 +93,7 @@ const fr: Translations = {
key: 'partialOasGis',
text: 'Mon partenaire reçoit une pension partielle de la SV et le SRG',
},
{ key: 'allowance', text: "Mon partenaire reçoit l'Allocation" },
{ key: 'alw', text: "Mon partenaire reçoit l'Allocation" },
{ key: 'none', text: 'Aucune de ces réponses' },
{ key: 'helpMe', text: 'Aidez-moi à savoir' },
],
Expand Down Expand Up @@ -312,8 +322,8 @@ const fr: Translations = {
'Vous devez être un partenaire survivant ou un veuf pour être admissible à cette prestation.',
mustBePartnered:
'Vous devez être conjoint de fait ou marié pour être admissible à cette prestation.',
mustHavePartnerWithOas:
'Votre partenaire doit recevoir la prestation de sécurité de la vieillesse pour être admissible à cette prestation.',
mustHavePartnerWithGis:
'Votre partenaire doit recevoir le supplément de revenu garanti pour être admissible à cette prestation.',
mustMeetIncomeReq:
'Votre revenu est trop élevé pour que vous soyez admissible à cette prestation.',
mustMeetYearReq:
Expand Down Expand Up @@ -395,7 +405,7 @@ const fr: Translations = {
url: 'https://www.canada.ca/fr/services/prestations/pensionspubliques/rpc/securite-vieillesse/supplement-revenu-garanti/admissibilite.html',
order: 8,
},
allowanceQualify: {
alwQualify: {
text: "Vous pourriez être admissible à l'Allocation",
url: 'https://www.canada.ca/fr/services/prestations/pensionspubliques/rpc/securite-vieillesse/supplement-revenu-garanti/allocation.html',
order: 9,
Expand All @@ -420,12 +430,12 @@ const fr: Translations = {
url: 'https://www.canada.ca/fr/services/prestations/pensionspubliques/rpc/securite-vieillesse/paiements.html',
order: 13,
},
allowanceGisEntitlement: {
alwGisEntitlement: {
text: "Montants du Supplément de revenu garanti (SRG) et de l'allocation ",
url: 'https://www.canada.ca/fr/services/prestations/pensionspubliques/rpc/securite-vieillesse/paiements/tab4-1.html',
order: 14,
},
allowanceInfo: {
alwInfo: {
text: 'Supplément de revenu garanti : Allocation',
url: 'https://www.canada.ca/fr/services/prestations/pensionspubliques/rpc/securite-vieillesse/supplement-revenu-garanti/allocation/montant-prestation.html',
order: 15,
Expand Down
20 changes: 13 additions & 7 deletions i18n/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ export interface Translations {
question: {
income: string
age: string
maritalStatus: string
livingCountry: string
legalStatus: string
legalStatusOther: string
canadaWholeLife: string
yearsInCanadaSince18: string
maritalStatus: string
partnerIncome: string
partnerBenefitStatus: string
everLivedSocialCountry: string
partnerBenefitStatus: string
partnerIncome: string
partnerAge: string
partnerLivingCountry: string
partnerLegalStatus: string
partnerCanadaWholeLife: string
partnerYearsInCanadaSince18: string
partnerEverLivedSocialCountry: string
}
questionOptions: {
legalStatus: KeyAndText[]
Expand All @@ -63,7 +69,7 @@ export interface Translations {
mustCompleteOasCheck: string
mustBeWidowed: string
mustBePartnered: string
mustHavePartnerWithOas: string
mustHavePartnerWithGis: string
mustMeetIncomeReq: string
mustMeetYearReq: string
ineligibleYearsOrCountry: string
Expand Down Expand Up @@ -98,13 +104,13 @@ export interface Translations {
oasQualify: Link
oasPartial: Link
gisQualify: Link
allowanceQualify: Link
alwQualify: Link
afsQualify: Link
workingOutsideCanada: Link
gisEntitlement: Link
oasEntitlement2: Link
allowanceGisEntitlement: Link
allowanceInfo: Link
alwGisEntitlement: Link
alwInfo: Link
afsEntitlement: Link
oasRecoveryTax: Link
oasDefer: Link
Expand Down
18 changes: 18 additions & 0 deletions i18n/tooltips/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ const en: TooltipTranslations = {
heading: 'Social Agreement Countries',
text: 'You may still qualify if you have you lived in one of the countries Canada has established a social security agreement.',
},
partnerAge: {
useDataFromKey: 'age',
},
partnerLivingCountry: {
useDataFromKey: 'livingCountry',
},
partnerLegalStatus: {
useDataFromKey: 'legalStatus',
},
partnerCanadaWholeLife: {
useDataFromKey: 'canadaWholeLife',
},
partnerYearsInCanadaSince18: {
useDataFromKey: 'yearsInCanadaSince18',
},
partnerEverLivedSocialCountry: {
useDataFromKey: 'everLivedSocialCountry',
},
}

export default en
Loading

0 comments on commit dde5fe7

Please sign in to comment.