diff --git a/l10n_us_hr_payroll/__manifest__.py b/l10n_us_hr_payroll/__manifest__.py
index fcbe1dad..d18c9903 100644
--- a/l10n_us_hr_payroll/__manifest__.py
+++ b/l10n_us_hr_payroll/__manifest__.py
@@ -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',
diff --git a/l10n_us_hr_payroll/data/state/ok_oklahoma.xml b/l10n_us_hr_payroll/data/state/ok_oklahoma.xml
new file mode 100644
index 00000000..f4ec8269
--- /dev/null
+++ b/l10n_us_hr_payroll/data/state/ok_oklahoma.xml
@@ -0,0 +1,133 @@
+
+
+
+
+ US OK Oklahoma SUTA Wage Base
+ us_ok_suta_wage_base
+
+
+
+
+ 18700.0
+
+
+
+
+
+
+
+ US OK Oklahoma SUTA Rate
+ us_ok_suta_rate
+
+
+
+
+ 1.5
+
+
+
+
+
+
+ US OK Oklahoma Allowances Rate
+ us_ok_sit_allowances_rate
+
+
+
+
+ {
+ 'weekly' : 19.23,
+ 'bi-weekly' : 38.46,
+ 'semi-monthly': 41.67,
+ 'monthly' : 83.33,
+ 'quarterly' : 250.00,
+ 'semi-annual': 500.00,
+ 'annually': 1000.00,
+ }
+
+
+
+
+
+
+ US OK Oklahoma SIT Tax Rate
+ us_ok_sit_tax_rate
+
+
+
+
+ {
+ '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)),
+ },
+ }
+
+
+
+
+
+
+
+ US Oklahoma - Employment Security Commission - Unemployment Tax
+
+
+
+ US Oklahoma - Tax Commission - Income Tax
+
+
+
+
+
+
+
+
+
+ ER: US OK Oklahoma State Unemployment
+ ER_US_OK_SUTA
+ 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')
+ code
+ 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')
+
+
+
+
+
+
+
+
+ EE: US OK Oklahoma State Income Tax Withholding
+ EE_US_OK_SIT
+ python
+ result, _ = ok_oklahoma_state_income_withholding(payslip, categories, worked_days, inputs)
+ code
+ result, result_rate = ok_oklahoma_state_income_withholding(payslip, categories, worked_days, inputs)
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n_us_hr_payroll/models/hr_payslip.py b/l10n_us_hr_payroll/models/hr_payslip.py
index 9b68835a..13e92312 100644
--- a/l10n_us_hr_payroll/models/hr_payslip.py
+++ b/l10n_us_hr_payroll/models/hr_payslip.py
@@ -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,
diff --git a/l10n_us_hr_payroll/models/state/ok_oklahoma.py b/l10n_us_hr_payroll/models/state/ok_oklahoma.py
new file mode 100644
index 00000000..bc0ecc24
--- /dev/null
+++ b/l10n_us_hr_payroll/models/state/ok_oklahoma.py
@@ -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)
diff --git a/l10n_us_hr_payroll/models/us_payroll_config.py b/l10n_us_hr_payroll/models/us_payroll_config.py
index e4552626..d50f4040 100644
--- a/l10n_us_hr_payroll/models/us_payroll_config.py
+++ b/l10n_us_hr_payroll/models/us_payroll_config.py
@@ -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',
diff --git a/l10n_us_hr_payroll/tests/__init__.py b/l10n_us_hr_payroll/tests/__init__.py
index 43afe830..cc2bfff6 100755
--- a/l10n_us_hr_payroll/tests/__init__.py
+++ b/l10n_us_hr_payroll/tests/__init__.py
@@ -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
diff --git a/l10n_us_hr_payroll/tests/test_us_ok_oklahoma_payslip_2020.py b/l10n_us_hr_payroll/tests/test_us_ok_oklahoma_payslip_2020.py
new file mode 100755
index 00000000..03297065
--- /dev/null
+++ b/l10n_us_hr_payroll/tests/test_us_ok_oklahoma_payslip_2020.py
@@ -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)
diff --git a/l10n_us_hr_payroll/views/us_payroll_config_views.xml b/l10n_us_hr_payroll/views/us_payroll_config_views.xml
index e844905d..eae427c3 100644
--- a/l10n_us_hr_payroll/views/us_payroll_config_views.xml
+++ b/l10n_us_hr_payroll/views/us_payroll_config_views.xml
@@ -226,6 +226,13 @@
+
+ Form OK-W-4 - State Income Tax
+
+
+
+
+