mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] l10n_ca_hr_payroll: add EI and improve FIT tests
This commit is contained in:
@@ -27,12 +27,6 @@
|
||||
</record>
|
||||
|
||||
<!-- Categories -->
|
||||
<record id="hr_payroll_category_ee_fed_fit" model="hr.salary.rule.category">
|
||||
<field name="name">EE: Federal Income Tax Withholding</field>
|
||||
<field name="code">EE_CA_FIT</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_category_ee_fed_cpp" model="hr.salary.rule.category">
|
||||
<field name="name">EE: Canada Pension Plan</field>
|
||||
<field name="code">EE_CA_CPP</field>
|
||||
@@ -45,7 +39,41 @@
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_category_ee_fed_fit" model="hr.salary.rule.category">
|
||||
<field name="name">EE: Federal Income Tax Withholding</field>
|
||||
<field name="code">EE_CA_FIT</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
<!-- Rules -->
|
||||
<record id="hr_payroll_rule_ee_fed_cpp" model="hr.salary.rule">
|
||||
<field name="sequence" eval="181"/>
|
||||
<field name="struct_id" ref="hr_ca_payroll_structure"/>
|
||||
<field name="category_id" ref="hr_payroll_category_ee_fed_cpp"/>
|
||||
<field name="name">EE: Canada Pension Plan</field>
|
||||
<field name="code">EE_CA_CPP</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result, _ = ca_cpp(payslip, categories, worked_days, inputs)</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">result, result_rate = ca_cpp(payslip, categories, worked_days, inputs)</field>
|
||||
<field name="partner_id" ref="res_partner_ca_fed"/>
|
||||
<field name="appears_on_payslip" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_rule_ee_fed_ei" model="hr.salary.rule">
|
||||
<field name="sequence" eval="186"/>
|
||||
<field name="struct_id" ref="hr_ca_payroll_structure"/>
|
||||
<field name="category_id" ref="hr_payroll_category_ee_fed_ei"/>
|
||||
<field name="name">EE: CA Employment Insurance</field>
|
||||
<field name="code">EE_CA_EI</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result, _ = ca_ei(payslip, categories, worked_days, inputs)</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">result, result_rate = ca_ei(payslip, categories, worked_days, inputs)</field>
|
||||
<field name="partner_id" ref="res_partner_ca_fed"/>
|
||||
<field name="appears_on_payslip" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_rule_ee_fed_fit" model="hr.salary.rule">
|
||||
<field name="sequence" eval="195"/>
|
||||
<field name="struct_id" ref="hr_ca_payroll_structure"/>
|
||||
@@ -60,7 +88,4 @@
|
||||
<field name="appears_on_payslip" eval="True"/>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
</odoo>
|
||||
@@ -1,5 +1,11 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
|
||||
def ca_cpp(payslip, categories, worked_days, inputs):
|
||||
if payslip.contract_id.ca_payroll_config_value('is_cpp_exempt'):
|
||||
return 0.0, 0.0
|
||||
return 0.0, 0.0
|
||||
|
||||
# from odoo import fields
|
||||
# from datetime import datetime, timedelta
|
||||
# import logging
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
|
||||
def ca_ei(payslip, categories, worked_days, inputs):
|
||||
if payslip.contract_id.ca_payroll_config_value('is_ei_exempt'):
|
||||
return 0.0, 0.0
|
||||
IE = categories.GROSS # TODO how to adjust
|
||||
year = payslip.dict.get_year()
|
||||
D1 = -payslip.sum_category('EE_CA_EI', str(year) + '-01-01', str(year + 1) + '-01-01')
|
||||
EI = round(min(889.54 - D1, 0.0158 * IE), 2)
|
||||
return -EI, 100.0
|
||||
|
||||
@@ -24,7 +24,7 @@ def ca_fit_federal_income_tax_withholding(payslip, categories, worked_days, inpu
|
||||
A = _compute_annual_taxable_income(payslip, categories)
|
||||
# If the result is negative, T = L.
|
||||
if A <= 0.0 and L:
|
||||
return -L, 1.0
|
||||
return -L, 100.0
|
||||
elif A <= 0.0:
|
||||
return 0.0, 0.0
|
||||
|
||||
@@ -47,10 +47,10 @@ def ca_fit_federal_income_tax_withholding(payslip, categories, worked_days, inpu
|
||||
|
||||
K2 = 0.0
|
||||
if not payslip.contract_id.ca_payroll_config_value('is_cpp_exempt'):
|
||||
C = categories.EE_CA_CPP
|
||||
C = -categories.EE_CA_CPP
|
||||
K2 += 0.15 * min(P * C, 3166.45) # min because we can only have up to
|
||||
if not payslip.contract_id.ca_payroll_config_value('is_ei_exempt'):
|
||||
EI = categories.EE_CA_EI
|
||||
EI = -categories.EE_CA_EI
|
||||
K2 += 0.15 * min(P * EI, 889.54)
|
||||
K3 = 0.0 # medical
|
||||
CEA = 1257.0 # TODO this is an indexed parameter
|
||||
@@ -60,6 +60,9 @@ def ca_fit_federal_income_tax_withholding(payslip, categories, worked_days, inpu
|
||||
|
||||
LCF = min(750.0, 0.15 * 0.0) # 0.0 => amount deducted or withheld during the year for the acquisition by the employee of approved shares of the capital stock of a prescribed labour-sponsored venture capital corporation
|
||||
T1 = T3 - LCF
|
||||
if T1 < 0.0:
|
||||
T1 = 0.0
|
||||
|
||||
T = (T1 / P) + L
|
||||
if T > 0.0:
|
||||
T = round(T, 2)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
from .federal.ca_fit import ca_fit_federal_income_tax_withholding
|
||||
from .federal.ca_cpp import ca_cpp
|
||||
from .federal.ca_ei import ca_ei
|
||||
|
||||
|
||||
class HRPayslip(models.Model):
|
||||
@@ -25,6 +27,8 @@ class HRPayslip(models.Model):
|
||||
res = super()._get_base_local_dict()
|
||||
res.update({
|
||||
'ca_fit_federal_income_tax_withholding': ca_fit_federal_income_tax_withholding,
|
||||
'ca_cpp': ca_cpp,
|
||||
'ca_ei': ca_ei,
|
||||
})
|
||||
return res
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestPayslip(TestCAPayslip):
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
is_cpp_exempt=True,
|
||||
if_ei_exempt=True,
|
||||
is_ei_exempt=True,
|
||||
)
|
||||
|
||||
self._log('2021 tax first payslip:')
|
||||
@@ -50,7 +50,7 @@ class TestPayslip(TestCAPayslip):
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
is_cpp_exempt=True,
|
||||
if_ei_exempt=True,
|
||||
is_ei_exempt=True,
|
||||
)
|
||||
payslip = self._createPayslip(employee, date_from, date_to)
|
||||
cats = self._getCategories(payslip)
|
||||
@@ -68,7 +68,7 @@ class TestPayslip(TestCAPayslip):
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
is_cpp_exempt=True,
|
||||
if_ei_exempt=True,
|
||||
is_ei_exempt=True,
|
||||
schedule_pay='weekly'
|
||||
)
|
||||
payslip = self._createPayslip(employee, date_from, date_to)
|
||||
@@ -77,3 +77,43 @@ class TestPayslip(TestCAPayslip):
|
||||
self.assertEqual(cats.get('EE_CA_CPP', 0.0), 0.0)
|
||||
self.assertEqual(cats.get('EE_CA_EI', 0.0), 0.0)
|
||||
self.assertPayrollAlmostEqual(cats['EE_CA_FIT'], -321.05) # note calculator says 321.00
|
||||
|
||||
def test_low_wage_additional(self):
|
||||
salary = 1000.0
|
||||
date_from = '2021-01-01'
|
||||
date_to = '2021-01-31'
|
||||
test_additional = 100.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
is_cpp_exempt=True,
|
||||
is_ei_exempt=True,
|
||||
fed_td1_additional=test_additional,
|
||||
)
|
||||
|
||||
payslip = self._createPayslip(employee, date_from, date_to)
|
||||
cats = self._getCategories(payslip)
|
||||
self.assertEqual(cats['GROSS'], 1000.0)
|
||||
self.assertEqual(cats.get('EE_CA_CPP', 0.0), 0.0)
|
||||
self.assertEqual(cats.get('EE_CA_EI', 0.0), 0.0)
|
||||
self.assertEqual(cats['EE_CA_FIT'], -test_additional)
|
||||
|
||||
def test_basic_ei(self):
|
||||
salary = 7000.0
|
||||
date_from = '2021-01-01'
|
||||
date_to = '2021-01-31'
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
wage=salary,
|
||||
is_cpp_exempt=True,
|
||||
is_ei_exempt=False
|
||||
)
|
||||
|
||||
payslip = self._createPayslip(employee, date_from, date_to)
|
||||
cats = self._getCategories(payslip)
|
||||
self.assertEqual(cats['GROSS'], 7000.0)
|
||||
self.assertEqual(cats.get('EE_CA_CPP', 0.0), 0.0)
|
||||
self.assertAlmostEqual(cats['EE_CA_EI'], -110.60)
|
||||
self.assertPayrollAlmostEqual(cats['EE_CA_FIT'], -1010.90)
|
||||
|
||||
Reference in New Issue
Block a user