[IMP] l10n_us_hr_payroll: For Oklahoma 13.0

This commit is contained in:
Bhoomi Vaishnani
2020-05-18 11:23:03 -04:00
parent 0f004c6f15
commit a7fc00b0f3
8 changed files with 236 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ United States of America - Payroll Rules.
'data/state/nv_nevada.xml',
'data/state/ny_new_york.xml',
'data/state/oh_ohio.xml',
'data/state/ok_oklahoma.xml',
'data/state/pa_pennsylvania.xml',
'data/state/sc_south_carolina.xml',
'data/state/tx_texas.xml',

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Wage Base -->
<record id="rule_parameter_us_ok_suta_wage_base" model="hr.rule.parameter">
<field name="name">US OK Oklahoma SUTA Wage Base</field>
<field name="code">us_ok_suta_wage_base</field>
<field name="country_id" ref="base.us"/>
</record>
<data noupdate="1">
<record id="rule_parameter_us_ok_suta_wage_base_2020" model="hr.rule.parameter.value">
<field name="parameter_value">18700.0</field>
<field name="rule_parameter_id" ref="rule_parameter_us_ok_suta_wage_base"/>
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
</record>
</data>
<!-- Rate -->
<record id="rule_parameter_us_ok_suta_rate" model="hr.rule.parameter">
<field name="name">US OK Oklahoma SUTA Rate</field>
<field name="code">us_ok_suta_rate</field>
<field name="country_id" ref="base.us"/>
</record>
<data noupdate="1">
<record id="rule_parameter_us_ok_suta_rate_2020" model="hr.rule.parameter.value">
<field name="parameter_value">1.5</field>
<field name="rule_parameter_id" ref="rule_parameter_us_ok_suta_rate"/>
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
</record>
</data>
<record id="rule_parameter_us_ok_sit_allowances_rate" model="hr.rule.parameter">
<field name="name">US OK Oklahoma Allowances Rate</field>
<field name="code">us_ok_sit_allowances_rate</field>
<field name="country_id" ref="base.us"/>
</record>
<data noupdate="1">
<record id="rule_parameter_us_ok_sit_allowances_rate_2020" model="hr.rule.parameter.value">
<field name="parameter_value">{
'weekly' : 19.23,
'bi-weekly' : 38.46,
'semi-monthly': 41.67,
'monthly' : 83.33,
'quarterly' : 250.00,
'semi-annual': 500.00,
'annually': 1000.00,
}</field>
<field name="rule_parameter_id" ref="rule_parameter_us_ok_sit_allowances_rate"/>
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
</record>
</data>
<record id="rule_parameter_us_ok_sit_tax_rate" model="hr.rule.parameter">
<field name="name">US OK Oklahoma SIT Tax Rate</field>
<field name="code">us_ok_sit_tax_rate</field>
<field name="country_id" ref="base.us"/>
</record>
<data noupdate="1">
<record id="rule_parameter_us_ok_sit_tax_rate_2020" model="hr.rule.parameter.value">
<field name="parameter_value">{
'single': {
'weekly': ((122, 0.00, 0.00), (141, 0.50, 0.00), (170, 1.00, 0.10), (194, 2.00, 0.38), (216, 3.00, 0.87), (261, 4.00, 1.53), ('inf', 5.00, 3.30)),
'bi-weekly': ((244, 0.00, 0.00), (283, 0.50, 0.00), (340, 1.00, 0.19), (388, 2.00, 0.77), (433, 3.00, 1.73), (521, 4.00, 3.06), ('inf', 5.00, 6.60)),
'semi-monthly': ((265, 0.00, 0.00), (306, 0.50, 0.00), (369, 1.00, 0.21), (421, 2.00, 0.83), (469, 3.00, 1.88), (565, 4.00, 3.31), ('inf', 5.00, 7.15)),
'monthly': ((529, 0.00, 0.00), (613, 0.50, 0.00), (738, 1.00, 0.42), (842, 2.00, 1.67), (938, 3.00, 3.75), (1129, 4.00, 6.63), ('inf', 5.00, 14.29)),
'quarterly': ((1588, 0.00, 0.00), (1838, 0.50, 0.00), (2213, 1.00, 1.25), (2525, 2.00, 5.00), (2813, 3.00, 11.25), (3388, 4.00, 19.88), ('inf', 5.00, 42.88)),
'semi-annual': ((3175, 0.00, 0.00), (3675, 0.50, 0.00), (4425, 1.00, 2.50), (5050, 2.00, 10.00), (5625, 3.00, 22.50), (6775, 4.00, 39.75), ('inf', 5.00, 85.75)),
'annually': ((6350, 0.00, 0.00), (7350, 0.50, 0.00), (8850, 1.00, 5.00), (10100, 2.00, 20.00), (11250, 3.00, 45.00), (13550, 4.00, 79.50), ('inf', 5.00, 171.50)),
},
'married': {
'weekly': ((244, 0.00, 0.00), (283, 0.50, 0.00), (340, 1.00, 0.19), (388, 2.00, 0.77), (433, 3.00, 1.73), (479, 4.00, 3.06), ('inf', 5.00, 4.90)),
'bi-weekly': ((488, 0.00, 0.00), (565, 0.50, 0.00), (681, 1.00, 0.38), (777, 2.00, 1.54), (865, 3.00, 3.46), (958, 4.00, 6.12), ('inf', 5.00, 9.81)),
'semi-monthly': ((529, 0.00, 0.00), (613, 0.50, 0.00), (738, 1.00, 0.42), (842, 2.00, 1.67), (938, 3.00, 3.75), (1038, 4.00, 6.63), ('inf', 5.00, 10.63)),
'monthly': ((1058, 0.00, 0.00), (1225, 0.50, 0.00), (1475, 1.00, 0.83), (1683, 2.00, 3.33), (1875, 3.00, 7.50), (2075, 4.00, 13.25), ('inf', 5.00, 21.25)),
'quarterly': ((3175, 0.00, 0.00), (3675, 0.50, 0.00), (4425, 1.00, 2.50), (5050, 2.00, 10.00), (5625, 3.00, 22.50), (6225, 4.00, 39.75), ('inf', 5.00, 63.75)),
'semi-annual': ((6350, 0.00, 0.00), (7350, 0.50, 0.00), (8850, 1.00, 5.00), (10100, 2.00, 20.00), (11250, 3.00, 45.00), (12450, 4.00, 79.50), ('inf', 5.00, 127.50)),
'annually': ((12700, 0.00, 0.00), (14700, 0.50, 0.00), (17700, 1.00, 10.00), (20200, 2.00, 40.00), (22500, 3.00, 90.00), (24900, 4.00, 159.00), ('inf', 5.00, 255.00)),
},
'head_household': {
'weekly': ((122, 0.00, 0.00), (141, 0.50, 0.00), (170, 1.00, 0.10), (194, 2.00, 0.38), (216, 3.00, 0.87), (261, 4.00, 1.53), ('inf', 5.00, 3.30)),
'bi-weekly': ((244, 0.00, 0.00), (283, 0.50, 0.00), (340, 1.00, 0.19), (388, 2.00, 0.77), (433, 3.00, 1.73), (521, 4.00, 3.06), ('inf', 5.00, 6.60)),
'semi-monthly': ((265, 0.00, 0.00), (306, 0.50, 0.00), (369, 1.00, 0.21), (421, 2.00, 0.83), (469, 3.00, 1.88), (565, 4.00, 3.31), ('inf', 5.00, 7.15)),
'monthly': ((529, 0.00, 0.00), (613, 0.50, 0.00), (738, 1.00, 0.42), (842, 2.00, 1.67), (938, 3.00, 3.75), (1129, 4.00, 6.63), ('inf', 5.00, 14.29)),
'quarterly': ((1588, 0.00, 0.00), (1838, 0.50, 0.00), (2213, 1.00, 1.25), (2525, 2.00, 5.00), (2813, 3.00, 11.25), (3388, 4.00, 19.88), ('inf', 5.00, 42.88)),
'semi-annual': ((3175, 0.00, 0.00), (3675, 0.50, 0.00), (4425, 1.00, 2.50), (5050, 2.00, 10.00), (5625, 3.00, 22.50), (6775, 4.00, 39.75), ('inf', 5.00, 85.75)),
'annually': ((6350, 0.00, 0.00), (7350, 0.50, 0.00), (8850, 1.00, 5.00), (10100, 2.00, 20.00), (11250, 3.00, 45.00), (13550, 4.00, 79.50), ('inf', 5.00, 171.50)),
},
}</field>
<field name="rule_parameter_id" ref="rule_parameter_us_ok_sit_tax_rate"/>
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
</record>
</data>
<!-- Partners and Contribution Registers -->
<record id="res_partner_us_ok_dor" model="res.partner">
<field name="name">US Oklahoma - Employment Security Commission - Unemployment Tax</field>
</record>
<record id="res_partner_us_ok_dor_sit" model="res.partner">
<field name="name">US Oklahoma - Tax Commission - Income Tax</field>
</record>
<!-- Categories -->
<!-- Rules -->
<record id="hr_payroll_rule_er_us_ok_suta" model="hr.salary.rule">
<field name="sequence" eval="450"/>
<field name="struct_id" ref="hr_payroll_structure"/>
<field name="category_id" ref="hr_payroll_category_er_us_suta"/>
<field name="name">ER: US OK Oklahoma State Unemployment</field>
<field name="code">ER_US_OK_SUTA</field>
<field name="condition_select">python</field>
<field name="condition_python">result, _ = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_ok_suta_wage_base', rate='us_ok_suta_rate', state_code='OK')</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result, result_rate = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_ok_suta_wage_base', rate='us_ok_suta_rate', state_code='OK')</field>
<field name="partner_id" ref="res_partner_us_ok_dor"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rule_ee_us_ok_sit" model="hr.salary.rule">
<field name="sequence" eval="195"/>
<field name="struct_id" ref="hr_payroll_structure"/>
<field name="category_id" ref="hr_payroll_category_ee_us_sit"/>
<field name="name">EE: US OK Oklahoma State Income Tax Withholding</field>
<field name="code">EE_US_OK_SIT</field>
<field name="condition_select">python</field>
<field name="condition_python">result, _ = ok_oklahoma_state_income_withholding(payslip, categories, worked_days, inputs)</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">result, result_rate = ok_oklahoma_state_income_withholding(payslip, categories, worked_days, inputs)</field>
<field name="partner_id" ref="res_partner_us_ok_dor_sit"/>
<field name="appears_on_payslip" eval="True"/>
</record>
</odoo>

