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_ms_hr_payroll US Mississippi Payroll for 11.0
This commit is contained in:
24
l10n_us_ms_hr_payroll/README.rst
Normal file
24
l10n_us_ms_hr_payroll/README.rst
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
**************************************
|
||||||
|
Hibou - US Payroll - Mississippi State
|
||||||
|
**************************************
|
||||||
|
|
||||||
|
Calculations and contribution registers for Mississippi State Payroll.
|
||||||
|
|
||||||
|
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
|
||||||
|
|
||||||
|
=============
|
||||||
|
Main Features
|
||||||
|
=============
|
||||||
|
|
||||||
|
* New Partners and Contribution Registers for:
|
||||||
|
* Mississippi Department of Revenue
|
||||||
|
* Mississippi Department of Employment Security
|
||||||
|
* Contract level Mississippi Exemptions and 89-350 fields
|
||||||
|
* Payroll Rate for Mississippi Unemployment Rate
|
||||||
|
|
||||||
|
|
||||||
|
=======
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/master/LICENSE>`_.
|
||||||
|
Copyright Hibou Corp. 2019
|
||||||
1
l10n_us_ms_hr_payroll/__init__.py
Executable file
1
l10n_us_ms_hr_payroll/__init__.py
Executable file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
28
l10n_us_ms_hr_payroll/__manifest__.py
Executable file
28
l10n_us_ms_hr_payroll/__manifest__.py
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
'name': 'USA - Mississippi - Payroll',
|
||||||
|
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'category': 'Localization',
|
||||||
|
'depends': ['l10n_us_hr_payroll'],
|
||||||
|
'version': '11.0.2019.0.0',
|
||||||
|
'description': """
|
||||||
|
USA::Mississippi Payroll Rules.
|
||||||
|
===============================
|
||||||
|
|
||||||
|
* New Partners and Contribution Registers for:
|
||||||
|
* Mississippi Department of Revenue
|
||||||
|
* Mississippi Department of Employment Security
|
||||||
|
* Contract level Mississippi Exemptions and 89-350 fields
|
||||||
|
* Payroll Rate for Mississippi Unemployment Rate
|
||||||
|
""",
|
||||||
|
'auto_install': False,
|
||||||
|
'website': 'https://hibou.io/',
|
||||||
|
'data': [
|
||||||
|
'views/hr_payroll_views.xml',
|
||||||
|
'data/base.xml',
|
||||||
|
'data/rates.xml',
|
||||||
|
'data/rules.xml',
|
||||||
|
'data/final.xml',
|
||||||
|
],
|
||||||
|
'installable': True
|
||||||
|
}
|
||||||
44
l10n_us_ms_hr_payroll/data/base.xml
Executable file
44
l10n_us_ms_hr_payroll/data/base.xml
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<!-- CONTRIBUTION REGISTERS -->
|
||||||
|
<record id="res_partner_msdor_unemp" model="res.partner">
|
||||||
|
<field name="name">Mississippi Department of Employment Security</field>
|
||||||
|
<field name="supplier">1</field>
|
||||||
|
<field eval="0" name="customer"/>
|
||||||
|
</record>
|
||||||
|
<record id="res_partner_msdor_withhold" model="res.partner">
|
||||||
|
<field name="name">Mississippi Department of Revenue</field>
|
||||||
|
<field name="supplier">1</field>
|
||||||
|
<field eval="0" name="customer"/>
|
||||||
|
</record>
|
||||||
|
<record id="contrib_register_msdor_unemp" model="hr.contribution.register">
|
||||||
|
<field name="name">Mississippi Unemployment</field>
|
||||||
|
<field name="note">Mississippi Department of Employment Security</field>
|
||||||
|
<field name="partner_id" ref="res_partner_msdor_unemp"/>
|
||||||
|
</record>
|
||||||
|
<record id="contrib_register_msdor_withhold" model="hr.contribution.register">
|
||||||
|
<field name="name">Mississippi Income Tax Withholding</field>
|
||||||
|
<field name="note">Mississippi Department of Revenue - Income Tax Withholding</field>
|
||||||
|
<field name="partner_id" ref="res_partner_msdor_withhold"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- HR SALARY RULE CATEGORIES-->
|
||||||
|
<record id="hr_payroll_ms_unemp_wages" model="hr.salary.rule.category">
|
||||||
|
<field name="name">Wage: US-MS Unemployment</field>
|
||||||
|
<field name="code">WAGE_US_MS_UNEMP</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hr_payroll_ms_unemp" model="hr.salary.rule.category">
|
||||||
|
<field name="name">ER: US-MS Unemployment</field>
|
||||||
|
<field name="code">ER_US_MS_UNEMP</field>
|
||||||
|
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hr_payroll_ms_income_withhold" model="hr.salary.rule.category">
|
||||||
|
<field name="name">EE: US-MS Income Withholding</field>
|
||||||
|
<field name="code">EE_US_MS_INC_WITHHOLD</field>
|
||||||
|
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
17
l10n_us_ms_hr_payroll/data/final.xml
Executable file
17
l10n_us_ms_hr_payroll/data/final.xml
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<!-- HR PAYROLL STRUCTURE -->
|
||||||
|
<record id="hr_payroll_salary_structure_us_ms_employee" model="hr.payroll.structure">
|
||||||
|
<field name="code">US_MS_EMP</field>
|
||||||
|
<field name="name">USA Mississippi Employee</field>
|
||||||
|
<field eval="[(6, 0, [
|
||||||
|
ref('hr_payroll_rules_ms_unemp_wages'),
|
||||||
|
ref('hr_payroll_rules_ms_unemp'),
|
||||||
|
ref('hr_payroll_rules_ms_inc_withhold'),
|
||||||
|
])]" 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>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
12
l10n_us_ms_hr_payroll/data/rates.xml
Normal file
12
l10n_us_ms_hr_payroll/data/rates.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record id="hr_payroll_rates_ms_unemp_2019" model="hr.payroll.rate">
|
||||||
|
<field name="name">US Mississippi Unemployment</field>
|
||||||
|
<field name="code">US_MS_UNEMP</field>
|
||||||
|
<field name="rate">1.2</field>
|
||||||
|
<field name="date_from">2019-01-01</field>
|
||||||
|
<field name="wage_limit_year" eval="14000.0"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
123
l10n_us_ms_hr_payroll/data/rules.xml
Executable file
123
l10n_us_ms_hr_payroll/data/rules.xml
Executable file
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<!-- HR SALARY RULES-->
|
||||||
|
<record id="hr_payroll_rules_ms_unemp_wages" model="hr.salary.rule">
|
||||||
|
<field name="sequence" eval="423"/>
|
||||||
|
<field name="category_id" ref="hr_payroll_ms_unemp_wages"/>
|
||||||
|
<field name="name">Wage: US-MS Unemployment</field>
|
||||||
|
<field name="code">WAGE_US_MS_UNEMP</field>
|
||||||
|
<field name="condition_select">python</field>
|
||||||
|
<field name="condition_python">result = (contract.futa_type != contract.FUTA_TYPE_BASIC)</field>
|
||||||
|
<field name="amount_select">code</field>
|
||||||
|
<field name="amount_python_compute">
|
||||||
|
###
|
||||||
|
year = int(payslip.dict.date_to[:4])
|
||||||
|
rate = payslip.dict.get_rate('US_MS_UNEMP')
|
||||||
|
ytd = payslip.sum('WAGE_US_MS_UNEMP', str(year) + '-01-01', str(year+1) + '-01-01')
|
||||||
|
ytd += contract.external_wages
|
||||||
|
remaining = rate.wage_limit_year - ytd
|
||||||
|
if remaining <= 0.0:
|
||||||
|
result = 0
|
||||||
|
elif remaining < categories.BASIC:
|
||||||
|
result = remaining
|
||||||
|
else:
|
||||||
|
result = categories.BASIC
|
||||||
|
</field>
|
||||||
|
<field name="appears_on_payslip" eval="False"/>
|
||||||
|
</record>
|
||||||
|
<record id="hr_payroll_rules_ms_unemp" model="hr.salary.rule">
|
||||||
|
<field name="sequence" eval="443"/>
|
||||||
|
<field name="category_id" ref="hr_payroll_ms_unemp"/>
|
||||||
|
<field name="name">ER: US-MS Unemployment</field>
|
||||||
|
<field name="code">ER_US_MS_UNEMP</field>
|
||||||
|
<field name="condition_select">python</field>
|
||||||
|
<field name="condition_python">result = (contract.futa_type != contract.FUTA_TYPE_BASIC)</field>
|
||||||
|
<field name="amount_select">code</field>
|
||||||
|
<field name="amount_python_compute">
|
||||||
|
rate = payslip.dict.get_rate('US_MS_UNEMP')
|
||||||
|
result_rate = -rate.rate
|
||||||
|
result = categories.WAGE_US_MS_UNEMP
|
||||||
|
|
||||||
|
# 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_msdor_unemp"/>
|
||||||
|
<field name="appears_on_payslip" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hr_payroll_rules_ms_inc_withhold" model="hr.salary.rule">
|
||||||
|
<field name="sequence" eval="145"/>
|
||||||
|
<field name="category_id" ref="hr_payroll_ms_income_withhold"/>
|
||||||
|
<field name="name">EE: US-MS Income Withholding</field>
|
||||||
|
<field name="code">EE_US_MS_INC_WITHHOLD</field>
|
||||||
|
<field name="condition_select">python</field>
|
||||||
|
<field name="condition_python">result = contract.ms_89_350_filing_status</field>
|
||||||
|
<field name="amount_select">code</field>
|
||||||
|
<field name="amount_python_compute">
|
||||||
|
year = int(payslip.dict.date_to[:4])
|
||||||
|
filing_status = contract.ms_89_350_filing_status
|
||||||
|
schedule_pay = contract.schedule_pay
|
||||||
|
PPAY = categories.GROSS
|
||||||
|
EX = contract.ms_89_350_exemption
|
||||||
|
additional = contract.ms_89_350_additional_withholding
|
||||||
|
|
||||||
|
STDED = 0.0
|
||||||
|
|
||||||
|
PP = 0
|
||||||
|
if 'weekly' == schedule_pay:
|
||||||
|
PP = 52
|
||||||
|
elif 'bi-weekly' == schedule_pay:
|
||||||
|
PP = 26
|
||||||
|
elif 'semi-monthly' == schedule_pay:
|
||||||
|
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 MO Income Withholding calculation')
|
||||||
|
|
||||||
|
AGP = PPAY * PP
|
||||||
|
|
||||||
|
if year == 2019 or True:
|
||||||
|
if filing_status == 'single':
|
||||||
|
STDED = 2300.0
|
||||||
|
elif filing_status == 'head_of_household':
|
||||||
|
STDED = 3400.0
|
||||||
|
elif filing_status == 'married_dual':
|
||||||
|
STDED = 2300.0
|
||||||
|
elif filing_status == 'married':
|
||||||
|
STDED = 4600.0
|
||||||
|
|
||||||
|
bracket = [
|
||||||
|
(10000.0, 0.05, 290.0),
|
||||||
|
(5000.0, 0.04, 90.0),
|
||||||
|
(2000.0, 0.03, 0.0),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
TI = AGP - (EX + STDED)
|
||||||
|
if TI <= 0.01:
|
||||||
|
result = 0.0
|
||||||
|
else:
|
||||||
|
for data in bracket:
|
||||||
|
if TI >= data[0]:
|
||||||
|
TAX = ((TI - data[0]) * data[1]) + data[2]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
TAX = 0.0
|
||||||
|
|
||||||
|
result = round(TAX / PP)
|
||||||
|
|
||||||
|
result += additional
|
||||||
|
</field>
|
||||||
|
<field name="register_id" ref="contrib_register_msdor_withhold"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
1
l10n_us_ms_hr_payroll/models/__init__.py
Normal file
1
l10n_us_ms_hr_payroll/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import hr_payroll
|
||||||
18
l10n_us_ms_hr_payroll/models/hr_payroll.py
Executable file
18
l10n_us_ms_hr_payroll/models/hr_payroll.py
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
from odoo import models, fields
|
||||||
|
|
||||||
|
|
||||||
|
class USMSHrContract(models.Model):
|
||||||
|
_inherit = 'hr.contract'
|
||||||
|
|
||||||
|
ms_89_350_filing_status = fields.Selection([
|
||||||
|
('', 'Exempt (e.g. Box 8)'),
|
||||||
|
('single', 'Single'),
|
||||||
|
('married', 'Married (spouse NOT employed)'),
|
||||||
|
('married_dual', 'Married (spouse IS employed)'),
|
||||||
|
('head_of_household', 'Head of Household'),
|
||||||
|
], string='Mississippi 89-350 Filing Status', default='single')
|
||||||
|
|
||||||
|
ms_89_350_exemption = fields.Float(string='Mississippi 89-350 Exemptions', default=0.0,
|
||||||
|
help='Box 6')
|
||||||
|
ms_89_350_additional_withholding = fields.Float(string="Mississippi 89-350 Additional Withholding", default=0.0,
|
||||||
|
help='Box 7')
|
||||||
1
l10n_us_ms_hr_payroll/tests/__init__.py
Executable file
1
l10n_us_ms_hr_payroll/tests/__init__.py
Executable file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_us_ms_payslip_2019
|
||||||
86
l10n_us_ms_hr_payroll/tests/test_us_ms_payslip_2019.py
Executable file
86
l10n_us_ms_hr_payroll/tests/test_us_ms_payslip_2019.py
Executable file
@@ -0,0 +1,86 @@
|
|||||||
|
from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip
|
||||||
|
|
||||||
|
|
||||||
|
class TestUsMsPayslip(TestUsPayslip):
|
||||||
|
# Calculations from https://www.dor.ms.gov/Documents/Computer%20Payroll%20Accounting%201-2-19.pdf
|
||||||
|
MS_UNEMP = -1.2 / 100.0
|
||||||
|
|
||||||
|
def test_2019_taxes_one(self):
|
||||||
|
salary = 1250.0
|
||||||
|
ms_89_350_exemption = 11000.0
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_ms_hr_payroll.hr_payroll_salary_structure_us_ms_employee'),
|
||||||
|
schedule_pay='semi-monthly')
|
||||||
|
contract.ms_89_350_filing_status = 'head_of_household'
|
||||||
|
contract.ms_89_350_exemption = ms_89_350_exemption
|
||||||
|
|
||||||
|
self._log('2019 Mississippi tax single first payslip:')
|
||||||
|
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||||
|
|
||||||
|
payslip.compute_sheet()
|
||||||
|
|
||||||
|
cats = self._getCategories(payslip)
|
||||||
|
|
||||||
|
self.assertPayrollEqual(cats['WAGE_US_MS_UNEMP'], salary)
|
||||||
|
self.assertPayrollEqual(cats['ER_US_MS_UNEMP'], cats['WAGE_US_MS_UNEMP'] * self.MS_UNEMP)
|
||||||
|
|
||||||
|
STDED = 3400.0 # Head of Household
|
||||||
|
AGP = salary * 24 # Semi-Monthly
|
||||||
|
TI = AGP - (ms_89_350_exemption + STDED)
|
||||||
|
self.assertPayrollEqual(TI, 15600.0)
|
||||||
|
TAX = ((TI - 10000) * 0.05) + 290 # Over 10,000
|
||||||
|
self.assertPayrollEqual(TAX, 570.0)
|
||||||
|
|
||||||
|
ms_withhold = round(TAX / 24) # Semi-Monthly
|
||||||
|
self.assertPayrollEqual(cats['EE_US_MS_INC_WITHHOLD'], ms_withhold)
|
||||||
|
|
||||||
|
def test_2019_taxes_one_exempt(self):
|
||||||
|
salary = 1250.0
|
||||||
|
ms_89_350_exemption = 11000.0
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_ms_hr_payroll.hr_payroll_salary_structure_us_ms_employee'),
|
||||||
|
schedule_pay='semi-monthly')
|
||||||
|
contract.ms_89_350_filing_status = ''
|
||||||
|
contract.ms_89_350_exemption = ms_89_350_exemption
|
||||||
|
|
||||||
|
self._log('2019 Mississippi tax single first payslip:')
|
||||||
|
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||||
|
|
||||||
|
payslip.compute_sheet()
|
||||||
|
|
||||||
|
cats = self._getCategories(payslip)
|
||||||
|
self.assertPayrollEqual(cats.get('EE_US_MS_INC_WITHHOLD', 0.0), 0.0)
|
||||||
|
|
||||||
|
def test_2019_taxes_additional(self):
|
||||||
|
salary = 1250.0
|
||||||
|
ms_89_350_exemption = 11000.0
|
||||||
|
additional = 40.0
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_ms_hr_payroll.hr_payroll_salary_structure_us_ms_employee'),
|
||||||
|
schedule_pay='semi-monthly')
|
||||||
|
contract.ms_89_350_filing_status = 'head_of_household'
|
||||||
|
contract.ms_89_350_exemption = ms_89_350_exemption
|
||||||
|
contract.ms_89_350_additional_withholding = additional
|
||||||
|
|
||||||
|
self._log('2019 Mississippi tax single first payslip:')
|
||||||
|
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||||
|
|
||||||
|
payslip.compute_sheet()
|
||||||
|
|
||||||
|
cats = self._getCategories(payslip)
|
||||||
|
|
||||||
|
self.assertPayrollEqual(cats['WAGE_US_MS_UNEMP'], salary)
|
||||||
|
self.assertPayrollEqual(cats['ER_US_MS_UNEMP'], cats['WAGE_US_MS_UNEMP'] * self.MS_UNEMP)
|
||||||
|
|
||||||
|
STDED = 3400.0 # Head of Household
|
||||||
|
AGP = salary * 24 # Semi-Monthly
|
||||||
|
TI = AGP - (ms_89_350_exemption + STDED)
|
||||||
|
self.assertPayrollEqual(TI, 15600.0)
|
||||||
|
TAX = ((TI - 10000) * 0.05) + 290 # Over 10,000
|
||||||
|
self.assertPayrollEqual(TAX, 570.0)
|
||||||
|
|
||||||
|
ms_withhold = round(TAX / 24) # Semi-Monthly
|
||||||
|
self.assertPayrollEqual(cats['EE_US_MS_INC_WITHHOLD'], ms_withhold + additional)
|
||||||
20
l10n_us_ms_hr_payroll/views/hr_payroll_views.xml
Executable file
20
l10n_us_ms_hr_payroll/views/hr_payroll_views.xml
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="hr_contract_form_l10n_us_ms_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">hr.contract.form.inherit</field>
|
||||||
|
<field name="model">hr.contract</field>
|
||||||
|
<field name="priority">139</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="Mississippi" name="ms">
|
||||||
|
<field name="ms_89_350_filing_status" string="Filing Status"/>
|
||||||
|
<field name="ms_89_350_exemption" string="Exemptions"/>
|
||||||
|
<field name="ms_89_350_additional_withholding" string="Additional Withholding"/>
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user