hr_payroll_holidays
hr_payroll_input_name_report
hr_payroll_input_report
hr_payroll_payment
hr_payroll_timesheet
hr_payslip_line_date
l10n_us_fl_hr_payroll
l10n_us_hr_payroll
l10n_us_mo_hr_payroll
l10n_us_oh_hr_payroll
l10n_us_va_hr_payroll
This commit is contained in:
Jared Kipe
2018-04-30 08:15:31 -07:00
parent 14878ae669
commit eb4de8bddc
13 changed files with 811 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import hr_payroll

View File

@@ -0,0 +1,31 @@
# -*- encoding: utf-8 -*-
{
'name': 'USA - Ohio - Payroll',
'author': 'Hibou Corp. <hello@hibou.io>',
'license': 'AGPL-3',
'category': 'Localization',
'depends': ['l10n_us_hr_payroll'],
'version': '11.0.2017.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':[
'hr_payroll_view.xml',
'data/base.xml',
'data/rules_2016.xml',
'data/rules_2017.xml',
'data/rules_2018.xml',
'data/final.xml',
],
'installable': True
}

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- CONTRIBUTION REGISTERS -->
<record id="res_partner_ohdor_unemp" model="res.partner">
<field name="name">Ohio OBG - Unemployment</field>
<field name="supplier">1</field>
<field eval="0" name="customer"/>
</record>
<record id="res_partner_ohdor_withhold" model="res.partner">
<field name="name">Ohio OBG - Income Withholding</field>
<field name="supplier">1</field>
<field eval="0" name="customer"/>
</record>
<record id="contrib_register_ohdor_unemp" model="hr.contribution.register">
<field name="name">Ohio Unemployment</field>
<field name="note">Ohio Treasurer of State - Unemployment</field>
<field name="partner_id" ref="res_partner_ohdor_unemp"/>
</record>
<record id="contrib_register_ohdor_withhold" model="hr.contribution.register">
<field name="name">Ohio Income Tax Withholding</field>
<field name="note">Ohio Treasurer of State - Income Tax Withholding</field>
<field name="partner_id" ref="res_partner_ohdor_withhold"/>
</record>
<!-- HR SALARY RULE CATEGORIES-->
<record id="hr_payroll_oh_unemp_wages" model="hr.salary.rule.category">
<field name="name">Ohio Unemployment - Wages</field>
<field name="code">OH_UNEMP_WAGES</field>
</record>
<record id="hr_payroll_oh_unemp" model="hr.salary.rule.category">
<field name="name">Ohio Unemployment</field>
<field name="code">OH_UNEMP</field>
<field name="parent_id" ref="hr_payroll.COMP"/>
</record>
<record id="hr_payroll_oh_income_withhold" model="hr.salary.rule.category">
<field name="name">Ohio Income Withholding</field>
<field name="code">OH_INC_WITHHOLD</field>
<field name="parent_id" ref="hr_payroll.DED"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR PAYROLL STRUCTURE -->
<record id="hr_payroll_salary_structure_us_oh_employee" model="hr.payroll.structure">
<field name="code">US_OH_EMP</field>
<field name="name">USA Ohio Employee</field>
<field eval="[(6, 0, [
ref('hr_payroll_rules_oh_unemp_wages_2016'),
ref('hr_payroll_rules_oh_unemp_2016'),
ref('hr_payroll_rules_oh_inc_withhold_2016'),
ref('hr_payroll_rules_oh_unemp_wages_2017'),
ref('hr_payroll_rules_oh_unemp_2017'),
ref('hr_payroll_rules_oh_inc_withhold_2017'),
ref('hr_payroll_rules_oh_unemp_wages_2018'),
ref('hr_payroll_rules_oh_unemp_2018'),
ref('hr_payroll_rules_oh_inc_withhold_2018'),
])]" name="rule_ids"/>
<field name="company_id" ref="base.main_company"/>
<field name="parent_id" ref="l10n_us_hr_payroll.hr_payroll_salary_structure_us_employee"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR SALARY RULES-->
<record id="hr_payroll_rules_oh_unemp_wages_2016" model="hr.salary.rule">
<field name="sequence" eval="423"/>
<field name="category_id" ref="hr_payroll_oh_unemp_wages"/>
<field name="name">Ohio Unemployment - Wages (2016)</field>
<field name="code">OH_UNEMP_WAGES_2016</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2016')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
###
ytd = payslip.sum('OH_UNEMP_WAGES_2016', '2016-01-01', '2017-01-01')
ytd += contract.external_wages
remaining = 9000.0 - ytd
if remaining &lt;= 0.0:
result = 0
elif remaining &lt; categories.GROSS:
result = remaining
else:
result = categories.GROSS
</field>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_oh_unemp_2016" model="hr.salary.rule">
<field name="sequence" eval="443"/>
<field name="category_id" ref="hr_payroll_oh_unemp"/>
<field name="name">Ohio Unemployment (2016)</field>
<field name="code">OH_UNEMP_2016</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2016')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
result_rate = -contract.oh_unemp_rate(2016)
result = categories.OH_UNEMP_WAGES
# result_rate of 0 implies 100% due to bug
if result_rate == 0.0:
result = 0.0
</field>
<field name="register_id" ref="contrib_register_ohdor_unemp"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_oh_inc_withhold_2016" model="hr.salary.rule">
<field name="sequence" eval="145"/>
<field name="category_id" ref="hr_payroll_oh_income_withhold"/>
<field name="name">Ohio Income Withholding</field>
<field name="code">OH_INC_WITHHOLD_2016</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2016')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
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 http://www.tax.ohio.gov/Portals/0/employer_withholding/August2015Rates/WTH_OptionalComputerFormula_073015.pdf
TW = (wages * PP) - (650 * allowances)
if TW &lt;= 5000.0:
WD = ((TW * 0.005) / PP) * 1.112
elif TW &lt;= 10000.0:
WD = ((((TW - 5000.0) * 0.01) + 25.0) / PP) * 1.112
elif TW &lt;= 15000.0:
WD = ((((TW - 10000.0) * 0.02) + 75.0) / PP) * 1.112
elif TW &lt;= 20000.0:
WD = ((((TW - 15000.0) * 0.025) + 175.0) / PP) * 1.112
elif TW &lt;= 40000.0:
WD = ((((TW - 20000.0) * 0.03) + 300.0) / PP) * 1.112
elif TW &lt;= 80000.0:
WD = ((((TW - 40000.0) * 0.035) + 900.0) / PP) * 1.112
elif TW &lt;= 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
result = -WD
</field>
<field name="register_id" ref="contrib_register_ohdor_withhold"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR SALARY RULES-->
<record id="hr_payroll_rules_oh_unemp_wages_2017" model="hr.salary.rule">
<field name="sequence" eval="423"/>
<field name="category_id" ref="hr_payroll_oh_unemp_wages"/>
<field name="name">Ohio Unemployment - Wages (2017)</field>
<field name="code">OH_UNEMP_WAGES_2017</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2017')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
###
ytd = payslip.sum('OH_UNEMP_WAGES_2017', '2017-01-01', '2018-01-01')
ytd += contract.external_wages
remaining = 9000.0 - ytd
if remaining &lt;= 0.0:
result = 0
elif remaining &lt; categories.GROSS:
result = remaining
else:
result = categories.GROSS
</field>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_oh_unemp_2017" model="hr.salary.rule">
<field name="sequence" eval="443"/>
<field name="category_id" ref="hr_payroll_oh_unemp"/>
<field name="name">Ohio Unemployment (2017)</field>
<field name="code">OH_UNEMP_2017</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2017')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
result_rate = -contract.oh_unemp_rate(2017)
result = categories.OH_UNEMP_WAGES
# result_rate of 0 implies 100% due to bug
if result_rate == 0.0:
result = 0.0
</field>
<field name="register_id" ref="contrib_register_ohdor_unemp"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_oh_inc_withhold_2017" model="hr.salary.rule">
<field name="sequence" eval="145"/>
<field name="category_id" ref="hr_payroll_oh_income_withhold"/>
<field name="name">Ohio Income Withholding</field>
<field name="code">OH_INC_WITHHOLD_2017</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2017')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
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 http://www.tax.ohio.gov/Portals/0/employer_withholding/August2015Rates/WTH_OptionalComputerFormula_073015.pdf
TW = (wages * PP) - (650 * allowances)
if TW &lt;= 5000.0:
WD = ((TW * 0.005) / PP) * 1.112
elif TW &lt;= 10000.0:
WD = ((((TW - 5000.0) * 0.01) + 25.0) / PP) * 1.112
elif TW &lt;= 15000.0:
WD = ((((TW - 10000.0) * 0.02) + 75.0) / PP) * 1.112
elif TW &lt;= 20000.0:
WD = ((((TW - 15000.0) * 0.025) + 175.0) / PP) * 1.112
elif TW &lt;= 40000.0:
WD = ((((TW - 20000.0) * 0.03) + 300.0) / PP) * 1.112
elif TW &lt;= 80000.0:
WD = ((((TW - 40000.0) * 0.035) + 900.0) / PP) * 1.112
elif TW &lt;= 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
result = -WD
</field>
<field name="register_id" ref="contrib_register_ohdor_withhold"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR SALARY RULES-->
<record id="hr_payroll_rules_oh_unemp_wages_2018" model="hr.salary.rule">
<field name="sequence" eval="423"/>
<field name="category_id" ref="hr_payroll_oh_unemp_wages"/>
<field name="name">Ohio Unemployment - Wages (2018)</field>
<field name="code">OH_UNEMP_WAGES_2018</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2018')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
###
ytd = payslip.sum('OH_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01')
ytd += contract.external_wages
remaining = 9500.0 - ytd
if remaining &lt;= 0.0:
result = 0
elif remaining &lt; categories.GROSS:
result = remaining
else:
result = categories.GROSS
</field>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_oh_unemp_2018" model="hr.salary.rule">
<field name="sequence" eval="443"/>
<field name="category_id" ref="hr_payroll_oh_unemp"/>
<field name="name">Ohio Unemployment (2018)</field>
<field name="code">OH_UNEMP_2018</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2018')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
result_rate = -contract.oh_unemp_rate(2018)
result = categories.OH_UNEMP_WAGES
# result_rate of 0 implies 100% due to bug
if result_rate == 0.0:
result = 0.0
</field>
<field name="register_id" ref="contrib_register_ohdor_unemp"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_oh_inc_withhold_2018" model="hr.salary.rule">
<field name="sequence" eval="145"/>
<field name="category_id" ref="hr_payroll_oh_income_withhold"/>
<field name="name">Ohio Income Withholding</field>
<field name="code">OH_INC_WITHHOLD_2018</field>
<field name="condition_select">python</field>
<field name="condition_python">result = (payslip.date_to[:4] == '2018')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
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 http://www.tax.ohio.gov/Portals/0/employer_withholding/August2015Rates/WTH_OptionalComputerFormula_073015.pdf
TW = (wages * PP) - (650 * allowances)
if TW &lt;= 5000.0:
WD = ((TW * 0.005) / PP) * 1.112
elif TW &lt;= 10000.0:
WD = ((((TW - 5000.0) * 0.01) + 25.0) / PP) * 1.112
elif TW &lt;= 15000.0:
WD = ((((TW - 10000.0) * 0.02) + 75.0) / PP) * 1.112
elif TW &lt;= 20000.0:
WD = ((((TW - 15000.0) * 0.025) + 175.0) / PP) * 1.112
elif TW &lt;= 40000.0:
WD = ((((TW - 20000.0) * 0.03) + 300.0) / PP) * 1.112
elif TW &lt;= 80000.0:
WD = ((((TW - 40000.0) * 0.035) + 900.0) / PP) * 1.112
elif TW &lt;= 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
result = -WD
</field>
<field name="register_id" ref="contrib_register_ohdor_withhold"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,27 @@
from odoo import models, fields, api
class USOHHrContract(models.Model):
_inherit = 'hr.contract'
oh_income_allowances = fields.Integer(string='Ohio Income Allowances', default=0)
@api.multi
def oh_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, 'oh_unemp_rate_' + str(year)):
return self.employee_id.company_id['oh_unemp_rate_' + str(year)]
raise NotImplemented('Year (' + str(year) + ') Not implemented for US Ohio.')
class OHCompany(models.Model):
_inherit = 'res.company'
# Defaults from :: https://jfs.ohio.gov/ouc/uctax/rates.stm
oh_unemp_rate_2016 = fields.Float(string="Ohio Unemployment Rate 2016", default=2.7)
oh_unemp_rate_2017 = fields.Float(string="Ohio Unemployment Rate 2017", default=2.7)
oh_unemp_rate_2018 = fields.Float(string="Ohio Unemployment Rate 2018", default=2.7)

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="us_fl_view_company_form" model="ir.ui.view">
<field name="name">res.company.form</field>
<field name="model">res.company</field>
<field name="priority">64</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='currency_id']" position="after">
<field name="oh_unemp_rate_2016"/>
<field name="oh_unemp_rate_2017"/>
<field name="oh_unemp_rate_2018"/>
</xpath>
</data>
</field>
</record>
<record id="hr_contract_form_l10n_us_oh_inherit" model="ir.ui.view">
<field name="name">hr.contract.form.inherit</field>
<field name="model">hr.contract</field>
<field name="priority">64</field>
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='w4_filing_status']" position="before">
<field name="oh_income_allowances"/>
</xpath>
</data>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
from . import test_us_oh_payslip_2016
from . import test_us_oh_payslip_2017
from . import test_us_oh_payslip_2018

