diff --git a/l10n_us_oh_hr_payroll/README.rst b/l10n_us_oh_hr_payroll/README.rst new file mode 100644 index 00000000..1312b209 --- /dev/null +++ b/l10n_us_oh_hr_payroll/README.rst @@ -0,0 +1,68 @@ +******************************* +Hibou - US Payroll - Ohio State +******************************* + +Calculations and contribution registers for Ohio State Payroll. + +For more information and add-ons, visit `Hibou.io `_. + +============= +Main Features +============= + +* New Ohio Department of Revenue partner +* Contribution Registers for: + * Ohio Department of Revenue - Unemployment + * Ohio Department of Revenue - Income Tax withholding +* Contract level Ohio Withholding Allowance +* Company level Ohio Unemployment Rate + +.. image:: https://user-images.githubusercontent.com/15882954/41481725-e1cbd3c4-7087-11e8-8bf7-84843bb2f943.png + :alt: 'Employee Contract Detail' + :width: 988 + :align: left + +USA Ohio Employee added to Contract Salary Structure Menu + +.. image:: https://user-images.githubusercontent.com/15882954/41481743-f1eceb4e-7087-11e8-8d09-dd45551a3fa4.png + :alt: 'Computed Pay Slip Detail' + :width: 988 + :align: left + +New Payslip Categories for: + +* Ohio Income Withholding +* Ohio Unemployment - Wages +* Ohio Unemployment + +Upgrading to 2019 +========================== + +If you were using this prior to January 2019, then you will need to run the following +migration script. + +Odoo Shell code:: + + def migrate_rule_name(rule_id): + main = env.ref(rule_id) + old_2017 = env.ref(rule_id.replace('2018', '2017')) + old_2016 = env.ref(rule_id.replace('2018', '2016')) + lines = env['hr.payslip.line'].search([('salary_rule_id', 'in', [old_2017.id, old_2016.id,])]) + lines.write({'salary_rule_id': main.id}) + + rules = [ + 'l10n_us_oh_hr_payroll.hr_payroll_rules_oh_unemp_wages_2018', + 'l10n_us_oh_hr_payroll.hr_payroll_rules_oh_unemp_2018', + 'l10n_us_oh_hr_payroll.hr_payroll_rules_oh_inc_withhold_2018', + ] + for rule_id in rules: + migrate_rule_name(rule_id) + + env.cr.commit() + + +======= +License +======= +Please see `LICENSE `_. +Copyright Hibou Corp. 2018 diff --git a/l10n_us_oh_hr_payroll/__init__.py b/l10n_us_oh_hr_payroll/__init__.py new file mode 100755 index 00000000..0650744f --- /dev/null +++ b/l10n_us_oh_hr_payroll/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_us_oh_hr_payroll/__manifest__.py b/l10n_us_oh_hr_payroll/__manifest__.py new file mode 100755 index 00000000..ea602ecd --- /dev/null +++ b/l10n_us_oh_hr_payroll/__manifest__.py @@ -0,0 +1,29 @@ +{ + 'name': 'USA - Ohio - Payroll', + 'author': 'Hibou Corp. ', + 'license': 'AGPL-3', + 'category': 'Localization', + 'depends': ['l10n_us_hr_payroll'], + 'version': '12.0.2019.0.0', + 'description': """ +USA::Ohio Payroll Rules. +======================== + + * Ohio Department of Revenue partner + * Contribution register for Ohio DoR Unemployment + * Contribution register for Ohio DoR Income Tax Withholding + * Contract level Ohio Withholding Allowance + * Company level Ohio Unemployment Rate + """, + + 'auto_install': False, + 'website': 'https://hibou.io/', + 'data':[ + 'views/hr_payroll_views.xml', + 'data/base.xml', + 'data/rates.xml', + 'data/rules.xml', + 'data/final.xml', + ], + 'installable': True +} diff --git a/l10n_us_oh_hr_payroll/data/base.xml b/l10n_us_oh_hr_payroll/data/base.xml new file mode 100755 index 00000000..3ca54fc3 --- /dev/null +++ b/l10n_us_oh_hr_payroll/data/base.xml @@ -0,0 +1,46 @@ + + + + + + Ohio OBG - Unemployment + 1 + + + + Ohio OBG - Income Withholding + 1 + + + + Ohio Unemployment + Ohio Treasurer of State - Unemployment + + + + Ohio Income Tax Withholding + Ohio Treasurer of State - Income Tax Withholding + + + + + + + Wage: US-OH Unemployment + WAGE_US_OH_UNEMP + + + + ER: US-OH Unemployment + ER_US_OH_UNEMP + + + + + EE: US-OH Income Withholding + EE_US_OH_INC_WITHHOLD + + + + + diff --git a/l10n_us_oh_hr_payroll/data/final.xml b/l10n_us_oh_hr_payroll/data/final.xml new file mode 100755 index 00000000..6a94e0a5 --- /dev/null +++ b/l10n_us_oh_hr_payroll/data/final.xml @@ -0,0 +1,19 @@ + + + + + + + US_OH_EMP + USA Ohio Employee + + + + + + + diff --git a/l10n_us_oh_hr_payroll/data/rates.xml b/l10n_us_oh_hr_payroll/data/rates.xml new file mode 100755 index 00000000..e8c415aa --- /dev/null +++ b/l10n_us_oh_hr_payroll/data/rates.xml @@ -0,0 +1,19 @@ + + + + + US Ohio Unemployment + US_OH_UNEMP + 2.7 + 2018-01-01 + + + + US Ohio Unemployment + US_OH_UNEMP + 2.7 + 2019-01-01 + + + + diff --git a/l10n_us_oh_hr_payroll/data/rules.xml b/l10n_us_oh_hr_payroll/data/rules.xml new file mode 100755 index 00000000..db60a9c1 --- /dev/null +++ b/l10n_us_oh_hr_payroll/data/rules.xml @@ -0,0 +1,128 @@ + + + + + + + + + Wage: US-OH Unemployment + WAGE_US_OH_UNEMP + python + result = (contract.futa_type != contract.FUTA_TYPE_BASIC) + code + +### +rate = payslip.dict.get_rate('US_OH_UNEMP') +year = payslip.dict.date_to.year +ytd = payslip.sum('WAGE_US_OH_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-OH Unemployment + ER_US_OH_UNEMP + python + result = (contract.futa_type != contract.FUTA_TYPE_BASIC) + code + +rate = payslip.dict.get_rate('US_OH_UNEMP') +result_rate = -rate.rate +result = categories.WAGE_US_OH_UNEMP + +# result_rate of 0 implies 100% due to bug +if result_rate == 0.0: + result = 0.0 + + + + + + + + + EE: US-OH Income Withholding + EE_US_OH_INC_WITHHOLD + python + result = True + code + +year = payslip.dict.date_to.year +wages = categories.GROSS +allowances = contract.oh_income_allowances +schedule_pay = contract.schedule_pay +val = 0.00 + +PP = 0 +if 'weekly' == schedule_pay: + PP = 52 +elif 'bi-weekly' == schedule_pay: + PP = 26 +elif 'semi-monthly' == schedule_pay: # impossible + PP = 24 +elif 'monthly' == schedule_pay: + PP = 12 +elif 'quarterly' == schedule_pay: + PP = 4 +elif 'semi-annually' == schedule_pay: + PP = 2 +elif 'annually' == schedule_pay: + PP = 1 +else: + raise Exception('Invalid schedule_pay="' + schedule_pay + '" for OH Income Withholding calculation') + +# Algorithm from https://www.tax.ohio.gov/Portals/0/employer_withholding/2019%20tables/WTH_OptionalComputerFormula_2019.pdf +if year == 2018: + TW = (wages * PP) - (650 * allowances) + if TW <= 5000.0: + WD = ((TW * 0.005) / PP) * 1.112 + elif TW <= 10000.0: + WD = ((((TW - 5000.0) * 0.01) + 25.0) / PP) * 1.112 + elif TW <= 15000.0: + WD = ((((TW - 10000.0) * 0.02) + 75.0) / PP) * 1.112 + elif TW <= 20000.0: + WD = ((((TW - 15000.0) * 0.025) + 175.0) / PP) * 1.112 + elif TW <= 40000.0: + WD = ((((TW - 20000.0) * 0.03) + 300.0) / PP) * 1.112 + elif TW <= 80000.0: + WD = ((((TW - 40000.0) * 0.035) + 900.0) / PP) * 1.112 + elif TW <= 100000.0: + WD = ((((TW - 80000.0) * 0.04) + 2300.0) / PP) * 1.112 + else: + WD = ((((TW - 100000.0) * 0.05) + 3100.0) / PP) * 1.112 +else: + TW = (wages * PP) - (650 * allowances) + if TW <= 5000.0: + WD = ((TW * 0.005) / PP) * 1.112 + elif TW <= 10000.0: + WD = ((((TW - 5000.0) * 0.01) + 25.0) / PP) * 1.075 + elif TW <= 15000.0: + WD = ((((TW - 10000.0) * 0.02) + 75.0) / PP) * 1.075 + elif TW <= 20000.0: + WD = ((((TW - 15000.0) * 0.025) + 175.0) / PP) * 1.075 + elif TW <= 40000.0: + WD = ((((TW - 20000.0) * 0.03) + 300.0) / PP) * 1.075 + elif TW <= 80000.0: + WD = ((((TW - 40000.0) * 0.035) + 900.0) / PP) * 1.075 + elif TW <= 100000.0: + WD = ((((TW - 80000.0) * 0.04) + 2300.0) / PP) * 1.075 + else: + WD = ((((TW - 100000.0) * 0.05) + 3100.0) / PP) * 1.075 + +result = -WD + + + + + + diff --git a/l10n_us_oh_hr_payroll/models/__init__.py b/l10n_us_oh_hr_payroll/models/__init__.py new file mode 100644 index 00000000..e99aa24a --- /dev/null +++ b/l10n_us_oh_hr_payroll/models/__init__.py @@ -0,0 +1 @@ +from . import hr_payroll diff --git a/l10n_us_oh_hr_payroll/models/hr_payroll.py b/l10n_us_oh_hr_payroll/models/hr_payroll.py new file mode 100755 index 00000000..9917337f --- /dev/null +++ b/l10n_us_oh_hr_payroll/models/hr_payroll.py @@ -0,0 +1,8 @@ +from odoo import models, fields, api + + +class USOHHrContract(models.Model): + _inherit = 'hr.contract' + + oh_income_allowances = fields.Integer(string='Ohio Income Allowances', default=0) + oh_additional_withholding = fields.Float(string="Additional Withholding", default=0.0) diff --git a/l10n_us_oh_hr_payroll/tests/__init__.py b/l10n_us_oh_hr_payroll/tests/__init__.py new file mode 100755 index 00000000..d7ed2c2e --- /dev/null +++ b/l10n_us_oh_hr_payroll/tests/__init__.py @@ -0,0 +1,2 @@ +from . import test_us_oh_payslip_2018 +from . import test_us_oh_payslip_2019 diff --git a/l10n_us_oh_hr_payroll/tests/test_us_oh_payslip_2018.py b/l10n_us_oh_hr_payroll/tests/test_us_oh_payslip_2018.py new file mode 100755 index 00000000..b4b7f1af --- /dev/null +++ b/l10n_us_oh_hr_payroll/tests/test_us_oh_payslip_2018.py @@ -0,0 +1,93 @@ +from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip +from odoo.addons.l10n_us_hr_payroll.models.l10n_us_hr_payroll import USHrContract + + +class TestUsOhPayslip(TestUsPayslip): + ### + # Taxes and Rates + ### + OH_UNEMP_MAX_WAGE = 9500.0 + OH_UNEMP = -2.7 / 100.0 + + def test_2018_taxes(self): + salary = 5000.0 + + # For formula here + # http://www.tax.ohio.gov/Portals/0/employer_withholding/August2015Rates/WTH_OptionalComputerFormula_073015.pdf + tw = salary * 12 # = 60000 + wd = ((tw - 40000) * 0.035 + 900) / 12 * 1.112 + + employee = self._createEmployee() + + contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee')) + + self._log('2017 Ohio tax last payslip:') + payslip = self._createPayslip(employee, '2017-12-01', '2017-12-31') + payslip.compute_sheet() + process_payslip(payslip) + + self._log('2018 Ohio tax first payslip:') + payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_OH_UNEMP'], salary) + self.assertPayrollEqual(cats['ER_US_OH_UNEMP'], cats['WAGE_US_OH_UNEMP'] * self.OH_UNEMP) + self.assertPayrollEqual(cats['EE_US_OH_INC_WITHHOLD'], -wd) + + process_payslip(payslip) + + # Make a new payslip, this one will have maximums + + remaining_oh_unemp_wages = self.OH_UNEMP_MAX_WAGE - salary if (self.OH_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + self._log('2018 Ohio tax second payslip:') + payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_OH_UNEMP'], remaining_oh_unemp_wages) + self.assertPayrollEqual(cats['ER_US_OH_UNEMP'], remaining_oh_unemp_wages * self.OH_UNEMP) + + def test_2018_taxes_with_external(self): + salary = 5000.0 + external_wages = 6000.0 + + employee = self._createEmployee() + + contract = self._createContract(employee, salary, external_wages=external_wages, + struct_id=self.ref('l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee')) + + self._log('2018 Ohio_external tax first payslip:') + payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_OH_UNEMP'], self.OH_UNEMP_MAX_WAGE - external_wages) + self.assertPayrollEqual(cats['ER_US_OH_UNEMP'], cats['WAGE_US_OH_UNEMP'] * self.OH_UNEMP) + + def test_2018_taxes_with_state_exempt(self): + salary = 5000.0 + external_wages = 6000.0 + + employee = self._createEmployee() + contract = self._createContract(employee, salary, external_wages=external_wages, struct_id=self.ref( + 'l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee'), futa_type=USHrContract.FUTA_TYPE_BASIC) + + self._log('2018 Ohio exempt tax first payslip:') + payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + # FUTA_TYPE_BASIC + self.assertPayrollEqual(cats.get('WAGE_US_OH_UNEMP', 0.0), 0.0) + self.assertPayrollEqual(cats.get('ER_US_OH_UNEMP', 0.0), cats.get('WAGE_US_OH_UNEMP', 0.0) * 0.0) diff --git a/l10n_us_oh_hr_payroll/tests/test_us_oh_payslip_2019.py b/l10n_us_oh_hr_payroll/tests/test_us_oh_payslip_2019.py new file mode 100755 index 00000000..0783ad36 --- /dev/null +++ b/l10n_us_oh_hr_payroll/tests/test_us_oh_payslip_2019.py @@ -0,0 +1,93 @@ +from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip +from odoo.addons.l10n_us_hr_payroll.models.l10n_us_hr_payroll import USHrContract + + +class TestUsOhPayslip(TestUsPayslip): + ### + # Taxes and Rates + ### + OH_UNEMP_MAX_WAGE = 9500.0 + OH_UNEMP = -2.7 / 100.0 + + def test_2019_taxes(self): + salary = 5000.0 + + # For formula here + # http://www.tax.ohio.gov/Portals/0/employer_withholding/August2015Rates/WTH_OptionalComputerFormula_073015.pdf + tw = salary * 12 # = 60000 + wd = ((tw - 40000) * 0.035 + 900) / 12 * 1.075 + + employee = self._createEmployee() + + contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee')) + + self._log('2018 Ohio tax last payslip:') + payslip = self._createPayslip(employee, '2018-12-01', '2018-12-31') + payslip.compute_sheet() + process_payslip(payslip) + + self._log('2019 Ohio tax first payslip:') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_OH_UNEMP'], salary) + self.assertPayrollEqual(cats['ER_US_OH_UNEMP'], cats['WAGE_US_OH_UNEMP'] * self.OH_UNEMP) + self.assertPayrollEqual(cats['EE_US_OH_INC_WITHHOLD'], -wd) + + process_payslip(payslip) + + # Make a new payslip, this one will have maximums + + remaining_oh_unemp_wages = self.OH_UNEMP_MAX_WAGE - salary if (self.OH_UNEMP_MAX_WAGE - 2*salary < salary) \ + else salary + + self._log('2019 Ohio tax second payslip:') + payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_OH_UNEMP'], remaining_oh_unemp_wages) + self.assertPayrollEqual(cats['ER_US_OH_UNEMP'], remaining_oh_unemp_wages * self.OH_UNEMP) + + def test_2019_taxes_with_external(self): + salary = 5000.0 + external_wages = 6000.0 + + employee = self._createEmployee() + + contract = self._createContract(employee, salary, external_wages=external_wages, + struct_id=self.ref('l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee')) + + self._log('2019 Ohio_external tax first payslip:') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + self.assertPayrollEqual(cats['WAGE_US_OH_UNEMP'], self.OH_UNEMP_MAX_WAGE - external_wages) + self.assertPayrollEqual(cats['ER_US_OH_UNEMP'], cats['WAGE_US_OH_UNEMP'] * self.OH_UNEMP) + + def test_2019_taxes_with_state_exempt(self): + salary = 5000.0 + external_wages = 6000.0 + + employee = self._createEmployee() + contract = self._createContract(employee, salary, external_wages=external_wages, struct_id=self.ref( + 'l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee'), futa_type=USHrContract.FUTA_TYPE_BASIC) + + self._log('2019 Ohio exempt tax first payslip:') + payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31') + + payslip.compute_sheet() + + cats = self._getCategories(payslip) + + # FUTA_TYPE_BASIC + self.assertPayrollEqual(cats.get('WAGE_US_OH_UNEMP', 0.0), 0.0) + self.assertPayrollEqual(cats.get('ER_US_OH_UNEMP', 0.0), cats.get('WAGE_US_OH_UNEMP', 0.0) * 0.0) diff --git a/l10n_us_oh_hr_payroll/views/hr_payroll_views.xml b/l10n_us_oh_hr_payroll/views/hr_payroll_views.xml new file mode 100755 index 00000000..19f084f4 --- /dev/null +++ b/l10n_us_oh_hr_payroll/views/hr_payroll_views.xml @@ -0,0 +1,21 @@ + + + + + hr.contract.form.inherit + hr.contract + 130 + + + + + + + + + + + + + +