From 276f5bfa3c162bef425596cc6a9468a9c285b916 Mon Sep 17 00:00:00 2001 From: Pavel Makarchuk <110687043+PavelMakarchuk@users.noreply.github.com> Date: Sun, 18 Aug 2024 18:54:21 +0200 Subject: [PATCH] Personal Credit Reform (#4906) * Personal Credit Reform Fixes #4905 * reform structure * testing * add phase in to the basic income * test * circular ref. * include ss * remove reform * desc. * ss * test fix --- changelog_entry.yaml | 4 +++ .../include_ss_benefits_as_earnings.yaml | 7 ++++ .../basic_income/phase_in/per_person.yaml | 7 ++++ .../basic_income/phase_in/rate.yaml | 7 ++++ .../basic_income_before_phase_out.yaml | 27 ++++++++++++++ .../ubi_center/basic_income_phase_in.yaml | 35 +++++++++++++++++++ .../basic_income_before_phase_out.py | 4 ++- .../basic_income/basic_income_phase_in.py | 22 ++++++++++++ 8 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/include_ss_benefits_as_earnings.yaml create mode 100644 policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/per_person.yaml create mode 100644 policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/rate.yaml create mode 100644 policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_phase_in.yaml create mode 100644 policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_phase_in.py diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb2d..efaa06896fe 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added: + - Personal Credit reform. diff --git a/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/include_ss_benefits_as_earnings.yaml b/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/include_ss_benefits_as_earnings.yaml new file mode 100644 index 00000000000..6902cc47772 --- /dev/null +++ b/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/include_ss_benefits_as_earnings.yaml @@ -0,0 +1,7 @@ +description: Social Security benefits are treated as earnings under the basic income phase in if this is selected. +values: + 0000-01-01: false +metadata: + unit: bool + label: SS benefits treated as earnings for basic income + period: year diff --git a/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/per_person.yaml b/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/per_person.yaml new file mode 100644 index 00000000000..707ec8c90e0 --- /dev/null +++ b/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/per_person.yaml @@ -0,0 +1,7 @@ +description: Basic incomes phase in per person if this is selected; otherwise, they phase in at a flat rate irrespective of household size. +values: + 0000-01-01: false +metadata: + unit: bool + label: Phase in basic income per person + period: year diff --git a/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/rate.yaml b/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/rate.yaml new file mode 100644 index 00000000000..c1b4ce432f0 --- /dev/null +++ b/policyengine_us/parameters/gov/contrib/ubi_center/basic_income/phase_in/rate.yaml @@ -0,0 +1,7 @@ +description: The basic income phases in at this rate. +values: + 0000-01-01: 1 +metadata: + unit: /1 + label: Basic income phase-in rate + period: year diff --git a/policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_before_phase_out.yaml b/policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_before_phase_out.yaml index 3ad764aa540..b1839fd46d1 100644 --- a/policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_before_phase_out.yaml +++ b/policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_before_phase_out.yaml @@ -3,6 +3,7 @@ input: gov.contrib.ubi_center.basic_income.amount.person.flat: 100 tax_unit_size: 2 + basic_income_phase_in: 400 output: basic_income_before_phase_out: 200 @@ -19,6 +20,7 @@ tax_units: tax_unit: members: [adult, child] + basic_income_phase_in: 20_000 output: basic_income_before_phase_out: 15_000 @@ -27,6 +29,7 @@ input: gov.contrib.ubi_center.basic_income.amount.tax_unit.fpg_percent: 1 tax_unit_fpg: 10_000 + tax_unit_earned_income: 10_000 output: basic_income_before_phase_out: 10_000 @@ -44,6 +47,7 @@ tax_units: tax_unit: members: [adult, child] + basic_income_phase_in: 20_000 families: family: members: [adult, child] @@ -65,9 +69,32 @@ tax_units: tax_unit: members: [adult, child] + basic_income_phase_in: 20_000 families: family: members: [adult, child] is_married: false output: basic_income_before_phase_out: 15_000 + +- name: Not fully phased in + period: 2022 + input: + gov.contrib.ubi_center.basic_income.amount.person.by_age[3].amount: 10_000 + gov.contrib.ubi_center.basic_income.amount.person.by_age[0].amount: 5_000 + gov.contrib.ubi_center.basic_income.amount.person.marriage_bonus: 0.2 + people: + adult: + age: 26 + child: + age: 4 + tax_units: + tax_unit: + members: [adult, child] + basic_income_phase_in: 12_000 + families: + family: + members: [adult, child] + is_married: false + output: + basic_income_before_phase_out: 12_000 diff --git a/policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_phase_in.yaml b/policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_phase_in.yaml new file mode 100644 index 00000000000..37766c357c3 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/contrib/ubi_center/basic_income_phase_in.yaml @@ -0,0 +1,35 @@ +- name: Three people phased in at 70% with earned income + period: 2022 + input: + gov.contrib.ubi_center.basic_income.phase_in.rate: 0.7 + gov.contrib.ubi_center.basic_income.phase_in.per_person: false + gov.contrib.ubi_center.basic_income.phase_in.include_ss_benefits_as_earnings: false + tax_unit_earned_income: 2_000 + tax_unit_size: 3 + tax_unit_social_security: 0 + output: + basic_income_phase_in: 1_400 + +- name: Five people phased in at 30% with earned income, phased in per person + period: 2022 + input: + gov.contrib.ubi_center.basic_income.phase_in.rate: 0.3 + gov.contrib.ubi_center.basic_income.phase_in.per_person: true + gov.contrib.ubi_center.basic_income.phase_in.include_ss_benefits_as_earnings: true + tax_unit_earned_income: 2_000 + tax_unit_size: 5 + tax_unit_social_security: 0 + output: + basic_income_phase_in: 3_000 + +- name: SS included in earnings + period: 2022 + input: + gov.contrib.ubi_center.basic_income.phase_in.rate: 0.3 + gov.contrib.ubi_center.basic_income.phase_in.per_person: false + gov.contrib.ubi_center.basic_income.phase_in.include_ss_benefits_as_earnings: true + tax_unit_earned_income: 2_000 + tax_unit_size: 5 + tax_unit_social_security: 3_000 + output: + basic_income_phase_in: 1_500 diff --git a/policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_before_phase_out.py b/policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_before_phase_out.py index 3c90a283592..2ae0b5e354b 100644 --- a/policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_before_phase_out.py +++ b/policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_before_phase_out.py @@ -31,9 +31,11 @@ def formula(tax_unit, period, parameters): # Disability amount disabled = person("is_ssi_disabled", period) disabled_amount = tax_unit.sum(disabled * p.person.disability) - return ( + base_amount = ( total_flat_amount + applicable_amount_by_age + fpg_amount + disabled_amount ) + phase_in_amount = tax_unit("basic_income_phase_in", period) + return min_(base_amount, phase_in_amount) diff --git a/policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_phase_in.py b/policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_phase_in.py new file mode 100644 index 00000000000..7391c4148c3 --- /dev/null +++ b/policyengine_us/variables/contrib/ubi_center/basic_income/basic_income_phase_in.py @@ -0,0 +1,22 @@ +from policyengine_us.model_api import * + + +class basic_income_phase_in(Variable): + value_type = float + entity = TaxUnit + label = "Basic income phase-in" + definition_period = YEAR + unit = USD + + def formula(tax_unit, period, parameters): + p = parameters(period).gov.contrib.ubi_center.basic_income.phase_in + earnings = tax_unit("tax_unit_earned_income", period) + if p.include_ss_benefits_as_earnings: + ss_benefits = tax_unit("tax_unit_social_security", period) + earnings += ss_benefits + if p.per_person: + tax_unit_size = tax_unit("tax_unit_size", period) + rate = p.rate * tax_unit_size + else: + rate = p.rate + return rate * earnings