Repository: PolicyEngine/policyengine-canada (language: python)

Issue:
New Brunswick Pension Benefit
Reference: https://www2.gnb.ca/content/gnb/en/services/services_renderer.2215.Pension_Benefits.html


Discussion / hints:

Fix patch:
diff --git a/changelog_entry.yaml b/changelog_entry.yaml
index e69de29bb..6699b08bf 100644
--- a/changelog_entry.yaml
+++ b/changelog_entry.yaml
@@ -0,0 +1,4 @@
+- bump: minor
+  changes:
+    added:
+    - New Brunswick pension benefit. 
diff --git a/policyengine_canada/parameters/gov/provinces/nb/benefits/pension_benefit/cap.yaml b/policyengine_canada/parameters/gov/provinces/nb/benefits/pension_benefit/cap.yaml
new file mode 100644
index 000000000..e10425b66
--- /dev/null
+++ b/policyengine_canada/parameters/gov/provinces/nb/benefits/pension_benefit/cap.yaml
@@ -0,0 +1,11 @@
+description: New Brunswick provides this maximum pension benefit.
+values:
+  2022-01-01: 1_000
+metadata:
+  unit: currency-CAD
+  label: New Brunswick pension benefit max amount
+  reference:
+  - title: Government of Canada - Province of New Brunswick
+    href: https://www.canada.ca/en/revenue-agency/services/forms-publications/tax-packages-years/general-income-tax-benefit-package/new-brunswick/5004-pc/information-residents-new-brunswick.html#P64_5140
+  - title: New Brunswick Income Tax Act
+    href: https://laws.gnb.ca/en/pdf/cs/N-6.001.pdf#page=31
diff --git a/policyengine_canada/variables/gov/provinces/nb/benefits/pension_benefit/nb_pension_benefit.py b/policyengine_canada/variables/gov/provinces/nb/benefits/pension_benefit/nb_pension_benefit.py
new file mode 100644
index 000000000..a1408f601
--- /dev/null
+++ b/policyengine_canada/variables/gov/provinces/nb/benefits/pension_benefit/nb_pension_benefit.py
@@ -0,0 +1,19 @@
+from policyengine_canada.model_api import *
+
+
+class nb_pension_benefit(Variable):
+    value_type = float
+    entity = Person
+    label = "New Brunswick pension benefit"
+    unit = CAD
+    definition_period = YEAR
+    defined_for = ProvinceCode.NB
+
+    def formula(person, period, parameters):
+        age = person("age", period)
+        pension_income = person("pension_and_savings_plan_income", period)
+        max_amount = parameters(
+            period
+        ).gov.provinces.nb.benefits.pension_benefit.cap
+        # Capped at a certain amount
+        return min_(max_amount, pension_income)


Test patch:
diff --git a/policyengine_canada/tests/gov/provinces/nb/pension_benefits/nb_pension_benefit.yaml b/policyengine_canada/tests/gov/provinces/nb/pension_benefits/nb_pension_benefit.yaml
new file mode 100644
index 000000000..d509fa0c6
--- /dev/null
+++ b/policyengine_canada/tests/gov/provinces/nb/pension_benefits/nb_pension_benefit.yaml
@@ -0,0 +1,16 @@
+- name: Max Pension Benefit 
+  period: 2023
+  input:
+    province_code: NB
+    pension_and_savings_plan_income: 20_000
+  output:
+    nb_pension_benefit: 1_000
+
+- name: Pension Benefit Below Maximum Amount
+  period: 2023
+  input:
+    province_code: NB
+    pension_and_savings_plan_income: 800
+  output:
+    nb_pension_benefit: 800
+