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

Issue:
Nova Scotia Pension Income Amount
Reference:
https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1


Discussion / hints:

Fix patch:
diff --git a/changelog_entry.yaml b/changelog_entry.yaml
index e69de29bb..94f8a2faf 100644
--- a/changelog_entry.yaml
+++ b/changelog_entry.yaml
@@ -0,0 +1,4 @@
+- bump: minor
+  changes:
+    added:
+    - Nova Scotia pension income amount.
diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/pension_income_amount/cap.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/pension_income_amount/cap.yaml
new file mode 100644
index 000000000..74afe880c
--- /dev/null
+++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/pension_income_amount/cap.yaml
@@ -0,0 +1,15 @@
+description: Nova Scotia caps the pension income amount at this amount. 
+values: 
+  2017-01-01: 1_173
+metadata:
+  unit: currency-CAD
+  period: year
+  label: Nova Scotia pension income amount cap 
+  reference: 
+  - title: 2022 Nova Scotia Personal Tax Credits Return Line 3
+    href: https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1
+  - title: 2022 Worksheet NS428
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/5003-c/5003-c-22e.pdf#page=1
+  - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada - 10H
+    href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28
+
diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_pension_income_amount.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_pension_income_amount.py
new file mode 100644
index 000000000..1aca64a60
--- /dev/null
+++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_pension_income_amount.py
@@ -0,0 +1,26 @@
+from policyengine_canada.model_api import *
+
+
+class ns_pension_income_amount(Variable):
+    value_type = float
+    entity = Person
+    label = "Nova Scotia pension income amount"
+    unit = CAD
+    definition_period = YEAR
+    defined_for = ProvinceCode.NS
+    reference = (
+        "https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/5003-c/5003-c-22e.pdf#page=1",
+        "https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28",
+    )
+
+    def formula(person, period, parameters):
+        p = parameters(
+            period
+        ).gov.provinces.ns.tax.income.credits.pension_income_amount
+
+        pension_income_amount = person(
+            "pension_and_savings_plan_income", period
+        )
+
+        return min_(pension_income_amount, p.cap)


Test patch:
diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_pension_income_amount.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_pension_income_amount.yaml
new file mode 100644
index 000000000..86104eef7
--- /dev/null
+++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_pension_income_amount.yaml
@@ -0,0 +1,31 @@
+- name: Person has pension income lower than 1_173
+  period: 2023
+  input:
+    province_code: NS
+    pension_and_savings_plan_income: 1_172
+  output:
+    ns_pension_income_amount: 1_172
+
+- name: Person has pension income equal to 1_173
+  period: 2023
+  input:
+    province_code: NS
+    pension_and_savings_plan_income: 1_173
+  output:
+    ns_pension_income_amount: 1_173
+
+- name: Person has pension income higher than 1_173
+  period: 2023
+  input:
+    province_code: NS
+    pension_and_savings_plan_income: 1_180
+  output:
+    ns_pension_income_amount: 1_173
+
+- name: Person has pension income 0
+  period: 2023
+  input:
+    province_code: NS
+    pension_and_savings_plan_income: 0
+  output:
+    ns_pension_income_amount: 0