View File

@@ -41,6 +41,7 @@ from .state.nj_newjersey import nj_newjersey_state_income_withholding
from .state.nm_new_mexico import nm_new_mexico_state_income_withholding
from .state.ny_new_york import ny_new_york_state_income_withholding
from .state.oh_ohio import oh_ohio_state_income_withholding
from .state.ok_oklahoma import ok_oklahoma_state_income_withholding
from .state.sc_south_carolina import sc_south_carolina_state_income_withholding
from .state.va_virginia import va_virginia_state_income_withholding
from .state.wa_washington import wa_washington_fml_er, \
@@ -105,6 +106,7 @@ class HRPayslip(models.Model):
'nm_new_mexico_state_income_withholding': nm_new_mexico_state_income_withholding,
'ny_new_york_state_income_withholding': ny_new_york_state_income_withholding,
'oh_ohio_state_income_withholding': oh_ohio_state_income_withholding,
'ok_oklahoma_state_income_withholding': ok_oklahoma_state_income_withholding,
'sc_south_carolina_state_income_withholding': sc_south_carolina_state_income_withholding,
'va_virginia_state_income_withholding': va_virginia_state_income_withholding,
'wa_washington_fml_er': wa_washington_fml_er,

View File

@@ -0,0 +1,47 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from .general import _state_applies, sit_wage
def ok_oklahoma_state_income_withholding(payslip, categories, worked_days, inputs):
"""
Returns SIT eligible wage and rate.
:return: result, result_rate (wage, percent)
"""
state_code = 'OK'
if not _state_applies(payslip, state_code):
return 0.0, 0.0
# Determine Wage
wage = sit_wage(payslip, categories)
if not wage:
return 0.0, 0.0
if payslip.contract_id.us_payroll_config_value('state_income_tax_exempt'):
return 0.0, 0.0
filing_status = payslip.contract_id.us_payroll_config_value('ok_w4_sit_filing_status')
if not filing_status:
return 0.0, 0.0
schedule_pay = payslip.contract_id.schedule_pay
additional = payslip.contract_id.us_payroll_config_value('state_income_tax_additional_withholding')
allowances = payslip.contract_id.us_payroll_config_value('ok_w4_sit_allowances')
allowances_amt = payslip.rule_parameter('us_ok_sit_allowances_rate')[schedule_pay]
tax_table = payslip.rule_parameter('us_ok_sit_tax_rate')[filing_status].get(schedule_pay)
taxable_income = wage - (allowances * allowances_amt)
withholding = 0.0
last = 0.0
for row in tax_table:
amt, rate, flat_fee = row
if wage <= float(amt):
withholding = ((taxable_income - last) * (rate / 100)) + flat_fee
break
last = amt
withholding = max(withholding, 0.0)
withholding += additional
withholding = round(withholding)
return wage, -((withholding / wage) * 100.0)

