mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Adding all from 11.0 https://github.com/hibou-io/odoo-hr-payroll
hr_payroll_holidays hr_payroll_input_name_report hr_payroll_input_report hr_payroll_payment hr_payroll_timesheet hr_payslip_line_date l10n_us_fl_hr_payroll l10n_us_hr_payroll l10n_us_mo_hr_payroll l10n_us_oh_hr_payroll l10n_us_va_hr_payroll
This commit is contained in:
3
l10n_us_mo_hr_payroll/__init__.py
Executable file
3
l10n_us_mo_hr_payroll/__init__.py
Executable file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import hr_payroll
|
||||
28
l10n_us_mo_hr_payroll/__manifest__.py
Executable file
28
l10n_us_mo_hr_payroll/__manifest__.py
Executable file
@@ -0,0 +1,28 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
{
|
||||
'name': 'USA - Missouri - 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::Missouri Payroll Rules.
|
||||
============================
|
||||
|
||||
* Contribution register and partner for Missouri Department of Revenue - Unemployment
|
||||
* Contribution register and partner for Missouri Department of Revenue - Income Tax Withholding
|
||||
* Contract level Missouri Exemptions and MO W-4 fields
|
||||
* Company level Missouri Unemployment Rate
|
||||
""",
|
||||
|
||||
'auto_install': False,
|
||||
'website': 'https://hibou.io/',
|
||||
'data': [
|
||||
'hr_payroll_view.xml',
|
||||
'data/base.xml',
|
||||
'data/rules_2018.xml',
|
||||
'data/final.xml',
|
||||
],
|
||||
'installable': True
|
||||
}
|
||||
46
l10n_us_mo_hr_payroll/data/base.xml
Executable file
46
l10n_us_mo_hr_payroll/data/base.xml
Executable file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- CONTRIBUTION REGISTERS -->
|
||||
<record id="res_partner_modor_unemp" model="res.partner">
|
||||
<field name="name">Missouri Department of Revenue - Unemployment Tax</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
<record id="res_partner_modor_withhold" model="res.partner">
|
||||
<field name="name">Missouri Department of Revenue - Income Tax Withholding</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
<record id="contrib_register_modor_unemp" model="hr.contribution.register">
|
||||
<field name="name">Missouri Unemployment</field>
|
||||
<field name="note">Missouri Department of Revemie - Unemployment</field>
|
||||
<field name="partner_id" ref="res_partner_modor_unemp"/>
|
||||
</record>
|
||||
<record id="contrib_register_modor_withhold" model="hr.contribution.register">
|
||||
<field name="name">Missouri Income Tax Withholding</field>
|
||||
<field name="note">Missouri Department of Revenue - Income Tax Withholding</field>
|
||||
<field name="partner_id" ref="res_partner_modor_withhold"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- HR SALARY RULE CATEGORIES-->
|
||||
<record id="hr_payroll_mo_unemp_wages" model="hr.salary.rule.category">
|
||||
<field name="name">Missouri Unemployment - Wages</field>
|
||||
<field name="code">MO_UNEMP_WAGES</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_mo_unemp" model="hr.salary.rule.category">
|
||||
<field name="name">Missouri Unemployment</field>
|
||||
<field name="code">MO_UNEMP</field>
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_mo_income_withhold" model="hr.salary.rule.category">
|
||||
<field name="name">Missouri Income Withholding</field>
|
||||
<field name="code">MO_INC_WITHHOLD</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
19
l10n_us_mo_hr_payroll/data/final.xml
Executable file
19
l10n_us_mo_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_mo_employee" model="hr.payroll.structure">
|
||||
<field name="code">US_MO_EMP</field>
|
||||
<field name="name">USA Missouri Employee</field>
|
||||
<field eval="[(6, 0, [
|
||||
ref('hr_payroll_rules_mo_unemp_wages_2018'),
|
||||
ref('hr_payroll_rules_mo_unemp_2018'),
|
||||
ref('hr_payroll_rules_mo_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>
|
||||
159
l10n_us_mo_hr_payroll/data/rules_2018.xml
Executable file
159
l10n_us_mo_hr_payroll/data/rules_2018.xml
Executable file
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR SALARY RULES-->
|
||||
<record id="hr_payroll_rules_mo_unemp_wages_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="423"/>
|
||||
<field name="category_id" ref="hr_payroll_mo_unemp_wages"/>
|
||||
<field name="name">Missouri Unemployment - Wages (2018)</field>
|
||||
<field name="code">MO_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('MO_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01')
|
||||
ytd += contract.external_wages
|
||||
remaining = 12500.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_mo_unemp_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="443"/>
|
||||
<field name="category_id" ref="hr_payroll_mo_unemp"/>
|
||||
<field name="name">Missouri Unemployment (2018)</field>
|
||||
<field name="code">MO_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.mo_unemp_rate(2018)
|
||||
result = categories.MO_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_modor_unemp"/>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_rules_mo_inc_withhold_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="145"/>
|
||||
<field name="category_id" ref="hr_payroll_mo_income_withhold"/>
|
||||
<field name="name">Missouri Income Withholding (2018)</field>
|
||||
<field name="code">MO_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">
|
||||
TAX = [
|
||||
(1028.0, 1.5),
|
||||
(1028.0, 2.0),
|
||||
(1028.0, 2.5),
|
||||
(1028.0, 3.0),
|
||||
(1028.0, 3.5),
|
||||
(1028.0, 4.0),
|
||||
(1028.0, 4.5),
|
||||
(1028.0, 5.0),
|
||||
(1028.0, 5.5),
|
||||
(999999999.0, 5.9),
|
||||
]
|
||||
wages = categories.GROSS
|
||||
exemptions = contract.mo_mow4_exemptions
|
||||
filing_status = contract.mo_mow4_filing_status
|
||||
additional = contract.mo_mow4_additional_withholding
|
||||
spouse_employed = contract.mo_mow4_spouse_employed
|
||||
schedule_pay = contract.schedule_pay
|
||||
result = 0.00
|
||||
|
||||
if filing_status:
|
||||
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')
|
||||
|
||||
gross_salary = PP * wages
|
||||
deduction = -1
|
||||
if filing_status == 'single' or (filing_status == 'married' and spouse_employed):
|
||||
deduction = 6500.0
|
||||
elif filing_status == 'married' and not spouse_employed:
|
||||
deduction = 13000.0
|
||||
else:
|
||||
deduction = 9550.0
|
||||
|
||||
if deduction < 0:
|
||||
raise UserError('Invalid deduction calculation')
|
||||
|
||||
allowances = 0
|
||||
if filing_status == 'single' or (filing_status == 'married' and spouse_employed):
|
||||
if exemptions == 1:
|
||||
allowances = 2100.0
|
||||
elif exemptions > 1:
|
||||
allowances = 2100.0 + ((exemptions - 1) * 1200.0)
|
||||
elif filing_status == 'married' and not spouse_employed:
|
||||
if exemptions > 0 and exemptions < 3:
|
||||
allowances = 2100.0 * exemptions
|
||||
elif exemptions >= 3:
|
||||
allowances = 2100.0 + 2100.0 + ((exemptions - 2) * 1200.0)
|
||||
else:
|
||||
if exemptions == 1:
|
||||
allowances = 3500.0
|
||||
elif exemptions > 1:
|
||||
allowances = 3500.0 + ((exemptions - 1) * 1200.0)
|
||||
|
||||
federal = categories.FED_INC_WITHHOLD * -1 * PP
|
||||
if filing_status == 'married' and not spouse_employed:
|
||||
federal = min(10000.0, federal)
|
||||
else:
|
||||
federal = min(5000.0, federal)
|
||||
|
||||
mo_taxable_income = gross_salary - deduction - allowances - federal
|
||||
|
||||
remaining_taxable_income = mo_taxable_income
|
||||
tax = 0.0
|
||||
for amt, rate in TAX:
|
||||
rate = rate / 100.0
|
||||
remaining_taxable_income = remaining_taxable_income - amt
|
||||
if remaining_taxable_income > 0.0 or remaining_taxable_income == 0.0:
|
||||
tax += rate * amt
|
||||
else:
|
||||
tax += rate * (remaining_taxable_income + amt)
|
||||
break
|
||||
tax = -tax
|
||||
tax = tax / PP
|
||||
|
||||
# Small GROSS results in an underflow
|
||||
if tax > 0.0:
|
||||
tax = 0.0
|
||||
|
||||
if additional:
|
||||
tax -= additional
|
||||
|
||||
result = round(tax)
|
||||
</field>
|
||||
<field name="register_id" ref="contrib_register_modor_withhold"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
34
l10n_us_mo_hr_payroll/hr_payroll.py
Executable file
34
l10n_us_mo_hr_payroll/hr_payroll.py
Executable file
@@ -0,0 +1,34 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class USMOHrContract(models.Model):
|
||||
_inherit = 'hr.contract'
|
||||
|
||||
mo_mow4_filing_status = fields.Selection([
|
||||
('', 'Exempt'),
|
||||
('single', 'Single'),
|
||||
('married', 'Married'),
|
||||
('head_of_household', 'Head of Household'),
|
||||
], string='Federal W4 Filing Status', default='single')
|
||||
mo_mow4_spouse_employed = fields.Boolean(string='Missouri W-4 Spouse Employed', default=False)
|
||||
mo_mow4_exemptions = fields.Integer(string='Missouri W-4 Exemptions', default=0)
|
||||
mo_mow4_additional_withholding = fields.Float(string="Missouri W-4 Additional Withholding", default=0.0)
|
||||
|
||||
|
||||
@api.multi
|
||||
def mo_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, 'mo_unemp_rate_' + str(year)):
|
||||
return self.employee_id.company_id['mo_unemp_rate_' + str(year)]
|
||||
|
||||
raise NotImplemented('Year (' + str(year) + ') Not implemented for US Missouri.')
|
||||
|
||||
|
||||
class MOCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
# Defaults from :: https://labor.mo.gov/DES/Employers/tax_rates#beginning
|
||||
mo_unemp_rate_2018 = fields.Float(string="Missouri Unemployment Rate 2018", default=2.511)
|
||||
34
l10n_us_mo_hr_payroll/hr_payroll_view.xml
Executable file
34
l10n_us_mo_hr_payroll/hr_payroll_view.xml
Executable file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="us_mo_view_company_form" model="ir.ui.view">
|
||||
<field name="name">res.company.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="priority">64</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="mo_unemp_rate_2018"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
<record id="hr_contract_form_l10n_us_mo_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.contract.form.inherit</field>
|
||||
<field name="model">hr.contract</field>
|
||||
<field name="priority">64</field>
|
||||
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='w4_filing_status']" position="before">
|
||||
<field name="mo_mow4_filing_status"/>
|
||||
<field name="mo_mow4_exemptions"/>
|
||||
<field name="mo_mow4_spouse_employed"/>
|
||||
<field name="mo_mow4_additional_withholding"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
3
l10n_us_mo_hr_payroll/tests/__init__.py
Executable file
3
l10n_us_mo_hr_payroll/tests/__init__.py
Executable file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_us_mo_payslip_2018
|
||||
224
l10n_us_mo_hr_payroll/tests/test_us_mo_payslip_2018.py
Executable file
224
l10n_us_mo_hr_payroll/tests/test_us_mo_payslip_2018.py
Executable file
@@ -0,0 +1,224 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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 TestUsMoPayslip(TestUsPayslip):
|
||||
# Calculations from http://dor.mo.gov/forms/4282_2018.pdf
|
||||
SALARY = 5000.0
|
||||
MO_ALLOWANCES = 3 # Different calculated amounts for different filing statuses
|
||||
|
||||
TAX = [
|
||||
(1028.0, 1.5),
|
||||
(1028.0, 2.0),
|
||||
(1028.0, 2.5),
|
||||
(1028.0, 3.0),
|
||||
(1028.0, 3.5),
|
||||
(1028.0, 4.0),
|
||||
(1028.0, 4.5),
|
||||
(1028.0, 5.0),
|
||||
(1028.0, 5.5),
|
||||
(999999999.0, 5.9),
|
||||
]
|
||||
|
||||
def test_2018_taxes_single(self):
|
||||
# Payroll Period Monthly
|
||||
salary = self.SALARY
|
||||
pp = 12.0
|
||||
gross_salary = salary * pp
|
||||
spouse_employed = False
|
||||
|
||||
# Single
|
||||
standard_deduction = 6500.0
|
||||
mo_allowance_calculated = 2100.0 + 1200.0 + 1200.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
employee.company_id.mo_unemp_rate_2018 = 2.511
|
||||
|
||||
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_mo_hr_payroll.hr_payroll_salary_structure_us_mo_employee'))
|
||||
contract.mo_mow4_spouse_employed = spouse_employed
|
||||
contract.mo_mow4_filing_status = 'single'
|
||||
contract.mo_mow4_exemptions = 3
|
||||
contract.mo_mow4_additional_withholding = 0.0
|
||||
|
||||
# tax rates
|
||||
mo_unemp = contract.mo_unemp_rate(2018) / -100.0
|
||||
|
||||
self._log('2018 Missouri tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['MO_UNEMP_WAGES'], salary)
|
||||
self.assertPayrollEqual(cats['MO_UNEMP'], cats['MO_UNEMP_WAGES'] * mo_unemp)
|
||||
|
||||
US_WITHHOLDING = cats['FED_INC_WITHHOLD']
|
||||
# -693.86
|
||||
self._log(US_WITHHOLDING)
|
||||
us_withholding = -US_WITHHOLDING * pp
|
||||
|
||||
# 5000 for single and married with spouse working, 10000 for married spouse not working
|
||||
us_withholding = min(5000, us_withholding)
|
||||
|
||||
|
||||
mo_taxable_income = gross_salary - standard_deduction - mo_allowance_calculated - us_withholding
|
||||
# 48306.14
|
||||
self._log(mo_taxable_income)
|
||||
|
||||
remaining_taxable_income = mo_taxable_income
|
||||
tax = 0.0
|
||||
for amt, rate in self.TAX:
|
||||
rate = rate / 100.0
|
||||
self._log(str(amt) + ' : ' + str(rate) + ' : ' + str(remaining_taxable_income))
|
||||
remaining_taxable_income = remaining_taxable_income - amt
|
||||
if remaining_taxable_income > 0.0 or remaining_taxable_income == 0.0:
|
||||
tax += rate * amt
|
||||
else:
|
||||
tax += rate * (remaining_taxable_income + amt)
|
||||
break
|
||||
tax = -tax
|
||||
self._log('Computed annual tax: ' + str(tax))
|
||||
|
||||
tax = tax / pp
|
||||
tax = round(tax)
|
||||
self._log('Computed period tax: ' + str(tax))
|
||||
self.assertPayrollEqual(cats['MO_INC_WITHHOLD'], tax)
|
||||
|
||||
def test_2018_spouse_not_employed(self):
|
||||
# Payroll Period Semi-monthly
|
||||
salary = self.SALARY
|
||||
pp = 24.0
|
||||
gross_salary = salary * pp
|
||||
spouse_employed = False
|
||||
|
||||
# Single
|
||||
standard_deduction = 13000.0
|
||||
mo_allowance_calculated = 2100.0 + 2100.0 + 1200.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
|
||||
contract = self._createContract(employee, salary,
|
||||
struct_id=self.ref('l10n_us_mo_hr_payroll.hr_payroll_salary_structure_us_mo_employee'),
|
||||
schedule_pay='semi-monthly')
|
||||
contract.mo_mow4_spouse_employed = spouse_employed
|
||||
contract.mo_mow4_filing_status = 'married'
|
||||
contract.mo_mow4_exemptions = 3
|
||||
contract.mo_mow4_additional_withholding = 0.0
|
||||
|
||||
self._log('2018 Missouri tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
US_WITHHOLDING = cats['FED_INC_WITHHOLD']
|
||||
# -693.86
|
||||
self._log(US_WITHHOLDING)
|
||||
us_withholding = -US_WITHHOLDING * pp
|
||||
|
||||
# 5000 for single and married with spouse working, 10000 for married spouse not working
|
||||
us_withholding = min(10000, us_withholding)
|
||||
|
||||
|
||||
mo_taxable_income = gross_salary - standard_deduction - mo_allowance_calculated - us_withholding
|
||||
# 48306.14
|
||||
self._log(mo_taxable_income)
|
||||
|
||||
remaining_taxable_income = mo_taxable_income
|
||||
tax = 0.0
|
||||
for amt, rate in self.TAX:
|
||||
rate = rate / 100.0
|
||||
self._log(str(amt) + ' : ' + str(rate) + ' : ' + str(remaining_taxable_income))
|
||||
remaining_taxable_income = remaining_taxable_income - amt
|
||||
if remaining_taxable_income > 0.0 or remaining_taxable_income == 0.0:
|
||||
tax += rate * amt
|
||||
else:
|
||||
tax += rate * (remaining_taxable_income + amt)
|
||||
break
|
||||
tax = -tax
|
||||
self._log('Computed annual tax: ' + str(tax))
|
||||
|
||||
tax = tax / pp
|
||||
tax = round(tax)
|
||||
self._log('Computed period tax: ' + str(tax))
|
||||
self.assertPayrollEqual(cats['MO_INC_WITHHOLD'], tax)
|
||||
|
||||
def test_2018_head_of_household(self):
|
||||
# Payroll Period Weekly
|
||||
salary = self.SALARY
|
||||
|
||||
# Payroll Period Weekly
|
||||
salary = self.SALARY
|
||||
pp = 52.0
|
||||
gross_salary = salary * pp
|
||||
spouse_employed = False
|
||||
|
||||
# Single HoH
|
||||
standard_deduction = 9550.0
|
||||
mo_allowance_calculated = 3500.0 + 1200.0 + 1200.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
|
||||
contract = self._createContract(employee, salary,
|
||||
struct_id=self.ref('l10n_us_mo_hr_payroll.hr_payroll_salary_structure_us_mo_employee'),
|
||||
schedule_pay='weekly')
|
||||
contract.mo_mow4_spouse_employed = spouse_employed
|
||||
contract.mo_mow4_filing_status = 'head_of_household'
|
||||
contract.mo_mow4_exemptions = 3
|
||||
contract.mo_mow4_additional_withholding = 0.0
|
||||
|
||||
self._log('2018 Missouri tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
US_WITHHOLDING = cats['FED_INC_WITHHOLD']
|
||||
self._log(US_WITHHOLDING)
|
||||
us_withholding = -US_WITHHOLDING * pp
|
||||
|
||||
# 5000 for single and married with spouse working, 10000 for married spouse not working
|
||||
us_withholding = min(5000, us_withholding)
|
||||
|
||||
|
||||
mo_taxable_income = gross_salary - standard_deduction - mo_allowance_calculated - us_withholding
|
||||
self._log(mo_taxable_income)
|
||||
|
||||
remaining_taxable_income = mo_taxable_income
|
||||
tax = 0.0
|
||||
for amt, rate in self.TAX:
|
||||
rate = rate / 100.0
|
||||
self._log(str(amt) + ' : ' + str(rate) + ' : ' + str(remaining_taxable_income))
|
||||
remaining_taxable_income = remaining_taxable_income - amt
|
||||
if remaining_taxable_income > 0.0 or remaining_taxable_income == 0.0:
|
||||
tax += rate * amt
|
||||
else:
|
||||
tax += rate * (remaining_taxable_income + amt)
|
||||
break
|
||||
tax = -tax
|
||||
self._log('Computed annual tax: ' + str(tax))
|
||||
|
||||
tax = tax / pp
|
||||
tax = round(tax)
|
||||
self._log('Computed period tax: ' + str(tax))
|
||||
self.assertPayrollEqual(cats['MO_INC_WITHHOLD'], tax)
|
||||
|
||||
def test_2018_underflow(self):
|
||||
# Payroll Period Weekly
|
||||
salary = 200.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
|
||||
contract = self._createContract(employee, salary,
|
||||
struct_id=self.ref('l10n_us_mo_hr_payroll.hr_payroll_salary_structure_us_mo_employee'))
|
||||
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
payslip.compute_sheet()
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['MO_INC_WITHHOLD'], 0.0)
|
||||
Reference in New Issue
Block a user