diff --git a/l10n_us_tx_hr_payroll/__init__.py b/l10n_us_tx_hr_payroll/__init__.py new file mode 100755 index 00000000..1bbfd266 --- /dev/null +++ b/l10n_us_tx_hr_payroll/__init__.py @@ -0,0 +1 @@ +from . import us_tx_hr_payroll diff --git a/l10n_us_tx_hr_payroll/__manifest__.py b/l10n_us_tx_hr_payroll/__manifest__.py new file mode 100755 index 00000000..875e7d87 --- /dev/null +++ b/l10n_us_tx_hr_payroll/__manifest__.py @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +{ + 'name': 'USA - Texas - Payroll', + 'author': 'Hibou Corp. ', + '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 +} diff --git a/l10n_us_tx_hr_payroll/data/base.xml b/l10n_us_tx_hr_payroll/data/base.xml new file mode 100755 index 00000000..58aca4aa --- /dev/null +++ b/l10n_us_tx_hr_payroll/data/base.xml @@ -0,0 +1,53 @@ + + + + + + + Texas Workforce Commission + 1 + + + + Texas Unemployment + Texas Workforce Commission - Unemployment + + + + Texas Obligation Assessment + Texas Workforce Commission - Obligation Assessment + + + + Texas Employment and Training Investment Assessment + Texas Workforce Commission - Employment and Trainging Investment Assessment + + + + + + + Texas Unemployment - Wages + TX_UNEMP_WAGES + + + + Texas Unemployment + TX_UNEMP + + + + + Texas Obligation Assessment + TX_OA + + + + + Texas Employment and Training Investment Assessment + TX_ETIA + + + + + diff --git a/l10n_us_tx_hr_payroll/data/final.xml b/l10n_us_tx_hr_payroll/data/final.xml new file mode 100755 index 00000000..82997a70 --- /dev/null +++ b/l10n_us_tx_hr_payroll/data/final.xml @@ -0,0 +1,20 @@ + + + + + + + US_TX_EMP + USA Texas Employee + + + + + + + diff --git a/l10n_us_tx_hr_payroll/data/rules_2018.xml b/l10n_us_tx_hr_payroll/data/rules_2018.xml new file mode 100755 index 00000000..551f7426 --- /dev/null +++ b/l10n_us_tx_hr_payroll/data/rules_2018.xml @@ -0,0 +1,87 @@ + + + + + + + + + Texas Unemployment - Wages (2018) + TX_UNEMP_WAGES_2018 + python + result = (payslip.date_to[:4] == '2018') + code + +### +ytd = payslip.sum('TX_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01') +ytd += contract.external_wages +remaining = 9000.0 - ytd +if remaining <= 0.0: + result = 0 +elif remaining < categories.GROSS: + result = remaining +else: + result = categories.GROSS + + + + + + + Texas Unemployment (2018) + TX_UNEMP_2018 + python + result = (payslip.date_to[:4] == '2018') + code + +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 + + + + + + + + Texas Obligation Assessment (2018) + TX_OA_2018 + python + result = (payslip.date_to[:4] == '2018') + code + +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 + + + + + + + + Texas Employment and Training Investment Assessment (2018) + TX_ETIA_2018 + python + result = (payslip.date_to[:4] == '2018') + code + +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 + + + + + + + diff --git a/l10n_us_tx_hr_payroll/tests/__init__.py b/l10n_us_tx_hr_payroll/tests/__init__.py new file mode 100755 index 00000000..a174888c --- /dev/null +++ b/l10n_us_tx_hr_payroll/tests/__init__.py @@ -0,0 +1 @@ +from . import test_us_tx_payslip_2018 diff --git a/l10n_us_tx_hr_payroll/tests/test_us_tx_payslip_2018.py b/l10n_us_tx_hr_payroll/tests/test_us_tx_payslip_2018.py new file mode 100755 index 00000000..9701b517 --- /dev/null +++ b/l10n_us_tx_hr_payroll/tests/test_us_tx_payslip_2018.py @@ -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) + diff --git a/l10n_us_tx_hr_payroll/us_tx_hr_payroll.py b/l10n_us_tx_hr_payroll/us_tx_hr_payroll.py new file mode 100755 index 00000000..e27219c0 --- /dev/null +++ b/l10n_us_tx_hr_payroll/us_tx_hr_payroll.py @@ -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) diff --git a/l10n_us_tx_hr_payroll/us_tx_hr_payroll_view.xml b/l10n_us_tx_hr_payroll/us_tx_hr_payroll_view.xml new file mode 100755 index 00000000..6481f458 --- /dev/null +++ b/l10n_us_tx_hr_payroll/us_tx_hr_payroll_view.xml @@ -0,0 +1,35 @@ + + + + + res.company.form + res.company + 20 + + + + + + + + + + + + + hr.contract.form.inherit + hr.contract + 110 + + + + + +

No additional fields.

+
+
+
+
+
+
+