Initial commit of l10n_us_tx_hr_payroll for 11.0.

This commit is contained in:
Kristen Marie Kulha
2018-05-22 13:11:55 -07:00
committed by Jared Kipe
parent d44f03618f
commit 79b0537e7b
9 changed files with 431 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import us_tx_hr_payroll

View File

@@ -0,0 +1,29 @@
# -*- encoding: utf-8 -*-
{
'name': 'USA - Texas - 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::Texas Payroll Rules.
=========================
* Texas Workforce Commission partner
* Contribution register for Texas Workforce Commission
* Company level Texas Umemployment Rate
* Company level Texas Obligation Assessment Rate
* Company level Texas Employment & Training Investment Assessment
""",
'auto_install': False,
'website': 'https://hibou.io/',
'data':[
'us_tx_hr_payroll_view.xml',
'data/base.xml',
'data/rules_2018.xml',
'data/final.xml',
],
'installable': True
}

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- CONTRIBUTION REGISTERS -->
<record id="res_partner_txdor" model="res.partner">
<field name="name">Texas Workforce Commission</field>
<field name="supplier">1</field>
<field eval="0" name="customer"/>
</record>
<record id="contrib_register_txdor" model="hr.contribution.register">
<field name="name">Texas Unemployment</field>
<field name="note">Texas Workforce Commission - Unemployment</field>
<field name="partner_id" ref="res_partner_txdor"/>
</record>
<record id="contrib_register_txdor" model="hr.contribution.register">
<field name="name">Texas Obligation Assessment</field>
<field name="note">Texas Workforce Commission - Obligation Assessment</field>
<field name="partner_id" ref="res_partner_txdor"/>
</record>
<record id="contrib_register_txdor" model="hr.contribution.register">
<field name="name">Texas Employment and Training Investment Assessment</field>
<field name="note">Texas Workforce Commission - Employment and Trainging Investment Assessment</field>
<field name="partner_id" ref="res_partner_txdor"/>
</record>
<!-- HR SALARY RULE CATEGORIES-->
<record id="hr_payroll_tx_unemp_wages" model="hr.salary.rule.category">
<field name="name">Texas Unemployment - Wages</field>
<field name="code">TX_UNEMP_WAGES</field>
</record>
<record id="hr_payroll_tx_unemp" model="hr.salary.rule.category">
<field name="name">Texas Unemployment</field>
<field name="code">TX_UNEMP</field>
<field name="parent_id" ref="hr_payroll.COMP"/>
</record>
<record id="hr_payroll_tx_oa" model="hr.salary.rule.category">
<field name="name">Texas Obligation Assessment</field>
<field name="code">TX_OA</field>
<field name="parent_id" ref="hr_payroll.COMP"/>
</record>
<record id="hr_payroll_tx_etia" model="hr.salary.rule.category">
<field name="name">Texas Employment and Training Investment Assessment</field>
<field name="code">TX_ETIA</field>
<field name="parent_id" ref="hr_payroll.COMP"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR PAYROLL STRUCTURE -->
<record id="hr_payroll_salary_structure_us_tx_employee" model="hr.payroll.structure">
<field name="code">US_TX_EMP</field>
<field name="name">USA Texas Employee</field>
<field eval="[(6, 0, [
ref('hr_payroll_rules_tx_unemp_wages_2018'),
ref('hr_payroll_rules_tx_unemp_2018'),
ref('hr_payroll_rules_tx_oa_2018'),
ref('hr_payroll_rules_tx_etia_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>

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR SALARY RULES-->
<record id="hr_payroll_rules_tx_unemp_wages_2018" model="hr.salary.rule">
<field name="sequence" eval="423"/>
<field name="category_id" ref="hr_payroll_tx_unemp_wages"/>
<field name="name">Texas Unemployment - Wages (2018)</field>
<field name="code">TX_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('TX_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01')
ytd += contract.external_wages
remaining = 9000.0 - ytd
if remaining &lt;= 0.0:
result = 0
elif remaining &lt; categories.GROSS:
result = remaining
else:
result = categories.GROSS
</field>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_tx_unemp_2018" model="hr.salary.rule">
<field name="sequence" eval="443"/>
<field name="category_id" ref="hr_payroll_tx_unemp"/>
<field name="name">Texas Unemployment (2018)</field>
<field name="code">TX_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.tx_unemp_rate(2018)
result = categories.TX_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_txdor"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_tx_oa_2018" model="hr.salary.rule">
<field name="sequence" eval="443"/>
<field name="category_id" ref="hr_payroll_tx_oa"/>
<field name="name">Texas Obligation Assessment (2018)</field>
<field name="code">TX_OA_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.tx_oa_rate(2018)
result = categories.TX_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_txdor"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_tx_etia_2018" model="hr.salary.rule">
<field name="sequence" eval="443"/>
<field name="category_id" ref="hr_payroll_tx_etia"/>
<field name="name">Texas Employment and Training Investment Assessment (2018)</field>
<field name="code">TX_ETIA_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.tx_etia_rate(2018)
result = categories.TX_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_txdor"/>
<field name="appears_on_payslip" eval="False"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1 @@
from . import test_us_tx_payslip_2018

View File

@@ -0,0 +1,161 @@
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 TestUsTXPayslip(TestUsPayslip):
###
# 2018 Taxes and Rates
###
TX_UNEMP_MAX_WAGE = 9000.0
def test_2018_taxes(self):
salary = 5000.0
employee = self._createEmployee()
employee.company_id.tx_unemp_rate_2018 = 2.7
employee.company_id.tx_oa_rate_2018 = 0.0
employee.company_id.tx_etia_rate_2018 = 0.1
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_tx_hr_payroll.hr_payroll_salary_structure_us_tx_employee'))
# tax rates
tx_unemp = contract.tx_unemp_rate(2018) / -100.0
tx_oa = contract.tx_oa_rate(2018) / -100.00
tx_etia = contract.tx_etia_rate(2018) / -100.00
self._log('2018 Texas tax first payslip:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['TX_UNEMP_WAGES'], salary)
self.assertPayrollEqual(cats['TX_UNEMP'], cats['TX_UNEMP_WAGES'] * tx_unemp)
self.assertPayrollEqual(cats['TX_OA'], cats['TX_UNEMP_WAGES'] * tx_oa)
self.assertPayrollEqual(cats['TX_ETIA'], cats['TX_UNEMP_WAGES'] * tx_etia)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_tx_unemp_wages = self.TX_UNEMP_MAX_WAGE - salary if (self.TX_UNEMP_MAX_WAGE - 2*salary < salary) \
else salary
self._log('2018 Texas tax second payslip:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['TX_UNEMP_WAGES'], remaining_tx_unemp_wages)
self.assertPayrollEqual(cats['TX_UNEMP'], remaining_tx_unemp_wages * tx_unemp)
def test_2018_taxes_with_external(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.tx_unemp_rate_2018 = 2.7
employee.company_id.tx_oa_rate_2018 = 0.0
employee.company_id.tx_etia_rate_2018 = 0.1
contract = self._createContract(employee, salary, external_wages=external_wages,
struct_id=self.ref('l10n_us_tx_hr_payroll.hr_payroll_salary_structure_us_tx_employee'))
# tax rates
tx_unemp = contract.tx_unemp_rate(2018) / -100.0
tx_oa = contract.tx_oa_rate(2018) / -100.00
tx_etia = contract.tx_etia_rate(2018) / -100.00
self._log('2018 Texas_external tax first payslip:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['TX_UNEMP_WAGES'], self.TX_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['TX_UNEMP'], cats['TX_UNEMP_WAGES'] * tx_unemp)
self.assertPayrollEqual(cats['TX_OA'], cats['TX_UNEMP_WAGES'] * tx_oa)
self.assertPayrollEqual(cats['TX_ETIA'], cats['TX_UNEMP_WAGES'] * tx_etia)
def test_2018_taxes_with_state_exempt(self):
salary = 5000.0
external_wages = 6000.0
employee = self._createEmployee()
employee.company_id.tx_unemp_rate_2018 = 2.7
employee.company_id.tx_oa_rate_2018 = 0.0
employee.company_id.tx_etia_rate_2018 = 0.1
contract = self._createContract(employee, salary, external_wages=external_wages, struct_id=self.ref(
'l10n_us_tx_hr_payroll.hr_payroll_salary_structure_us_tx_employee'), futa_type=USHrContract.FUTA_TYPE_BASIC)
# tax rates
tx_unemp = contract.tx_unemp_rate(2018) / -100.0
tx_oa = contract.tx_oa_rate(2018) / -100.00
tx_etia = contract.tx_etia_rate(2018) / -100.00
self.assertPayrollEqual(tx_unemp, 0.0)
self._log('2018 Texas_external tax first payslip:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['TX_UNEMP_WAGES'], self.TX_UNEMP_MAX_WAGE - external_wages)
self.assertPayrollEqual(cats['TX_UNEMP'], cats['TX_UNEMP_WAGES'] * tx_unemp)
self.assertPayrollEqual(cats['TX_OA'], cats['TX_UNEMP_WAGES'] * tx_oa)
self.assertPayrollEqual(cats['TX_ETIA'], cats['TX_UNEMP_WAGES'] * tx_etia)
def test_payslip_example(self):
salary = 2916.67
employee = self._createEmployee()
employee.company_id.tx_unemp_rate_2018 = 2.7
employee.company_id.tx_oa_rate_2018 = 0.0
employee.company_id.tx_etia_rate_2018 = 0.1
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_tx_hr_payroll.hr_payroll_salary_structure_us_tx_employee'))
contract.w4_allowances = 2
contract.w4_filing_status = 'single'
# tax rates
tx_unemp = contract.tx_unemp_rate(2018) / -100.0
tx_oa = contract.tx_oa_rate(2018) / -100.00
tx_etia = contract.tx_etia_rate(2018) / -100.00
self._log('2018 Texas tax first payslip:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['TX_UNEMP_WAGES'], salary)
self.assertPayrollEqual(cats['TX_UNEMP'], cats['TX_UNEMP_WAGES'] * tx_unemp)
self.assertPayrollEqual(cats['TX_OA'], cats['TX_UNEMP_WAGES'] * tx_oa)
self.assertPayrollEqual(cats['TX_ETIA'], cats['TX_UNEMP_WAGES'] * tx_etia)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_tx_unemp_wages = self.TX_UNEMP_MAX_WAGE - salary if (self.TX_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2018 Texas tax second payslip:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['TX_UNEMP_WAGES'], remaining_tx_unemp_wages)
self.assertPayrollEqual(cats['TX_UNEMP'], remaining_tx_unemp_wages * tx_unemp)

View File

@@ -0,0 +1,44 @@
from odoo import models, fields, api
class USTXHrContract(models.Model):
_inherit = 'hr.contract'
@api.multi
def tx_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, 'tx_unemp_rate_' + str(year)):
return self.employee_id.company_id['tx_unemp_rate_' + str(year)]
raise NotImplemented('Year (' + str(year) + ') Not implemented for US Texas.')
def tx_oa_rate(self, year):
self.ensure_one()
if self.futa_type == self.FUTA_TYPE_BASIC:
return 0.0
if hasattr(self.employee_id.company_id, 'tx_oa_rate_' + str(year)):
return self.employee_id.company_id['tx_oa_rate_' + str(year)]
raise NotImplemented('Year (' + str(year) + ') Not implemented for US Texas.')
def tx_etia_rate(self, year):
self.ensure_one()
if self.futa_type == self.FUTA_TYPE_BASIC:
return 0.0
if hasattr(self.employee_id.company_id, 'tx_etia_rate_' + str(year)):
return self.employee_id.company_id['tx_etia_rate_' + str(year)]
raise NotImplemented('Year (' + str(year) + ') Not implemented for US Texas.')
class TXCompany(models.Model):
_inherit = 'res.company'
tx_unemp_rate_2018 = fields.Float(string="Texas Unemployment Rate 2018", default=2.7)
tx_oa_rate_2018 = fields.Float(strimg="Texas Obligation Assessment Rate 2018", default=0.0)
tx_etia_rate_2018 = fields.Float(string="Texas Employment & Training Investment Assessment Rate", default=0.1)

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="us_tx_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="tx_unemp_rate_2018"/>
<field name="tx_oa_rate_2018"/>
<field name="tx_etia_rate_2018"/>
</xpath>
</data>
</field>
</record>
<record id="hr_contract_form_l10n_us_tx_inherit" model="ir.ui.view">
<field name="name">hr.contract.form.inherit</field>
<field name="model">hr.contract</field>
<field name="priority">110</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="Texas" name="tx">
<p>No additional fields.</p>
</group>
</xpath>
</data>
</field>
</record>
</data>
</odoo>