diff --git a/openfisca_canada/tests/benefitfinder/cerb/cerb.yaml b/openfisca_canada/tests/benefitfinder/cerb/cerb.yaml index dbbe4286..7ad531a9 100644 --- a/openfisca_canada/tests/benefitfinder/cerb/cerb.yaml +++ b/openfisca_canada/tests/benefitfinder/cerb/cerb.yaml @@ -11,9 +11,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 1 - + cerb__is_eligible_lost_all_income_lost_job_or_employer_closed: + - true - name: "individual employer closed - Scenario 1" period: 2020-08 @@ -26,8 +25,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 1 + cerb__is_eligible_lost_all_income_lost_job_or_employer_closed: + - true - name: "individual self eployed no income test" @@ -41,8 +40,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 4 + cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim: + - true - name: "individual unpaid leave care of child or sick" @@ -56,8 +55,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 4 + cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim: + - true - name: "individual recent parental leave cant return to work" period: 2020-08 @@ -70,8 +69,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 4 + cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim: + - true - name: "individual has recent ei claim" @@ -85,8 +84,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 4 + cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim: + - true - name: "individual is sick or quarantined or unpaid leave" period: 2020-08 @@ -99,8 +98,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 4 + cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim: + - true #has lost some income Tests @@ -118,8 +117,7 @@ output: cerb__is_eligible: - false - cerb__eligible_scenario: - - 0 + - name: "Lost Some Income - is quarantined" @@ -136,8 +134,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 3 + cerb__is_eligible_lost_some_income_quarantine: + - true - name: "Lost Some Income - has hours reduced or lost a job" period: 2018-08 @@ -153,8 +151,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 2 + cerb__is_eligible_lost_some_income_reduced_hours_1000_or_less: + - true - name: "Lost Some Income - is self employed some income" period: 2018-08 @@ -170,8 +168,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 5 + cerb__is_eligible_lost_some_income_self_employed_1000_hours_or_less: + - true # Person has gross income of greater than 5K - name: "Person Gross income over 5k" period: 2018-08 @@ -183,8 +181,8 @@ output: cerb__is_eligible: - true - cerb__eligible_scenario: - - 6 + cerb__is_eligible_gross_income_over_5k: + - true - name: "Some Income tests" period: 2018-08 diff --git a/openfisca_canada/variables/benefitfinder/cerb/cerb__is_eligible.py b/openfisca_canada/variables/benefitfinder/cerb/cerb__is_eligible.py index 9df38084..7a235964 100644 --- a/openfisca_canada/variables/benefitfinder/cerb/cerb__is_eligible.py +++ b/openfisca_canada/variables/benefitfinder/cerb/cerb__is_eligible.py @@ -2,8 +2,6 @@ from openfisca_core.model_api import * from openfisca_canada.entities import Person, Family -import numpy as np - class cerb__is_eligible(Variable): value_type = bool @@ -14,38 +12,83 @@ class cerb__is_eligible(Variable): reference = "tbd" def formula(persons, period, parameters): - return (persons('income_status__has_lost_all_income', period) * (persons('income_status_reason__has_lost_job', period) + persons('income_status_reason__has_employer_closed', period) + \ - persons('income_status_reason__is_self_employed', period) + persons('income_status_reason__has_unpaid_leave_to_care_for_child_or_sick', period) + \ - persons('income_status_reason__has_parental_recently_cant_return_to_work', period) + persons('income_status_reason__has_ei_recent_claim_ended', period))) + \ - (persons('income_status__has_lost_some_income', period) * ((persons("income_status_reason__has_hours_reduced",period) + persons("income_status_reason__employed_lost_a_job",period)) * persons("income_status_reason__has_1000_or_less",period))) + \ - (persons('income_status__has_lost_some_income', period) * persons("income_status_reason__is_quarantined",period)) + \ - (persons('income_status__has_lost_some_income', period) * persons("income_status_reason__is_self_employed",period) * persons("income_status_reason__has_1000_or_less",period)) + \ - persons('income_status_reason__is_gross_income_over_5k', period) - -class cerb__eligible_scenario(Variable): - value_type = float + return persons('cerb__is_eligible_lost_all_income_lost_job_or_employer_closed', period) +\ + persons('cerb__is_eligible_lost_some_income_reduced_hours_1000_or_less', period) +\ + persons('cerb__is_eligible_lost_some_income_quarantine', period) +\ + persons('cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim', period) +\ + persons('cerb__is_eligible_lost_some_income_self_employed_1000_hours_or_less', period) +\ + persons('cerb__is_eligible_gross_income_over_5k', period) + + +class cerb__is_eligible_lost_all_income_lost_job_or_employer_closed(Variable): + value_type = bool + entity = Person + definition_period = MONTH + label = u"which scenario of cerb is person eligible?" + reference = "tbd" + + def formula(persons, period, parameters): + return persons('income_status__has_lost_all_income', period) * (persons('income_status_reason__has_lost_job', period) +\ + persons('income_status_reason__has_employer_closed', period)) + +class cerb__is_eligible_lost_some_income_reduced_hours_1000_or_less(Variable): + value_type = bool + entity = Person + definition_period = MONTH + default_value = False + label = u"which scenario of cerb is person eligible?" + reference = "tbd" + + def formula(persons, period, parameters): + return persons('income_status__has_lost_some_income', period) * ((persons('income_status_reason__has_hours_reduced', period) + \ + persons('income_status_reason__employed_lost_a_job', period)) * persons('income_status_reason__has_1000_or_less', period)) + +class cerb__is_eligible_lost_some_income_quarantine(Variable): + value_type = bool entity = Person definition_period = MONTH default_value = False label = u"which scenario of cerb is person eligible?" reference = "tbd" + + def formula(persons, period, parameters): + return persons('income_status__has_lost_some_income', period) * persons('income_status_reason__is_quarantined', period) + + +class cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim(Variable): + value_type = bool + entity = Person + definition_period = MONTH + default_value = False + label = u"is person eligible for cerb__is_eligible_lost_all_income_self_employed_closed_unpaid_leave_parental_leave_recent_ei_claim?" + reference = "tbd" + + def formula(persons, period, parameters): + return persons('income_status__has_lost_all_income', period) * (persons('income_status_reason__is_self_employed', period) + \ + persons('income_status_reason__has_unpaid_leave_to_care_for_child_or_sick', period) + \ + persons('income_status_reason__has_parental_recently_cant_return_to_work', period) + \ + persons('income_status_reason__has_ei_recent_claim_ended', period)) + +class cerb__is_eligible_lost_some_income_self_employed_1000_hours_or_less(Variable): + value_type = bool + entity = Person + definition_period = MONTH + default_value = False + label = u"is person eligible for cerb__is_eligible_lost_some_income_self_employed_1000_hours_or_less?" + reference = "tbd" + + def formula(persons, period, parameters): + return persons('income_status__has_lost_some_income', period) * persons('income_status_reason__is_self_employed', period) * \ + persons('income_status_reason__has_1000_or_less', period) + +class cerb__is_eligible_gross_income_over_5k(Variable): + value_type = bool + entity = Person + definition_period = MONTH + default_value = False + label = u"is person eligible fo cerb__is_eligible_gross_income_over_5k?" + reference = "tbd" + def formula(persons, period, parameters): - result = np.arange(1) - if (persons('income_status__has_lost_all_income', period) * (persons('income_status_reason__has_lost_job', period) + persons('income_status_reason__has_employer_closed', period))): - result[0]=1 - elif (persons('income_status__has_lost_all_income', period) * persons('income_status_reason__is_self_employed', period) + persons('income_status_reason__has_unpaid_leave_to_care_for_child_or_sick', period) + \ - persons('income_status_reason__has_parental_recently_cant_return_to_work', period) + persons('income_status_reason__has_ei_recent_claim_ended', period)): - result[0]= 4 - elif (persons('income_status__has_lost_some_income', period) * ((persons("income_status_reason__has_hours_reduced",period) + persons("income_status_reason__employed_lost_a_job",period)) * persons("income_status_reason__has_1000_or_less",period))): - result[0]= 2 - elif (persons('income_status__has_lost_some_income', period) * persons("income_status_reason__is_quarantined",period)): - result[0]= 3 - elif (persons('income_status__has_lost_some_income', period) * persons("income_status_reason__is_self_employed",period) * persons("income_status_reason__has_1000_or_less",period)): - result[0]= 5 - elif persons('income_status_reason__is_gross_income_over_5k', period): - result[0]= 6 - else: - result[0]= 0 - return result - \ No newline at end of file + return persons('income_status_reason__is_gross_income_over_5k', period) \ No newline at end of file