diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..6beb1147e 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Bug causing child minimum basic income ages to function incorrectly when the adult UBI is nonzero. diff --git a/policyengine_uk/tests/policy/reforms/parametric/basic_income/bi_maximum.yaml b/policyengine_uk/tests/policy/reforms/parametric/basic_income/bi_maximum.yaml new file mode 100644 index 000000000..d7f38ae47 --- /dev/null +++ b/policyengine_uk/tests/policy/reforms/parametric/basic_income/bi_maximum.yaml @@ -0,0 +1,10 @@ +- name: Minimum child age functions correctly when adult is non zero. + period: 2021 + input: + gov.contrib.ubi_center.basic_income.amount.child_min_age: 16 + gov.contrib.ubi_center.basic_income.amount.by_age.working_age: 1 + people: + child: + age: 14 + output: + basic_income: 0 diff --git a/policyengine_uk/variables/contrib/ubi_center/basic_income/bi_maximum.py b/policyengine_uk/variables/contrib/ubi_center/basic_income/bi_maximum.py index 22271484d..95e77f402 100644 --- a/policyengine_uk/variables/contrib/ubi_center/basic_income/bi_maximum.py +++ b/policyengine_uk/variables/contrib/ubi_center/basic_income/bi_maximum.py @@ -16,9 +16,13 @@ def formula(person, period, parameters): is_child_for_bi = (age < bi.amount.adult_age) * ( age >= bi.amount.child_min_age ) + is_adult_for_bi = (age >= bi.amount.adult_age) * ~is_senior_for_bi weekly_amount_by_age = select( - [is_child_for_bi, is_senior_for_bi], - [bi.amount.by_age.child, bi.amount.by_age.senior], - default=bi.amount.by_age.working_age, + [is_child_for_bi, is_senior_for_bi, is_adult_for_bi], + [ + bi.amount.by_age.child, + bi.amount.by_age.senior, + bi.amount.by_age.working_age, + ], ) return (weekly_flat_amount + weekly_amount_by_age) * WEEKS_IN_YEAR