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..e99aa24a --- /dev/null +++ b/l10n_us_wa_hr_payroll/__init__.py @@ -0,0 +1 @@ +from . import hr_payroll diff --git a/l10n_us_wa_hr_payroll/__manifest__.py b/l10n_us_wa_hr_payroll/__manifest__.py new file mode 100755 index 00000000..efad9188 --- /dev/null +++ b/l10n_us_wa_hr_payroll/__manifest__.py @@ -0,0 +1,28 @@ +{ + 'name': 'USA - Washington - Payroll', + 'author': 'Hibou Corp. ', + 'license': 'AGPL-3', + 'category': 'Localization', + 'depends': ['l10n_us_hr_payroll'], + 'version': '11.0.2018.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', + 'hr_payroll_view.xml', + 'data/base.xml', + 'data/rules_2018.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..3aea7bed --- /dev/null +++ b/l10n_us_wa_hr_payroll/data/base.xml @@ -0,0 +1,88 @@ + + + + + + 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 + + + + + + + Washington Unemployment - Wages + WA_UNEMP_WAGES + + + + Washington Unemployment + WA_UNEMP + + + + + Washington LNI + WA_LNI + + + + + Washington LNI Withholding + WA_LNI_WITHHOLD + + + + + + + + Washington LNI Withholding + WA_LNI_WITHHOLD + none + code + +hours = worked_days.WORK100.number_of_hours +rate = contract.wa_lni.rate_emp_withhold +if rate: + result = -(hours * rate) + + + + + + + + Washington LNI + WA_LNI + + none + code + +hours = worked_days.WORK100.number_of_hours +rate = contract.wa_lni.rate +withholding = categories.WA_LNI_WITHHOLD +if rate: + result = -(hours * rate) - withholding + + + + + + + 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/rules_2018.xml b/l10n_us_wa_hr_payroll/data/rules_2018.xml new file mode 100755 index 00000000..a8271265 --- /dev/null +++ b/l10n_us_wa_hr_payroll/data/rules_2018.xml @@ -0,0 +1,49 @@ + + + + + + + + + Washington Unemployment - Wages (2018) + WA_UNEMP_WAGES_2018 + python + result = (payslip.date_to[:4] == '2018') + code + +### +ytd = payslip.sum('WA_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01') +ytd += contract.external_wages +remaining = 47300.0 - ytd +if remaining <= 0.0: + result = 0 +elif remaining < categories.GROSS: + result = remaining +else: + result = categories.GROSS + + + + + + + Washington Unemployment (2018) + WA_UNEMP_2018 + python + result = (payslip.date_to[:4] == '2018') + code + +result_rate = -contract.wa_unemp_rate(2018) +result = categories.WA_UNEMP_WAGES + +# result_rate of 0 implies 100% due to bug +if result_rate == 0.0: + result = 0.0 + + + + + + + diff --git a/l10n_us_wa_hr_payroll/hr_payroll.py b/l10n_us_wa_hr_payroll/hr_payroll.py new file mode 100755 index 00000000..6e45dbc8 --- /dev/null +++ b/l10n_us_wa_hr_payroll/hr_payroll.py @@ -0,0 +1,33 @@ +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') + + @api.multi + def wa_unemp_rate(self, year): + self.ensure_one() + if self.futa_type == self.FUTA_TYPE_BASIC: + return 0.0 + + if hasattr(self.employee_id.company_id, 'wa_unemp_rate_' + str(year)): + return self.employee_id.company_id['wa_unemp_rate_' + str(year)] + + raise NotImplemented('Year (' + str(year) + ') Not implemented for US Washington.') + + +class WACompany(models.Model): + _inherit = 'res.company' + + # No Defaults, need to sign up with the Employment Security Department + wa_unemp_rate_2018 = fields.Float(string="Washington Unemployment Rate 2018", default=0.0) + + +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/hr_payroll_view.xml b/l10n_us_wa_hr_payroll/hr_payroll_view.xml new file mode 100755 index 00000000..519391bc --- /dev/null +++ b/l10n_us_wa_hr_payroll/hr_payroll_view.xml @@ -0,0 +1,31 @@ + + + + + res.company.form + res.company + 64 + + + + + + + + + + + hr.contract.form.inherit + hr.contract + 64 + + + + + + + + + + + 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..c6d19c7c --- /dev/null +++ b/l10n_us_wa_hr_payroll/tests/__init__.py @@ -0,0 +1 @@ +from . import test_us_wa_payslip_2018 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..54631587 --- /dev/null +++ b/l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2018.py @@ -0,0 +1,61 @@ +from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip +from odoo.addons.l10n_us_hr_payroll.l10n_us_hr_payroll import USHrContract + + +class TestUsWAPayslip(TestUsPayslip): + ### + # Taxes and Rates + ### + WA_UNEMP_MAX_WAGE = 47300.0 + + 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() + employee.company_id.wa_unemp_rate_2018 = 1.16 + + 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 = contract.wa_unemp_rate(2018) / -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['WA_UNEMP_WAGES'], salary) + self.assertPayrollEqual(cats['WA_UNEMP'], cats['WA_UNEMP_WAGES'] * wa_unemp) + self.assertPayrollEqual(cats['WA_LNI_WITHHOLD'], -(self.lni.rate_emp_withhold * hours_in_period)) + self.assertPayrollEqual(cats['WA_LNI'], -(self.lni.rate * hours_in_period) - cats['WA_LNI_WITHHOLD']) + + 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['WA_UNEMP_WAGES'], remaining_wa_unemp_wages) + self.assertPayrollEqual(cats['WA_UNEMP'], remaining_wa_unemp_wages * wa_unemp)