mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of l10n_us_ks_hr_payroll for 11.0.
This commit is contained in:
1
l10n_us_ks_hr_payroll/__init__.py
Executable file
1
l10n_us_ks_hr_payroll/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import us_ks_hr_payroll
|
||||
26
l10n_us_ks_hr_payroll/__manifest__.py
Executable file
26
l10n_us_ks_hr_payroll/__manifest__.py
Executable file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
'name': 'USA - Kansas - Payroll',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Localization',
|
||||
'depends': ['l10n_us_hr_payroll'],
|
||||
'version': '11.0.2018.0.0',
|
||||
'description': """
|
||||
USA::Kansas Payroll Rules.
|
||||
===========================
|
||||
|
||||
* Kansas Department of Revenue partner
|
||||
* Contribution register for Kansas DoR
|
||||
* Company level Kansas Unemployment Rate
|
||||
""",
|
||||
|
||||
'auto_install': False,
|
||||
'website': 'https://hibou.io/',
|
||||
'data':[
|
||||
'us_ks_hr_payroll_view.xml',
|
||||
'data/base.xml',
|
||||
'data/rules_2018.xml',
|
||||
'data/final.xml',
|
||||
],
|
||||
'installable': True
|
||||
}
|
||||
48
l10n_us_ks_hr_payroll/data/base.xml
Executable file
48
l10n_us_ks_hr_payroll/data/base.xml
Executable file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- CONTRIBUTION REGISTERS -->
|
||||
<record id="res_partner_ksdor_unemp" model="res.partner">
|
||||
<field name="name">Kansas Department of Revenue - Unemployment Insurance Tax</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
<record id="res_partner_ksdor_withhold" model="res.partner">
|
||||
<field name="name">Kansas Department of Revenue - Income Tax Withholding</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
|
||||
<record id="contrib_register_ksdor_unemp" model="hr.contribution.register">
|
||||
<field name="name">Kansas Unemployment Insurance Tax</field>
|
||||
<field name="note">Kansas Department of Revenue - Unemployment Insurance Tax</field>
|
||||
<field name="partner_id" ref="res_partner_ksdor_unemp"/>
|
||||
</record>
|
||||
<record id="contrib_register_ksdor_withhold" model="hr.contribution.register">
|
||||
<field name="name">Kansas Income Tax Withholding</field>
|
||||
<field name="note">Kansas Department of Revenue - Income Tax Withholding</field>
|
||||
<field name="partner_id" ref="res_partner_ksdor_withhold"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- HR SALARY RULE CATEGORIES-->
|
||||
<record id="hr_payroll_ks_unemp_wages" model="hr.salary.rule.category">
|
||||
<field name="name">Kansas Unemployment Insurance Tax - Wages</field>
|
||||
<field name="code">KS_UNEMP_WAGES</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_ks_unemp" model="hr.salary.rule.category">
|
||||
<field name="name">Kansas Unemployment Insurance Tax</field>
|
||||
<field name="code">KS_UNEMP</field>
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_ks_income_withhold" model="hr.salary.rule.category">
|
||||
<field name="name">Kansas Income Withholding</field>
|
||||
<field name="code">KS_WITHHOLD</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
19
l10n_us_ks_hr_payroll/data/final.xml
Executable file
19
l10n_us_ks_hr_payroll/data/final.xml
Executable file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR PAYROLL STRUCTURE -->
|
||||
<record id="hr_payroll_salary_structure_us_ks_employee" model="hr.payroll.structure">
|
||||
<field name="code">US_KS_EMP</field>
|
||||
<field name="name">USA Kansas Employee</field>
|
||||
<field eval="[(6, 0, [
|
||||
ref('hr_payroll_rules_ks_unemp_wages_2018'),
|
||||
ref('hr_payroll_rules_ks_unemp_2018'),
|
||||
ref('hr_payroll_rules_ks_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>
|
||||
229
l10n_us_ks_hr_payroll/data/rules_2018.xml
Executable file
229
l10n_us_ks_hr_payroll/data/rules_2018.xml
Executable file
@@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR SALARY RULES-->
|
||||
<record id="hr_payroll_rules_ks_unemp_wages_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="423"/>
|
||||
<field name="category_id" ref="hr_payroll_ks_unemp_wages"/>
|
||||
<field name="name">Kansas Unemployment Insurance Tax - Wages (2018)</field>
|
||||
<field name="code">KS_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('KS_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01')
|
||||
ytd += contract.external_wages
|
||||
remaining = 14000.0 - ytd
|
||||
if remaining <= 0.0:
|
||||
result = 0
|
||||
elif remaining < categories.GROSS:
|
||||
result = remaining
|
||||
else:
|
||||
result = categories.GROSS
|
||||
</field>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
<record id="hr_payroll_rules_ks_unemp_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="443"/>
|
||||
<field name="category_id" ref="hr_payroll_ks_unemp"/>
|
||||
<field name="name">Kansas Unemployment (2018)</field>
|
||||
<field name="code">KS_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.ks_unemp_rate(2018)
|
||||
result = categories.KS_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_ksdor_unemp"/>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!-- STATE INCOME WITHHOLDING -->
|
||||
<record id="hr_payroll_rules_ks_inc_withhold_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="145"/>
|
||||
<field name="category_id" ref="hr_payroll_ks_income_withhold"/>
|
||||
<field name="name">Kansas Income Withholding</field>
|
||||
<field name="code">KS_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.ks_k4_allowances
|
||||
additional_withholding = contract.ks_additional_withholding
|
||||
schedule_pay = contract.schedule_pay
|
||||
filing_status = contract.ks_k4_filing_status
|
||||
|
||||
# Tables are found in https://www.ksrevenue.org/pdf/kw1002017.pdf
|
||||
# First check for exemption status (Step 1)
|
||||
if filing_status == 'exempt':
|
||||
result = 0
|
||||
|
||||
else:
|
||||
# Calculate Withholding Allowance Amounts using table (allowance multipliers are from table).
|
||||
if schedule_pay == 'weekly':
|
||||
wages -= (allowances * 43.27)
|
||||
elif schedule_pay == 'bi-weekly':
|
||||
wages -= (allowances * 86.54)
|
||||
elif schedule_pay == 'semi-monthly':
|
||||
wages -= (allowances * 93.75)
|
||||
elif schedule_pay == 'monthly':
|
||||
wages -= (allowances * 187.50)
|
||||
elif schedule_pay == 'quarterly':
|
||||
wages -= (allowances * 562.50)
|
||||
elif schedule_pay == 'semi-annual':
|
||||
wages -= (allowances * 1125.00)
|
||||
elif schedule_pay == 'annually':
|
||||
wages -= (allowances * 2250.00)
|
||||
|
||||
# Tax Rate Tables to calculate income withholding
|
||||
#### WEEKLY ####
|
||||
if schedule_pay == 'weekly':
|
||||
if filing_status == 'head_household' or 'single' and wages > 0:
|
||||
tax_rate_table = [
|
||||
(58, 0.0, 0.0),
|
||||
(346, 0.031, 0.0),
|
||||
(635, 0.0525, 8.94),
|
||||
(float('inf'), 0.057, 24.09),
|
||||
]
|
||||
|
||||
elif filing_status == 'married':
|
||||
tax_rate_table = [
|
||||
(144, 0.0, 0.0),
|
||||
(721, 0.031, 0.0),
|
||||
(1298, 0.0525, 17.88),
|
||||
(float('inf'), 0.057, 48.17),
|
||||
]
|
||||
|
||||
### BI-WEEKLY ###
|
||||
if schedule_pay == 'bi-weekly':
|
||||
if filing_status == 'head_household' or 'single' and wages > 0:
|
||||
tax_rate_table = [
|
||||
(115, 0.0, 0.0),
|
||||
(692, 0.031, 0.0),
|
||||
(1269, 0.0525, 17.88),
|
||||
(float('inf'), 0.057, 48.17),
|
||||
]
|
||||
|
||||
elif filing_status == 'married':
|
||||
tax_rate_table = [
|
||||
(288, 0.0, 0.0),
|
||||
(1442, 0.031, 0.0),
|
||||
(2596, 0.0525, 35.77),
|
||||
(float('inf'), 0.057, 96.35),
|
||||
]
|
||||
|
||||
### SEMI-MONTHLY ###
|
||||
if schedule_pay == 'semi-monthly':
|
||||
if filing_status == 'head_household' or 'single' and wages > 0:
|
||||
tax_rate_table = [
|
||||
(125, 0.0, 0.0),
|
||||
(750, 0.031, 0.0),
|
||||
(1375, 0.0525, 19.38),
|
||||
(float('inf'), 0.057, 52.19),
|
||||
]
|
||||
|
||||
elif filing_status == 'married':
|
||||
tax_rate_table = [
|
||||
(313, 0.0, 0.0),
|
||||
(1563, 0.031, 0.0),
|
||||
(2813, 0.0525, 38.75),
|
||||
(float('inf'), 0.057, 104.38),
|
||||
]
|
||||
|
||||
### MONTHLY ###
|
||||
if schedule_pay == 'monthly':
|
||||
if filing_status == 'head_household' or 'single' and wages > 0:
|
||||
tax_rate_table = [
|
||||
(250, 0.0, 0.0),
|
||||
(1500, 0.031, 0.0),
|
||||
(2750, 0.0525, 38.75),
|
||||
(float('inf'), 0.057, 104.38),
|
||||
]
|
||||
|
||||
elif filing_status == 'married':
|
||||
tax_rate_table = [
|
||||
(625, 0.0, 0.0),
|
||||
(3125, 0.031, 0.0),
|
||||
(5625, 0.0525, 77.50),
|
||||
(float('inf'), 0.057, 208.75),
|
||||
]
|
||||
|
||||
### QUARTERLY ###
|
||||
if schedule_pay == 'quarterly':
|
||||
if filing_status == 'head_household' or 'single' and wages > 0:
|
||||
tax_rate_table = [
|
||||
(750, 0.0, 0.0),
|
||||
(4500, 0.031, 0.0),
|
||||
(8250, 0.0525, 116.25),
|
||||
(float('inf'), 0.057, 313.13),
|
||||
]
|
||||
|
||||
elif filing_status == 'married':
|
||||
tax_rate_table = [
|
||||
(1875, 0.0, 0.0),
|
||||
(9375, 0.031, 0.0),
|
||||
(16875, 0.0525, 232.50),
|
||||
(float('inf'), 0.057, 626.25),
|
||||
]
|
||||
|
||||
### SEMI-ANNUAL ###
|
||||
if schedule_pay == 'semi-annual':
|
||||
if filing_status == 'head_household' or 'single' and wages > 0:
|
||||
tax_rate_table = [
|
||||
(1500, 0.0, 0.0),
|
||||
(9000, 0.031, 0.0),
|
||||
(16500, 0.0525, 232.50),
|
||||
(float('inf'), 0.057, 626.25),
|
||||
]
|
||||
|
||||
elif filing_status == 'married':
|
||||
tax_rate_table = [
|
||||
(3750, 0.0, 0.0),
|
||||
(18750, 0.031, 0.0),
|
||||
(33750, 0.0525, 465.00),
|
||||
(float('inf'), 0.057, 1252.50),
|
||||
]
|
||||
|
||||
### ANNUAL ###
|
||||
if schedule_pay == 'annually':
|
||||
if filing_status == 'head_household' or 'single' and wages > 0:
|
||||
tax_rate_table = [
|
||||
(3000, 0.0, 0.0),
|
||||
(18000, 0.031, 0.0),
|
||||
(33000, 0.0525, 465.00),
|
||||
(float('inf'), 0.057, 1252.50),
|
||||
]
|
||||
|
||||
elif filing_status == 'married':
|
||||
tax_rate_table = [
|
||||
(7500, 0.0, 0.0),
|
||||
(37500, 0.031, 0.0),
|
||||
(67500, 0.0525, 930.00),
|
||||
(float('inf'), 0.057, 2505.00),
|
||||
]
|
||||
|
||||
over = 0.0
|
||||
tax = 0.0
|
||||
for row in tax_rate_table:
|
||||
if wages <= row[0]:
|
||||
tax = ((wages - over) * row[1]) + row[2]
|
||||
tax += additional_withholding
|
||||
break
|
||||
over = row[0]
|
||||
|
||||
result = -tax
|
||||
|
||||
</field>
|
||||
<field name="register_id" ref="contrib_register_ksdor_withhold"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
1
l10n_us_ks_hr_payroll/tests/__init__.py
Executable file
1
l10n_us_ks_hr_payroll/tests/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import test_us_ks_payslip_2018
|
||||
92
l10n_us_ks_hr_payroll/tests/test_us_ks_payslip_2018.py
Executable file
92
l10n_us_ks_hr_payroll/tests/test_us_ks_payslip_2018.py
Executable file
@@ -0,0 +1,92 @@
|
||||
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 TestUsKSPayslip(TestUsPayslip):
|
||||
###
|
||||
# 2018 Taxes and Rates
|
||||
###
|
||||
KS_UNEMP_MAX_WAGE = 14000.0
|
||||
|
||||
def test_2018_taxes(self):
|
||||
self.debug = True
|
||||
salary = 210
|
||||
schedule_pay = 'weekly'
|
||||
allowances = 2
|
||||
additional_withholding = 0
|
||||
|
||||
# Amount of each withholding allowance for weekly from Withholding Allowance Amounts Table
|
||||
# https://www.ksrevenue.org/pdf/kw1002017.pdf
|
||||
withholding_allowance = 43.27 * allowances
|
||||
taxable_pay = salary - withholding_allowance
|
||||
|
||||
# Tax Percentage Method for Single, taxable pay over $58, under $346
|
||||
wh = -round(((taxable_pay - 58) * 0.031) - additional_withholding, 2)
|
||||
|
||||
employee = self._createEmployee()
|
||||
|
||||
contract = self._createContract(employee,
|
||||
salary,
|
||||
struct_id=self.ref(
|
||||
'l10n_us_ks_hr_payroll.hr_payroll_salary_structure_us_ks_employee'),
|
||||
schedule_pay=schedule_pay)
|
||||
contract.ks_k4_allowances = allowances
|
||||
contract.ks_additional_withholding = additional_withholding
|
||||
contract.ks_k4_filing_status = 'single'
|
||||
|
||||
self.assertEqual(contract.schedule_pay, 'weekly')
|
||||
|
||||
# tax rates
|
||||
ks_unemp = contract.ks_unemp_rate(2018) / -100.0
|
||||
|
||||
self._log('2018 Kansas tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['KS_UNEMP_WAGES'], salary)
|
||||
self.assertPayrollEqual(cats['KS_UNEMP'], cats['KS_UNEMP_WAGES'] * ks_unemp)
|
||||
self.assertPayrollEqual(cats['KS_WITHHOLD'], wh)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
# Make a new payslip, this one will have maximums
|
||||
|
||||
remaining_ks_unemp_wages = self.KS_UNEMP_MAX_WAGE - salary if (self.KS_UNEMP_MAX_WAGE - 2 * salary < salary) \
|
||||
else salary
|
||||
|
||||
self._log('2018 Kansas tax second payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['KS_UNEMP_WAGES'], remaining_ks_unemp_wages)
|
||||
self.assertPayrollEqual(cats['KS_UNEMP'], remaining_ks_unemp_wages * ks_unemp)
|
||||
|
||||
def test_2018_taxes_with_state_exempt(self):
|
||||
salary = 210
|
||||
schedule_pay = 'weekly'
|
||||
allowances = 2
|
||||
|
||||
# Tax Exempt
|
||||
wh = 0
|
||||
|
||||
employee = self._createEmployee()
|
||||
|
||||
contract = self._createContract(employee,
|
||||
salary,
|
||||
struct_id=self.ref(
|
||||
'l10n_us_ks_hr_payroll.hr_payroll_salary_structure_us_ks_employee'),
|
||||
schedule_pay=schedule_pay)
|
||||
contract.ks_k4_allowances = allowances
|
||||
contract.ks_k4_filing_status = 'exempt'
|
||||
|
||||
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertEqual(cats['KS_WITHHOLD'], wh)
|
||||
36
l10n_us_ks_hr_payroll/us_ks_hr_payroll.py
Executable file
36
l10n_us_ks_hr_payroll/us_ks_hr_payroll.py
Executable file
@@ -0,0 +1,36 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class USKSHrContract(models.Model):
|
||||
_inherit = 'hr.contract'
|
||||
|
||||
ks_k4_allowances = fields.Integer(string="Kansas K-4 Allowances",
|
||||
default=0,
|
||||
help="Allowances claimed on K-4")
|
||||
ks_additional_withholding = fields.Float(string="Additional Withholding",
|
||||
default=0.0,
|
||||
help='Additional withholding from line 5 of form K-4')
|
||||
ks_k4_filing_status = fields.Selection([
|
||||
('exempt', 'Exempt'),
|
||||
('single', 'Single'),
|
||||
('married', 'Married'),
|
||||
('head_household', 'Head of Household')
|
||||
], string='KS Filing Status', default='single')
|
||||
|
||||
|
||||
@api.multi
|
||||
def ks_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, 'ks_unemp_rate_' + str(year)):
|
||||
return self.employee_id.company_id['ks_unemp_rate_' + str(year)]
|
||||
|
||||
raise NotImplemented('Year (' + str(year) + ') Not implemented for US Kansas.')
|
||||
|
||||
|
||||
class KSCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
ks_unemp_rate_2018 = fields.Float(string="Kansas Unemployment Insurance Rate 2018", default=2.7)
|
||||
35
l10n_us_ks_hr_payroll/us_ks_hr_payroll_view.xml
Executable file
35
l10n_us_ks_hr_payroll/us_ks_hr_payroll_view.xml
Executable file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="us_ks_view_company_form" model="ir.ui.view">
|
||||
<field name="name">res.company.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="priority">20</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="ks_unemp_rate_2018"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_contract_form_l10n_us_ks_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.contract.form.inherit</field>
|
||||
<field name="model">hr.contract</field>
|
||||
<field name="priority">147</field>
|
||||
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//group[@name='state_filing']" position="inside">
|
||||
<group string="Kansas" name="ks">
|
||||
<field name="ks_k4_allowances" string="K-4 Allowances"/>
|
||||
<field name="ks_additional_withholding" string="Additional Withholding"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user