NEW l10n_us_sc_hr_payroll for 11.0

This commit is contained in:
David Frick
2019-07-10 17:45:17 -04:00
parent 097c42fc6b
commit 1d8dfdc3b6
9 changed files with 323 additions and 0 deletions

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,27 @@
{
'name': 'USA - South Carolina - 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::South Carolina Payroll Rules.
==================================
* Added Tax Rules, Salary Structure, and other tax related changes for South Carolina
* Contribution register and partner for South Carolina Department of Revenue
* Contribution register and partner for South Carolina Department of Employment and Workforce
* Rate for Unemployment with wage cap
""",
'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
}

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- CONTRIBUTION REGISTERS -->
<record id="res_partner_scdew_unemp" model="res.partner">
<field name="name">South Carolina Department of Employment and Workforce - Unemployment Tax</field>
<field name="supplier">1</field>
<field eval="0" name="customer"/>
</record>
<record id="res_partner_scdor_withhold" model="res.partner">
<field name="name">South Carolina Department of Revenue - Income Tax Withholding</field>
<field name="supplier">1</field>
<field eval="0" name="customer"/>
</record>
<record id="contrib_register_scdew_unemp" model="hr.contribution.register">
<field name="name">South Carolina Unemployment</field>
<field name="note">South Carolina Department of Employment and Workforce - Unemployment</field>
<field name="partner_id" ref="res_partner_scdew_unemp"/>
</record>
<record id="contrib_register_scdor_withhold" model="hr.contribution.register">
<field name="name">South Carolina Income Tax Withholding</field>
<field name="note">South Carolina Department of Revenue - Income Tax Withholding</field>
<field name="partner_id" ref="res_partner_scdor_withhold"/>
</record>
<!-- HR SALARY RULE CATEGORIES-->
<record id="hr_payroll_sc_unemp_wages" model="hr.salary.rule.category">
<field name="name">Wage: US-SC Unemployment</field>
<field name="code">WAGE_US_SC_UNEMP</field>
</record>
<record id="hr_payroll_sc_unemp" model="hr.salary.rule.category">
<field name="name">ER: US-SC Unemployment</field>
<field name="code">ER_US_SC_UNEMP</field>
<field name="parent_id" ref="hr_payroll.COMP"/>
</record>
<record id="hr_payroll_sc_income_withhold" model="hr.salary.rule.category">
<field name="name">EE: US-SC Income Tax Withholding</field>
<field name="code">EE_US_SC_INC_WITHHOLD</field>
<field name="parent_id" ref="hr_payroll.DED"/>
</record>
</odoo>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- HR PAYROLL STRUCTURE -->
<record id="hr_payroll_salary_structure_us_sc_employee" model="hr.payroll.structure">
<field name="code">US_SC_EMP</field>
<field name="name">USA South Carolina Employee</field>
<field eval="[(6, 0, [
ref('hr_payroll_rules_sc_unemp_wages'),
ref('hr_payroll_rules_sc_unemp'),
ref('hr_payroll_rules_sc_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>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="hr_payroll_rates_sc_unemp" model="hr.payroll.rate">
<field name="name">US SS Unemployment</field>
<field name="code">US_SC_UNEMP</field>
<field name="rate">1.09</field>
<field name="date_from">2019-01-01</field>
<field name="wage_limit_year" eval="14000.0"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- HR SALARY RULES-->
<record id="hr_payroll_rules_sc_unemp_wages" model="hr.salary.rule">
<field name="sequence" eval="507"/>
<field name="category_id" ref="hr_payroll_sc_unemp_wages"/>
<field name="name">Wage: US-SC Unemployment</field>
<field name="code">WAGE_US_SC_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_SC_UNEMP')
year = int(payslip.dict.date_to[:4])
ytd = payslip.sum('WAGE_US_SC_UNEMP', str(year) + '-01-01', str(year+1) + '-01-01')
ytd += contract.external_wages
remaining = rate.wage_limit_year - ytd
if remaining &lt;= 0.0:
result = 0
elif remaining &lt; categories.BASIC:
result = remaining
else:
result = categories.BASIC
</field>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_sc_unemp" model="hr.salary.rule">
<field name="sequence" eval="522"/>
<field name="category_id" ref="hr_payroll_sc_unemp"/>
<field name="name">ER: US-SC Unemployment</field>
<field name="code">ER_US_SC_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_SC_UNEMP')
result_rate = -rate.rate
result = categories.WAGE_US_SC_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_scdew_unemp"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_sc_inc_withhold" model="hr.salary.rule">
<field name="sequence" eval="190"/>
<field name="category_id" ref="hr_payroll_sc_income_withhold"/>
<field name="name">EE: US-SC Income Tax Withholding</field>
<field name="code">EE_US_SC_INC_WITHHOLD</field>
<field name="condition_select">python</field>
<field name="condition_python">result = True</field>
<field name="amount_select">code</field>
<field name="amount_python_compute">
result = categories.EE_US_FED_INC_WITHHOLD
</field>
<field name="register_id" ref="contrib_register_scdor_withhold"/>
</record>
</odoo>

View File

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

View File

@@ -0,0 +1,135 @@
from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip
from odoo.addons.l10n_us_hr_payroll.models.l10n_us_hr_payroll import USHrContract
class TestUsSCPayslip(TestUsPayslip):
###
# Taxes and Rates
###
SC_UNEMP_MAX_WAGE = 14000.0
US_SC_UNEMP = -1.09 / 100
def test_2019_taxes(self):
salary = 10000
exemptions = 2
employee = self._createEmployee()
contract = self._createContract(employee, salary,
struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee'))
contract.w4_allowances = exemptions
self._log('2019 South Carolina tax first payslip:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP)
self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD'])
process_payslip(payslip)
remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2*salary < salary) \
else salary
# Testing Additional Income Tax Withholding
self._log('2019 South Carolina tax second payslip:')
additional_wh = 40.0
contract.w4_additional_withholding = additional_wh
original_witholding = cats['EE_US_SC_INC_WITHHOLD']
payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP)
self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], original_witholding - additional_wh)
def test_2019_taxes_with_external(self):
salary = 5000.0
external_wages = 30000.0
employee = self._createEmployee()
contract = self._createContract(employee, salary, external_wages=external_wages,
struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee'))
self._log('2019 South Carolina_external tax first payslip:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], 0)
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP)
def test_2019_taxes_filing_status(self):
salary = 4000.0
w4_filing_status = 'married'
allowances = 1
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee'))
contract.w4_allowances = allowances
contract.w4_filing_status = w4_filing_status
self._log('2019 South Carolina tax first payslip: ')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP)
self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD'])
process_payslip(payslip)
# Create a 2nd payslip
remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2*salary < salary) \
else salary
self._log('2019 South Carolina tax second payslip:')
payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP)
def test_additional_withholding(self):
salary = 4000.0
additional_wh = 40.0
allowances = 1
employee = self._createEmployee()
contract = self._createContract(employee,
salary,
struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee')
)
contract.w4_addition_withholding = additional_wh
contract.w4_allowances = allowances
self._log('2019 South Carolina tax first payslip: ')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP)
self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], cats['EE_US_FED_INC_WITHHOLD'])
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (self.SC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2019 South Carolina tax second payslip weekly:')
payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_SC_UNEMP'], remaining_SC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP)

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hr_contract_form_l10n_us_sc_inherit" model="ir.ui.view">
<field name="name">hr.contract.form.inherit</field>
<field name="model">hr.contract</field>
<field name="priority">151</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="South Carolina" name="sc">
<p>No additional fields.</p>
</group>
</xpath>
</data>
</field>
</record>
</odoo>