diff --git a/l10n_us_wa_hr_payroll/README.rst b/l10n_us_wa_hr_payroll/README.rst new file mode 100644 index 00000000..1b6fb32e --- /dev/null +++ b/l10n_us_wa_hr_payroll/README.rst @@ -0,0 +1,20 @@ +************************************* +Hibou - US Payroll - Washington State +************************************* + +Calculations and contribution registers for Washington State Payroll. + +For more information and add-ons, visit `Hibou.io `_. + +============= +Main Features +============= + +* LNI (Labor and Industries) defined on HR Contracts that can be shared between contracts. +* Company level State Unemployment Rate (SUTA) + +======= +License +======= +Please see `LICENSE `_. +Copyright Hibou Corp. 2018 diff --git a/l10n_us_wa_hr_payroll/__init__.py b/l10n_us_wa_hr_payroll/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/l10n_us_wa_hr_payroll/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_us_wa_hr_payroll/__manifest__.py b/l10n_us_wa_hr_payroll/__manifest__.py new file mode 100755 index 00000000..2fc72921 --- /dev/null +++ b/l10n_us_wa_hr_payroll/__manifest__.py @@ -0,0 +1,29 @@ +{ + 'name': 'USA - Washington - Payroll', + 'author': 'Hibou Corp. ', + 'license': 'AGPL-3', + 'category': 'Localization', + 'depends': ['l10n_us_hr_payroll'], + 'version': '12.0.2019.0.0', + 'description': """ +USA::Washington Payroll Rules. +============================== + +* Contribution register and partner for Washington Employment Security Department - Unemployment +* Contribution register and partner for Washington Labor & Industries - (LNI) +* Contract level LNI +* Company level Washington Unemployment Rate + """, + + 'auto_install': False, + 'website': 'https://hibou.io/', + 'data': [ + 'security/ir.model.access.csv', + 'views/hr_payroll_views.xml', + 'data/base.xml', + 'data/rates.xml', + 'data/rules.xml', + 'data/final.xml', + ], + 'installable': True +} diff --git a/l10n_us_wa_hr_payroll/data/base.xml b/l10n_us_wa_hr_payroll/data/base.xml new file mode 100755 index 00000000..20ce5d4e --- /dev/null +++ b/l10n_us_wa_hr_payroll/data/base.xml @@ -0,0 +1,52 @@ + + + + + + Washington Employment Security Department - Unemployment Tax + 1 + + + + Washington Labor & Industries - LNI + 1 + + + + Washington Employment + Washington Employment Security Department - Unemployment + + + + Washington Labor & Industries + Washington Labor & Industries - LNI + + + + + + + Wage: US-WA Unemployment + WAGE_US_WA_UNEMP + + + + ER: US-WA Unemployment + ER_US_WA_UNEMP + + + + + ER: US-WA LNI + ER_US_WA_LNI + + + + + EE: US-WA LNI + EE_US_WA_LNI + + + + + diff --git a/l10n_us_wa_hr_payroll/data/final.xml b/l10n_us_wa_hr_payroll/data/final.xml new file mode 100755 index 00000000..b1655d4c --- /dev/null +++ b/l10n_us_wa_hr_payroll/data/final.xml @@ -0,0 +1,20 @@ + + + + + + + US_WA_EMP + USA Washington Employee + + + + + + + diff --git a/l10n_us_wa_hr_payroll/data/rates.xml b/l10n_us_wa_hr_payroll/data/rates.xml new file mode 100644 index 00000000..0278f36a --- /dev/null +++ b/l10n_us_wa_hr_payroll/data/rates.xml @@ -0,0 +1,19 @@ + + + + + US Washington Unemployment + US_WA_UNEMP + 1.16 + 2018-01-01 + + + + US Washington Unemployment + US_WA_UNEMP + 1.03 + 2019-01-01 + + + + \ No newline at end of file diff --git a/l10n_us_wa_hr_payroll/data/rules.xml b/l10n_us_wa_hr_payroll/data/rules.xml new file mode 100755 index 00000000..cfe87748 --- /dev/null +++ b/l10n_us_wa_hr_payroll/data/rules.xml @@ -0,0 +1,87 @@ + + + + + + + + Wage: US-WA Unemployment + WAGE_US_WA_UNEMP + python + result = (contract.futa_type != contract.FUTA_TYPE_BASIC) + code + +### +year = payslip.dict.date_to.year +rate = payslip.dict.get_rate('US_WA_UNEMP') +ytd = payslip.sum('WAGE_US_WA_UNEMP', str(year) + '-01-01', str(year+1) + '-01-01') +ytd += contract.external_wages +remaining = rate.wage_limit_year - ytd +if remaining <= 0.0: + result = 0 +elif remaining < categories.BASIC: + result = remaining +else: + result = categories.BASIC + + + + + + + + ER: US-WA Unemployment + ER_US_WA_UNEMP + python + result = (contract.futa_type != contract.FUTA_TYPE_BASIC) + code + +rate = payslip.dict.get_rate('US_WA_UNEMP') +result_rate = -rate.rate +result = categories.WAGE_US_WA_UNEMP + +# result_rate of 0 implies 100% due to bug +if result_rate == 0.0: + result = 0.0 + + + + + + + + + EE: US-WA LNI + EE_US_WA_LNI + none + code + +hours = worked_days.WORK100.number_of_hours +rate = contract.wa_lni.rate_emp_withhold +if rate: + result = -(hours * rate) + + + + + + + + + ER: US-WA LNI + ER_US_WA_LNI + + none + code + +hours = worked_days.WORK100.number_of_hours +rate = contract.wa_lni.rate +withholding = categories.EE_US_WA_LNI +if rate: + result = -(hours * rate) - withholding + + + + + + diff --git a/l10n_us_wa_hr_payroll/models/__init__.py b/l10n_us_wa_hr_payroll/models/__init__.py new file mode 100644 index 00000000..e99aa24a --- /dev/null +++ b/l10n_us_wa_hr_payroll/models/__init__.py @@ -0,0 +1 @@ +from . import hr_payroll diff --git a/l10n_us_wa_hr_payroll/models/hr_payroll.py b/l10n_us_wa_hr_payroll/models/hr_payroll.py new file mode 100755 index 00000000..6b5c023a --- /dev/null +++ b/l10n_us_wa_hr_payroll/models/hr_payroll.py @@ -0,0 +1,15 @@ +from odoo import models, fields, api + + +class USWAHrContract(models.Model): + _inherit = 'hr.contract' + + wa_lni = fields.Many2one('hr.contract.lni.wa', string='WA State LNI') + + +class WALNI(models.Model): + _name = 'hr.contract.lni.wa' + + name = fields.Char(string='Name') + rate = fields.Float(string='Rate (per hour worked)', digits=(7, 6)) + rate_emp_withhold = fields.Float(string='Employee Payroll Deduction Rate (per hour worked)', digits=(7, 6)) diff --git a/l10n_us_wa_hr_payroll/security/ir.model.access.csv b/l10n_us_wa_hr_payroll/security/ir.model.access.csv new file mode 100644 index 00000000..ac216dd2 --- /dev/null +++ b/l10n_us_wa_hr_payroll/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_hr_contract_lni_wa,access_hr_contract_lni_wa,model_hr_contract_lni_wa,base.group_user,1,0,0,0 +manage_hr_contract_lni_wa,manage_hr_contract_lni_wa,model_hr_contract_lni_wa,hr_payroll.group_hr_payroll_manager,1,1,1,1 \ No newline at end of file diff --git a/l10n_us_wa_hr_payroll/tests/__init__.py b/l10n_us_wa_hr_payroll/tests/__init__.py new file mode 100755 index 00000000..be35a060 --- /dev/null +++ b/l10n_us_wa_hr_payroll/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_us_wa_payslip_2018 +from . import test_us_wa_payslip_2019 diff --git a/l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2018.py b/l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2018.py new file mode 100755 index 00000000..9482b460 --- /dev/null +++ b/l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2018.py @@ -0,0 +1,60 @@ +from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip + + +class TestUsWAPayslip(TestUsPayslip): + ### + # Taxes and Rates + ### + WA_UNEMP_MAX_WAGE = 47300.0 + WA_UNEMP_RATE = 1.16 + + def setUp(self): + super(TestUsWAPayslip, self).setUp() + self.lni = self.env['hr.contract.lni.wa'].create({ + 'name': '5302 Computer Consulting', + 'rate': 0.1261, + 'rate_emp_withhold': 0.05575, + }) + + def test_2018_taxes(self): + salary = 25000.0 + + employee = self._createEmployee() + + contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_wa_hr_payroll.hr_payroll_salary_structure_us_wa_employee')) + self._log(str(contract.resource_calendar_id) + ' ' + contract.resource_calendar_id.name) + contract.wa_lni = self.lni + + # tax rates + wa_unemp = self.WA_UNEMP_RATE / -100.0 + + self._log('2018 Washington tax first payslip:') + payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31') + payslip.onchange_contract() + hours_in_period = payslip.worked_days_line_ids.filtered(lambda l: l.code == 'WORK100').number_of_hours + payslip.compute_sheet() + + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_WA_UNEMP'], salary) + self.assertPayrollEqual(cats['ER_US_WA_UNEMP'], cats['WAGE_US_WA_UNEMP'] * wa_unemp) + self.assertPayrollEqual(cats['EE_US_WA_LNI'], -(self.lni.rate_emp_withhold * hours_in_period)) + self.assertPayrollEqual(cats['ER_US_WA_LNI'], -(self.lni.rate * hours_in_period) - cats['EE_US_WA_LNI']) + + process_payslip(payslip) + + # Make a new payslip, this one will have maximums + + remaining_wa_unemp_wages = self.WA_UNEMP_MAX_WAGE - salary if (self.WA_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + self._log('2018 Washington tax second payslip:') + payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28') + payslip.onchange_contract() + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_WA_UNEMP'], remaining_wa_unemp_wages) + self.assertPayrollEqual(cats['ER_US_WA_UNEMP'], remaining_wa_unemp_wages * wa_unemp) diff --git a/l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2019.py b/l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2019.py new file mode 100755 index 00000000..72c0fc75 --- /dev/null +++ b/l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2019.py @@ -0,0 +1,60 @@ +from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip + + +class TestUsWAPayslip(TestUsPayslip): + ### + # Taxes and Rates + ### + WA_UNEMP_MAX_WAGE = 49800.0 + WA_UNEMP_RATE = 1.03 + + def setUp(self): + super(TestUsWAPayslip, self).setUp() + self.lni = self.env['hr.contract.lni.wa'].create({ + 'name': '5302 Computer Consulting', + 'rate': 0.1261, + 'rate_emp_withhold': 0.05575, + }) + + def test_2019_taxes(self): + salary = 25000.0 + + employee = self._createEmployee() + + contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_wa_hr_payroll.hr_payroll_salary_structure_us_wa_employee')) + self._log(str(contract.resource_calendar_id) + ' ' + contract.resource_calendar_id.name) + contract.wa_lni = self.lni + + # tax rates + wa_unemp = self.WA_UNEMP_RATE / -100.0 + + self._log('2019 Washington tax first payslip:') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + payslip.onchange_contract() + hours_in_period = payslip.worked_days_line_ids.filtered(lambda l: l.code == 'WORK100').number_of_hours + payslip.compute_sheet() + + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_WA_UNEMP'], salary) + self.assertPayrollEqual(cats['ER_US_WA_UNEMP'], cats['WAGE_US_WA_UNEMP'] * wa_unemp) + self.assertPayrollEqual(cats['EE_US_WA_LNI'], -(self.lni.rate_emp_withhold * hours_in_period)) + self.assertPayrollEqual(cats['ER_US_WA_LNI'], -(self.lni.rate * hours_in_period) - cats['EE_US_WA_LNI']) + + process_payslip(payslip) + + # Make a new payslip, this one will have maximums + + remaining_wa_unemp_wages = self.WA_UNEMP_MAX_WAGE - salary if (self.WA_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + self._log('2019 Washington tax second payslip:') + payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') + payslip.onchange_contract() + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_WA_UNEMP'], remaining_wa_unemp_wages) + self.assertPayrollEqual(cats['ER_US_WA_UNEMP'], remaining_wa_unemp_wages * wa_unemp) diff --git a/l10n_us_wa_hr_payroll/views/hr_payroll_views.xml b/l10n_us_wa_hr_payroll/views/hr_payroll_views.xml new file mode 100755 index 00000000..abd56634 --- /dev/null +++ b/l10n_us_wa_hr_payroll/views/hr_payroll_views.xml @@ -0,0 +1,20 @@ + + + + + hr.contract.form.inherit + hr.contract + 148 + + + + + + + + + + + + +