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

Issue:
Saskatchewan Age Amount
https://www.canada.ca/en/revenue-agency/services/forms-publications/td1-personal-tax-credits-returns/td1-forms-pay-received-on-january-1-later/td1sk.html


Discussion / hints:

Fix patch:
diff --git a/changelog_entry.yaml b/changelog_entry.yaml
index e69de29bb..f4f5b0574 100644
--- a/changelog_entry.yaml
+++ b/changelog_entry.yaml
@@ -0,0 +1,4 @@
+- bump: minor
+  changes:
+    added:
+    - Saskatchewan age amount tax credit.
diff --git a/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/age_eligibility.yaml b/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/age_eligibility.yaml
new file mode 100644
index 000000000..ad6a6dd01
--- /dev/null
+++ b/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/age_eligibility.yaml
@@ -0,0 +1,16 @@
+description: Saskatchewan provides the age amount credit for filers at or above this age threshold.
+values: 
+  2021-01-01: 65
+
+metadata:
+  unit: year
+  label: Saskatchewan age amount credit age eligibility
+  reference:
+  - title: 2021 Saskatchewan Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-21e.pdf#page=1
+  - title: 2022 Saskatchewan Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-22e.pdf#page=1
+  - title: 2023 Saskatchewan Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-23e.pdf#page=1
+  - title: The Income Tax Act, 2000 DIVISION 2 Section 17, Age Credit 17(1)
+    href: https://publications.saskatchewan.ca/api/v1/products/583/formats/806/download#page=15
diff --git a/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/max_amount.yaml b/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/max_amount.yaml
new file mode 100644
index 000000000..e83521a43
--- /dev/null
+++ b/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/max_amount.yaml
@@ -0,0 +1,18 @@
+description: Saskatchewan provides this maximum age amount credit.
+values: 
+  2021-01-01: 4_942
+  2022-01-01: 5_061
+  2023-01-01: 5_380
+
+metadata:
+  unit: currency-CAD
+  label: Saskatchewan age amount credit max amount
+  reference:
+  - title: 2021 Saskatchewan Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-21e.pdf#page=1
+  - title: 2022 Saskatchewan Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-22e.pdf#page=1
+  - title: 2023 Saskatchewan Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-23e.pdf#page=1
+  - title: The Income Tax Act, 2000 DIVISION 2 Section 17, Age Credit 17(1)
+    href: https://publications.saskatchewan.ca/api/v1/products/583/formats/806/download#page=15
diff --git a/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/reduction/rate.yaml b/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/reduction/rate.yaml
new file mode 100644
index 000000000..ba8683ef2
--- /dev/null
+++ b/policyengine_canada/parameters/gov/provinces/sk/tax/income/credits/age_amount/reduction/rate.yaml
@@ -0,0 +1,28 @@
+description: Saskatchewan reduces the age amount tax credit at this rate based on the income.
+
+metadata:
+  type: marginal_rate
+  threshold_unit: currency-CAD
+  rate_unit: /1
+  label: Saskatchewan age amount credit reduction rate
+  reference:
+  - title: Worksheet for the 2021 Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-21e.pdf#page=1
+  - title: Worksheet for the 2022 Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-22e.pdf#page=1
+  - title: Worksheet for the 2023 Personal Tax Credit Return
+    href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-23e.pdf#page=1
+  - title: The Income Tax Act, 2000 DIVISION 2 Section 17, Age Credit 17(1)
+    href: https://publications.saskatchewan.ca/api/v1/products/583/formats/806/download#page=15
+
+brackets:
+  - threshold:
+      2021-01-01: 0
+    rate:
+      2021-01-01: 0
+  - threshold:
+      2021-01-01: 36_794
+      2022-01-01: 37_677
+      2023-01-01: 40_051
+    rate:
+      2021-01-01: 0.15
diff --git a/policyengine_canada/variables/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount.py b/policyengine_canada/variables/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount.py
new file mode 100644
index 000000000..f66962d69
--- /dev/null
+++ b/policyengine_canada/variables/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount.py
@@ -0,0 +1,25 @@
+from policyengine_canada.model_api import *
+
+
+class sk_age_amount(Variable):
+    value_type = float
+    entity = Person
+    label = "Saskatchewan age amount credit"
+    unit = CAD
+    definition_period = YEAR
+    reference = (
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-21e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-22e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-23e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-21e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-22e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-23e.pdf#page=1",
+        "https://publications.saskatchewan.ca/api/v1/products/583/formats/806/download#page=15",
+    )
+    defined_for = "sk_age_amount_eligible"
+
+    def formula(person, period, parameters):
+        p = parameters(period).gov.provinces.sk.tax.income.credits.age_amount
+        income = person("individual_net_income", period)
+        reduction = p.reduction.rate.calc(income)
+        return max_(p.max_amount - reduction, 0)
diff --git a/policyengine_canada/variables/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount_eligible.py b/policyengine_canada/variables/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount_eligible.py
new file mode 100644
index 000000000..8a743fe96
--- /dev/null
+++ b/policyengine_canada/variables/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount_eligible.py
@@ -0,0 +1,24 @@
+from policyengine_canada.model_api import *
+
+
+class sk_age_amount_eligible(Variable):
+    value_type = bool
+    entity = Person
+    label = "Saskatchewan age amount eligibility"
+    unit = CAD
+    definition_period = YEAR
+    reference = (
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-21e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-22e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1sk/td1sk-23e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-21e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-22e.pdf#page=1",
+        "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1-ws/td1-ws-23e.pdf#page=1",
+        "https://publications.saskatchewan.ca/api/v1/products/583/formats/806/download#page=15",
+    )
+    defined_for = ProvinceCode.SK
+
+    def formula(person, period, parameters):
+        p = parameters(period).gov.provinces.sk.tax.income.credits.age_amount
+        age = person("age", period)
+        return age >= p.age_eligibility


