Skip to content

Commit

Permalink
Merge pull request #888 from DTS-STN/ado-141134
Browse files Browse the repository at this point in the history
ADO-141134: Floor years in canada value & ADO-141547: Set limit to 20 when partner not living in Canada
  • Loading branch information
MarcoGoC authored Sep 15, 2023
2 parents 5b0c458 + 36ef97f commit 066cc07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion utils/api/benefitHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,10 @@ export class BenefitHandler {
const partnerEliObj = OasEligibility(
this.input.partner.age,
this.input.partner.yearsInCanadaSince18,
this.input.partner.livedOnlyInCanada
this.input.partner.livedOnlyInCanada,
this.rawInput.partnerLivingCountry
)

if (this.input.partner.age > partnerEliObj.ageOfEligibility) {
if (this.input.partner.age < 75) {
this.input.partner.age = partnerEliObj.ageOfEligibility
Expand Down
8 changes: 5 additions & 3 deletions utils/api/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@ export function calculateAge(birthMonth: number, birthYear: number): number {
export function OasEligibility(
ageAtStart,
yearsInCanadaAtStart,
livedOnlyInCanada = false
livedOnlyInCanada = false,
livingCountry = 'CAN'
) {
let age = ageAtStart
let yearsInCanada = yearsInCanadaAtStart
const minAgeEligibility = 65
const minYearsOfResEligibility = 10
const minYearsOfResEligibility = livingCountry === 'CAN' ? 10 : 20

let ageOfEligibility
let yearsOfResAtEligibility
Expand Down Expand Up @@ -297,14 +298,15 @@ export function evaluateOASInput(input) {
age > eliObj.ageOfEligibility
? input.yearsInCanadaSince18 - ageDiff
: input.yearsInCanada + ageDiff

if (deferralMonths !== 0 && !input.receiveOAS) {
canDefer = true
newInput['inputAge'] = input.age
newInput['age'] = eliObj.ageOfEligibility
newInput['receiveOAS'] = true
newInput['yearsInCanadaSince18'] = input.livedOnlyInCanada
? 40
: Math.min(40, Math.round(newYearsInCan))
: Math.min(40, Math.floor(newYearsInCan))
newInput['oasDeferDuration'] = JSON.stringify({
months: Math.round(deferralMonths),
years: 0,
Expand Down

0 comments on commit 066cc07

Please sign in to comment.