View File

@@ -235,6 +235,13 @@ class HRContractUSPayrollConfig(models.Model):
# Ohio will use generic SIT exempt and additional fields
oh_it4_sit_exemptions = fields.Integer(string='Ohio IT-4 Exemptions',
help='Line 4')
ok_w4_sit_filing_status = fields.Selection([
('single', 'Single'),
('married', 'Married'),
('head_household', 'Head of Household')
], string='Oklahoma OK-W-4 Filing Status', help='OK-W-4')
ok_w4_sit_allowances = fields.Integer(string='Oklahoma OK-W-4 Allowances', help='OK-W-4 1.2.3.')
sc_w4_sit_allowances = fields.Integer(string='South Carolina SC W-4 Allowances', help='SC W-4 5.')
va_va4_sit_exemptions = fields.Integer(string='Virginia VA-4(P) Personal Exemptions',

View File

@@ -92,6 +92,8 @@ from . import test_us_ny_new_york_payslip_2020
from . import test_us_oh_ohio_payslip_2019
from . import test_us_oh_ohio_payslip_2020
from . import test_us_ok_oklahoma_payslip_2020
from . import test_us_pa_pennsylvania_payslip_2019
from . import test_us_pa_pennsylvania_payslip_2020

View File

@@ -0,0 +1,37 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from datetime import date, timedelta
from .common import TestUsPayslip
class TestUsOKPayslip(TestUsPayslip):
###
# 2020 Taxes and Rates
###
OK_UNEMP_MAX_WAGE = 18700.0
OK_UNEMP = 1.5
# Calculation based on example https://www.ok.gov/tax/documents/2020WHTables.pdf
def _test_sit(self, wage, filing_status, allowances, additional_withholding, exempt, schedule_pay, date_start, expected_withholding):
employee = self._createEmployee()
contract = self._createContract(employee,
wage=wage,
state_id=self.get_us_state('OK'),
ok_w4_sit_filing_status=filing_status,
ok_w4_sit_allowances=allowances,
state_income_tax_additional_withholding=additional_withholding,
state_income_tax_exempt=exempt,
schedule_pay=schedule_pay)
payslip = self._createPayslip(employee, date_start, date_start + timedelta(days=7))
payslip.compute_sheet()
cats = self._getCategories(payslip)
self._log('Computed period tax: ' + str(expected_withholding))
self.assertPayrollEqual(cats.get('EE_US_SIT', 0.0), -expected_withholding)
def test_2020_taxes_example(self):
self._test_er_suta('OK', self.OK_UNEMP, date(2020, 1, 1), wage_base=self.OK_UNEMP_MAX_WAGE)
self._test_sit(1825, 'married', 2, 0, False, 'semi-monthly', date(2020, 1, 1), 46.00)
self._test_sit(1825, 'married', 2, 0, True, 'monthly', date(2020, 1, 1), 0.00)
self._test_sit(1000, 'single', 1, 0, False, 'weekly', date(2020, 1, 1), 39.00)
self._test_sit(1000, 'single', 1, 10, False, 'weekly', date(2020, 1, 1), 49.00)

View File

@@ -226,6 +226,13 @@
<field name="oh_it4_sit_exemptions" string="Exemptions"/>
<field name="state_income_tax_additional_withholding" string="Additional Withholding (Line 5)"/>
</group>
<group name="state_ok_oklahoma" string="OK Oklahoma" attrs="{'invisible':[('state_id', '!=', %(base.state_us_31)s)]}">
<p colspan="2"><h3>Form OK-W-4 - State Income Tax</h3></p>
<field name="ok_w4_sit_filing_status" string="Filing Status"/>
<field name="ok_w4_sit_allowances" string="Allowances 1.2.3."/>
<field name="state_income_tax_additional_withholding" string="Additional Withholding 6."/>
<field name="state_income_tax_exempt" string="Exempt 7."/>
</group>
<group name="state_pa_pennsylvania" string="PA Pennsylvania" attrs="{'invisible':[('state_id', '!=', %(base.state_us_39)s)]}">
<field name="state_income_tax_exempt"/>
<field name="state_income_tax_additional_withholding"/>