Test patch:
diff --git a/policyengine_canada/tests/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount.yaml b/policyengine_canada/tests/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount.yaml
new file mode 100644
index 000000000..5a17ffcd7
--- /dev/null
+++ b/policyengine_canada/tests/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount.yaml
@@ -0,0 +1,117 @@
+- name: Ineligible
+  period: 2021
+  input:
+    province_code: SK
+    sk_age_amount_eligible: false
+    individual_net_income: 20_000
+  output:
+    sk_age_amount: 0
+
+
+- name: Eligible and net income below base amount
+  period: 2021
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 35_000
+  output:
+    sk_age_amount: 4_942
+
+
+- name: Eligible and net income between base net income amount and maximum net income amount # 4_942 - ((60_000 - 36_794) * 0.15)
+  period: 2021
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 60_000
+  output:
+    sk_age_amount: 1_461.1
+
+
+- name: Eligible over maximum net income amount
+  period: 2021
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 100_000
+  output:
+    sk_age_amount: 0
+
+- name: Ineligible
+  period: 2022
+  input:
+    province_code: SK
+    sk_age_amount_eligible: false
+    individual_net_income: 20_000
+  output:
+    sk_age_amount: 0
+
+
+- name: Eligible and net income below base amount
+  period: 2022
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 35_000
+  output:
+    sk_age_amount: 5_061
+
+
+- name: Eligible and net income between base net income amount and maximum net income amount # 5_061 - ((60_000 - 37_677) * 0.15)
+  period: 2022
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 60_000
+  output:
+    sk_age_amount: 1_712.55
+
+
+- name: Eligible over maximum net income amount
+  period: 2022
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 100_000
+  output:
+    sk_age_amount: 0
+
+
+- name: Ineligible
+  period: 2023
+  input:
+    province_code: SK
+    sk_age_amount_eligible: false
+    individual_net_income: 20_000
+  output:
+    sk_age_amount: 0
+
+
+- name: Eligible and net income below base amount
+  period: 2023
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 40_000
+  output:
+    sk_age_amount: 5_380
+
+
+- name: Eligible and net income between base net income amount and maximum net income amount # 5_380 - ((60_000 - 40_051) * 0.15)
+  period: 2023
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 60_000
+  output:
+    sk_age_amount: 2_387.65
+    
+
+- name: Eligible over maximum net income amount
+  period: 2023
+  input:
+    province_code: SK
+    sk_age_amount_eligible: true
+    individual_net_income: 100_000
+  output:
+    sk_age_amount: 0
diff --git a/policyengine_canada/tests/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount_eligible.yaml b/policyengine_canada/tests/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount_eligible.yaml
new file mode 100644
index 000000000..d96fca067
--- /dev/null
+++ b/policyengine_canada/tests/gov/provinces/sk/tax/income/credits/age_amount/sk_age_amount_eligible.yaml
@@ -0,0 +1,52 @@
+- name: Ineligible Age
+  period: 2021
+  input:
+    province_code: SK
+    age: 64
+  output: 
+    sk_age_amount_eligible: false
+
+
+- name: Eligible Age
+  period: 2021
+  input:
+    province_code: SK
+    age: 70
+  output:
+    sk_age_amount_eligible: true
+
+
+- name: Ineligible Age
+  period: 2022
+  input:
+    province_code: SK
+    age: 64
+  output: 
+    sk_age_amount_eligible: false
+
+
+- name: Eligible Age
+  period: 2022
+  input:
+    province_code: SK
+    age: 70
+  output:
+    sk_age_amount_eligible: true
+
+
+- name: Ineligible Age
+  period: 2023
+  input:
+    province_code: SK
+    age: 64
+  output: 
+    sk_age_amount_eligible: false
+
+
+- name: Eligible Age
+  period: 2023
+  input:
+    province_code: SK
+    age: 70
+  output:
+    sk_age_amount_eligible: true