From 9441ac01b43a3f3d273438bad49adb99dd72588d Mon Sep 17 00:00:00 2001
From: Bhoomi Vaishnani
Date: Fri, 15 May 2020 09:59:18 -0400
Subject: [PATCH] [IMP] l10n_us_hr_payroll: For Kansas 13.0
---
l10n_us_hr_payroll/__manifest__.py | 1 +
l10n_us_hr_payroll/data/state/ks_kansas.xml | 133 ++++++++++++++++++
l10n_us_hr_payroll/models/hr_payslip.py | 2 +
l10n_us_hr_payroll/models/state/ks_kansas.py | 44 ++++++
.../models/us_payroll_config.py | 7 +
l10n_us_hr_payroll/tests/__init__.py | 2 +
.../tests/test_us_ks_kansas_payslip_2020.py | 35 +++++
.../views/us_payroll_config_views.xml | 7 +
8 files changed, 231 insertions(+)
create mode 100644 l10n_us_hr_payroll/data/state/ks_kansas.xml
create mode 100644 l10n_us_hr_payroll/models/state/ks_kansas.py
create mode 100755 l10n_us_hr_payroll/tests/test_us_ks_kansas_payslip_2020.py
diff --git a/l10n_us_hr_payroll/__manifest__.py b/l10n_us_hr_payroll/__manifest__.py
index 76b404b8..27d836ba 100644
--- a/l10n_us_hr_payroll/__manifest__.py
+++ b/l10n_us_hr_payroll/__manifest__.py
@@ -40,6 +40,7 @@ United States of America - Payroll Rules.
'data/state/id_idaho.xml',
'data/state/il_illinois.xml',
'data/state/in_indiana.xml',
+ 'data/state/ks_kansas.xml',
'data/state/la_louisiana.xml',
'data/state/me_maine.xml',
'data/state/mi_michigan.xml',
diff --git a/l10n_us_hr_payroll/data/state/ks_kansas.xml b/l10n_us_hr_payroll/data/state/ks_kansas.xml
new file mode 100644
index 00000000..539d9490
--- /dev/null
+++ b/l10n_us_hr_payroll/data/state/ks_kansas.xml
@@ -0,0 +1,133 @@
+
+
+
+
+ US KS Kasas SUTA Wage Base
+ us_ks_suta_wage_base
+
+
+
+
+ 14000.0
+
+
+
+
+
+
+
+ US KS Kasas SUTA Rate
+ us_ks_suta_rate
+
+
+
+
+ 2.7
+
+
+
+
+
+
+ US KS Kansas Allowances Rate
+ us_ks_sit_allowances_rate
+
+
+
+
+ {
+ 'weekly' : 43.27,
+ 'bi-weekly' : 86.54,
+ 'semi-monthly': 93.75,
+ 'monthly' : 187.50,
+ 'quarterly' : 562.50,
+ 'semi-annual': 1125.00,
+ 'annually': 2250.00,
+ }
+
+
+
+
+
+
+ US KS Kasas SIT Tax Rate
+ us_ks_sit_tax_rate
+
+
+
+
+ {
+ 'single': {
+ 'weekly': ((58, 0.00, 0.00), (346, 3.10, 0.00), (635, 5.25, 8.94), ('inf', 5.70, 24.09)),
+ 'bi-weekly': ((115, 0.00, 0.00), (692, 3.10, 0.00), (1269, 5.25, 17.88), ('inf', 5.70, 48.17)),
+ 'semi-monthly': ((125, 0.00, 0.00), (750, 3.10, 0.00), (1375, 5.25, 19.38), ('inf', 5.70, 52.19)),
+ 'monthly': ((250, 0.00, 0.00), (1500, 3.10, 0.00), (2750, 5.25, 38.75), ('inf', 5.70, 104.38)),
+ 'quarterly': ((750, 0.00, 0.00), (4500, 3.10, 0.00), (8250, 5.25, 116.25), ('inf', 5.70, 313.13)),
+ 'semi-annual': ((1500, 0.00, 0.00), (9000, 3.10, 0.00), (16500, 5.25, 232.50), ('inf', 5.70, 626.25)),
+ 'annually': ((3000, 0.00, 0.00), (18000, 3.10, 0.00), (33000, 5.25, 465.00), ('inf', 5.70, 1252.50)),
+ },
+ 'married': {
+ 'weekly': ((144, 0.00, 0.00), (721, 3.10, 0.00), (1298, 5.25, 17.88), ('inf', 5.70, 48.17)),
+ 'bi-weekly': ((288, 0.00, 0.00), (1442, 3.10, 0.00), (2596, 5.25, 35.77), ('inf', 5.70, 96.35)),
+ 'semi-monthly': ((313, 0.00, 0.00), (1563, 3.10, 0.00), (2813, 5.25, 38.75), ('inf', 5.70, 104.38)),
+ 'monthly': ((625, 0.00, 0.00), (3125, 3.10, 0.00), (5625, 5.25, 77.50), ('inf', 5.70, 208.75)),
+ 'quarterly': ((1875, 0.00, 0.00), (9375, 3.10, 0.00), (16875, 5.25, 232.50), ('inf', 5.70, 626.25)),
+ 'semi-annual': ((3750, 0.00, 0.00), (18750, 3.10, 0.00), (33750, 5.25, 465.00), ('inf', 5.70, 1252.50)),
+ 'annually': ((7500, 0.00, 0.00), (37500, 3.10, 0.00), (67500, 5.25, 930.00), ('inf', 5.70, 2505.00)),
+ },
+ 'head_household': {
+ 'weekly': ((58, 0.00, 0.00), (346, 3.10, 0.00), (635, 5.25, 8.94), ('inf', 5.70, 24.09)),
+ 'bi-weekly': ((115, 0.00, 0.00), (692, 3.10, 0.00), (1269, 5.25, 17.88), ('inf', 5.70, 48.17)),
+ 'semi-monthly': ((125, 0.00, 0.00), (750, 3.10, 0.00), (1375, 5.25, 19.38), ('inf', 5.70, 52.19)),
+ 'monthly': ((250, 0.00, 0.00), (1500, 3.10, 0.00), (2750, 5.25, 38.75), ('inf', 5.70, 104.38)),
+ 'quarterly': ((750, 0.00, 0.00), (4500, 3.10, 0.00), (8250, 5.25, 116.25), ('inf', 5.70, 313.13)),
+ 'semi-annual': ((1500, 0.00, 0.00), (9000, 3.10, 0.00), (16500, 5.25, 232.50), ('inf', 5.70, 626.25)),
+ 'annually': ((3000, 0.00, 0.00), (18000, 3.10, 0.00), (33000, 5.25, 465.00), ('inf', 5.70, 1252.50)),
+ },
+ }
+
+
+
+
+
+
+
+ US Kansas - Department of Labor - Unemployment Tax
+
+
+
+ US Kansas - Department of Revenue - Income Tax
+
+
+
+
+
+
+
+
+
+ ER: US KS Kasas State Unemployment
+ ER_US_KS_SUTA
+ python
+ result, _ = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_ks_suta_wage_base', rate='us_ks_suta_rate', state_code='KS')
+ code
+ result, result_rate = general_state_unemployment(payslip, categories, worked_days, inputs, wage_base='us_ks_suta_wage_base', rate='us_ks_suta_rate', state_code='KS')
+
+
+
+
+
+
+
+
+ EE: US KS Kasas State Income Tax Withholding
+ EE_US_KS_SIT
+ python
+ result, _ = ks_kansas_state_income_withholding(payslip, categories, worked_days, inputs)
+ code
+ result, result_rate = ks_kansas_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 47156de9..aff10e65 100644
--- a/l10n_us_hr_payroll/models/hr_payslip.py
+++ b/l10n_us_hr_payroll/models/hr_payslip.py
@@ -25,6 +25,7 @@ from .state.ia_iowa import ia_iowa_state_income_withholding
from .state.id_idaho import id_idaho_state_income_withholding
from .state.il_illinois import il_illinois_state_income_withholding
from .state.in_indiana import in_indiana_state_income_withholding
+from .state.ks_kansas import ks_kansas_state_income_withholding
from .state.la_louisiana import la_louisiana_state_income_withholding
from .state.me_maine import me_maine_state_income_withholding
from .state.mi_michigan import mi_michigan_state_income_withholding
@@ -87,6 +88,7 @@ class HRPayslip(models.Model):
'id_idaho_state_income_withholding': id_idaho_state_income_withholding,
'il_illinois_state_income_withholding': il_illinois_state_income_withholding,
'in_indiana_state_income_withholding': in_indiana_state_income_withholding,
+ 'ks_kansas_state_income_withholding': ks_kansas_state_income_withholding,
'la_louisiana_state_income_withholding': la_louisiana_state_income_withholding,
'me_maine_state_income_withholding': me_maine_state_income_withholding,
'mi_michigan_state_income_withholding': mi_michigan_state_income_withholding,
diff --git a/l10n_us_hr_payroll/models/state/ks_kansas.py b/l10n_us_hr_payroll/models/state/ks_kansas.py
new file mode 100644
index 00000000..1e7398d0
--- /dev/null
+++ b/l10n_us_hr_payroll/models/state/ks_kansas.py
@@ -0,0 +1,44 @@
+# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
+
+from .general import _state_applies, sit_wage
+
+
+def ks_kansas_state_income_withholding(payslip, categories, worked_days, inputs):
+ """
+ Returns SIT eligible wage and rate.
+
+ :return: result, result_rate (wage, percent)
+ """
+ state_code = 'KS'
+ 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
+
+ filing_status = payslip.contract_id.us_payroll_config_value('ks_k4_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('ks_k4_sit_allowances')
+ allowances_amt = payslip.rule_parameter('us_ks_sit_allowances_rate')[schedule_pay]
+ tax_table = payslip.rule_parameter('us_ks_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 152ea877..e4552626 100644
--- a/l10n_us_hr_payroll/models/us_payroll_config.py
+++ b/l10n_us_hr_payroll/models/us_payroll_config.py
@@ -127,6 +127,13 @@ class HRContractUSPayrollConfig(models.Model):
in_w4_sit_personal_exemption = fields.Integer(string='Indiana In-W-4 Number of Personal Exemption', help='IN-W-4 5.')
in_w4_sit_dependent_exemption = fields.Integer(string='Indiana In-W-4 Number of Dependent Exemption', help='IN-W-4 6.')
+ ks_k4_sit_filing_status = fields.Selection([
+ ('single', 'Single'),
+ ('married', 'Married'),
+ ('head of household', 'Head of Household'),
+ ], string='Kansas K-4 Filing Status', help='KS K-4 3.')
+ ks_k4_sit_allowances = fields.Integer(string='Kansas KS K-4 Number of Allowances', help='KS K-4 Step 4.')
+
la_l4_sit_filing_status = fields.Selection([
('single', 'Single'),
('married', 'Married'),
diff --git a/l10n_us_hr_payroll/tests/__init__.py b/l10n_us_hr_payroll/tests/__init__.py
index 72a7b5d5..24359a1e 100755
--- a/l10n_us_hr_payroll/tests/__init__.py
+++ b/l10n_us_hr_payroll/tests/__init__.py
@@ -46,6 +46,8 @@ from . import test_us_il_illinois_payslip_2020
from . import test_us_in_indiana_payslip_2020
+from . import test_us_ks_kansas_payslip_2020
+
from . import test_us_la_louisiana_payslip_2019
from . import test_us_la_louisiana_payslip_2020
diff --git a/l10n_us_hr_payroll/tests/test_us_ks_kansas_payslip_2020.py b/l10n_us_hr_payroll/tests/test_us_ks_kansas_payslip_2020.py
new file mode 100755
index 00000000..61416613
--- /dev/null
+++ b/l10n_us_hr_payroll/tests/test_us_ks_kansas_payslip_2020.py
@@ -0,0 +1,35 @@
+# 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 TestUsKSPayslip(TestUsPayslip):
+ ###
+ # 2020 Taxes and Rates
+ ###
+ KS_UNEMP_MAX_WAGE = 14000.0
+ KS_UNEMP = 2.7
+ # Calculation based on example https://revenue.ky.gov/Forms/42A003(T)%20(12-2019)%202020%20Tax%20Tables.pdf
+
+ def _test_sit(self, wage, filing_status, allowances, additional_withholding, schedule_pay, date_start, expected_withholding):
+ employee = self._createEmployee()
+ contract = self._createContract(employee,
+ wage=wage,
+ state_id=self.get_us_state('KS'),
+ ks_k4_sit_filing_status=filing_status,
+ ks_k4_sit_allowances=allowances,
+ state_income_tax_additional_withholding=additional_withholding,
+ 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('KS', self.KS_UNEMP, date(2020, 1, 1), wage_base=self.KS_UNEMP_MAX_WAGE)
+ self._test_sit(625, 'married', 2, 0, 'semi-monthly', date(2020, 1, 1), 4.00)
+ # self._test_sit(1500, 'single', 0, 0, 'bi-weekly', date(2020, 1, 1), 69.90)
+ # self._test_sit(1500, 'single', 0, 0, 'bi-weekly', date(2020, 1, 1), 79.90)
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 fdd49599..56ef6921 100644
--- a/l10n_us_hr_payroll/views/us_payroll_config_views.xml
+++ b/l10n_us_hr_payroll/views/us_payroll_config_views.xml
@@ -125,6 +125,13 @@
+
+ Form KS K-4 - State Income Tax
+
+
+
+
+
Form LA L-4 - State Income Tax