View File

@@ -0,0 +1,111 @@
# -*- coding: utf-8 -*-
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 TestUsOhPayslip(TestUsPayslip):
###
# 2016 Taxes and Rates
###
def test_2016_taxes(self):
salary = 5000.0
## tax maximums
OH_UNEMP_MAX_WAGE = 9000.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()
employee.company_id.oh_unemp_rate_2016 = 2.7
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee'))
## tax rates
OH_UNEMP = contract.oh_unemp_rate(2016) / -100.0
self._log('2016 Ohio tax first payslip:')
payslip = self._createPayslip(employee, '2016-01-01', '2016-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], salary)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * OH_UNEMP)
self.assertPayrollEqual(cats['OH_INC_WITHHOLD'], -WD)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_oh_unemp_wages = OH_UNEMP_MAX_WAGE - salary if (OH_UNEMP_MAX_WAGE - 2*salary < salary) else salary
self._log('2016 Ohio tax second payslip:')
payslip = self._createPayslip(employee, '2016-02-01', '2016-02-29') # 2016 is a leap year
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], remaining_oh_unemp_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], remaining_oh_unemp_wages * OH_UNEMP)
def test_2016_taxes_with_external(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.oh_unemp_rate_2016 = 2.8
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'))
## tax maximums
OH_UNEMP_MAX_WAGE = 9000.0
## tax rates
OH_UNEMP = contract.oh_unemp_rate(2016) / -100.0
self._log('2016 Ohio_external tax first payslip:')
payslip = self._createPayslip(employee, '2016-01-01', '2016-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], OH_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * OH_UNEMP)
def test_2016_taxes_with_state_exempt(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.oh_unemp_rate_2016 = 2.9
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)
## tax maximums
OH_UNEMP_MAX_WAGE = 9000.0
## tax rates
OH_UNEMP = contract.oh_unemp_rate(2016) / -100.0
self.assertPayrollEqual(OH_UNEMP, 0.0)
self._log('2016 Ohio exempt tax first payslip:')
payslip = self._createPayslip(employee, '2016-01-01', '2016-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], OH_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * OH_UNEMP)

View File

@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
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 TestUsOhPayslip(TestUsPayslip):
###
# Taxes and Rates
###
OH_UNEMP_MAX_WAGE = 9000.0
def test_2017_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()
employee.company_id.oh_unemp_rate_2017 = 2.7
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee'))
# tax rates
oh_unemp = contract.oh_unemp_rate(2017) / -100.0
self._log('2016 Ohio tax last payslip:')
payslip = self._createPayslip(employee, '2016-12-01', '2016-12-31')
payslip.compute_sheet()
process_payslip(payslip)
self._log('2017 Ohio tax first payslip:')
payslip = self._createPayslip(employee, '2017-01-01', '2017-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], salary)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * oh_unemp)
self.assertPayrollEqual(cats['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('2017 Ohio tax second payslip:')
payslip = self._createPayslip(employee, '2017-02-01', '2017-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], remaining_oh_unemp_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], remaining_oh_unemp_wages * oh_unemp)
def test_2017_taxes_with_external(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.oh_unemp_rate_2017 = 2.8
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'))
# tax rates
oh_unemp = contract.oh_unemp_rate(2017) / -100.0
self._log('2017 Ohio_external tax first payslip:')
payslip = self._createPayslip(employee, '2017-01-01', '2017-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], self.OH_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * oh_unemp)
def test_2017_taxes_with_state_exempt(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.oh_unemp_rate_2017 = 2.9
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)
# tax rates
oh_unemp = contract.oh_unemp_rate(2017) / -100.0
self.assertPayrollEqual(oh_unemp, 0.0)
self._log('2017 Ohio exempt tax first payslip:')
payslip = self._createPayslip(employee, '2017-01-01', '2017-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], self.OH_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * oh_unemp)

View File

@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
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 TestUsOhPayslip(TestUsPayslip):
###
# Taxes and Rates
###
OH_UNEMP_MAX_WAGE = 9500.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()
employee.company_id.oh_unemp_rate_2018 = 2.7
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_oh_hr_payroll.hr_payroll_salary_structure_us_oh_employee'))
# tax rates
oh_unemp = contract.oh_unemp_rate(2018) / -100.0
self._log('2016 Ohio tax last payslip:')
payslip = self._createPayslip(employee, '2016-12-01', '2016-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['OH_UNEMP_WAGES'], salary)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * oh_unemp)
self.assertPayrollEqual(cats['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['OH_UNEMP_WAGES'], remaining_oh_unemp_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], remaining_oh_unemp_wages * oh_unemp)
def test_2018_taxes_with_external(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.oh_unemp_rate_2018 = 2.8
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'))
# tax rates
oh_unemp = contract.oh_unemp_rate(2018) / -100.0
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['OH_UNEMP_WAGES'], self.OH_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * oh_unemp)
def test_2018_taxes_with_state_exempt(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.oh_unemp_rate_2018 = 2.9
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)
# tax rates
oh_unemp = contract.oh_unemp_rate(2018) / -100.0
self.assertPayrollEqual(oh_unemp, 0.0)
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)
self.assertPayrollEqual(cats['OH_UNEMP_WAGES'], self.OH_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['OH_UNEMP'], cats['OH_UNEMP_WAGES'] * oh_unemp)