mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Merge branch 'new/11.0/l10n_us_sc_hr_payroll' into 11.0
This commit is contained in:
1
l10n_us_sc_hr_payroll/__init__.py
Normal file
1
l10n_us_sc_hr_payroll/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
27
l10n_us_sc_hr_payroll/__manifest__.py
Normal file
27
l10n_us_sc_hr_payroll/__manifest__.py
Normal 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
|
||||
}
|
||||
45
l10n_us_sc_hr_payroll/data/base.xml
Normal file
45
l10n_us_sc_hr_payroll/data/base.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- CONTRIBUTION REGISTERS -->
|
||||
<record id="res_partner_sc_dew_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_sc_dor_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_sc_dew_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_sc_dew_unemp"/>
|
||||
</record>
|
||||
<record id="contrib_register_sc_dor_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_sc_dor_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>
|
||||
17
l10n_us_sc_hr_payroll/data/final.xml
Normal file
17
l10n_us_sc_hr_payroll/data/final.xml
Normal 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>
|
||||
12
l10n_us_sc_hr_payroll/data/rates.xml
Normal file
12
l10n_us_sc_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_sc_unemp" model="hr.payroll.rate">
|
||||
<field name="name">US SC 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>
|
||||
110
l10n_us_sc_hr_payroll/data/rules.xml
Normal file
110
l10n_us_sc_hr_payroll/data/rules.xml
Normal file
@@ -0,0 +1,110 @@
|
||||
<?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 <= 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_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_sc_dew_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">
|
||||
wages = categories.GROSS # Must make sure sequence is after the GROSS sequence.
|
||||
# Step 1 - Convert wages to annual amount
|
||||
pay_period = 0.0
|
||||
pay_periods = {
|
||||
'weekly': 52.0,
|
||||
'bi-weekly': 26.0,
|
||||
'semi-monthly': 24.0,
|
||||
'monthly': 12.0
|
||||
}
|
||||
schedule_pay = contract.schedule_pay
|
||||
pay_period = pay_periods[schedule_pay]
|
||||
annual_wages = wages * pay_period
|
||||
|
||||
# Step 2 - Deduct the personal exemption amount and standard deduction from the annual wages.
|
||||
sc_exemption_amount = 2510.00
|
||||
personal_exemption_amt = contract.w4_allowances * sc_exemption_amount
|
||||
standard_deduction = 0.00
|
||||
if contract.w4_allowances > 0:
|
||||
if (annual_wages * .1) > 3470.00:
|
||||
standard_deduction = 3470.00
|
||||
else:
|
||||
standard_deduction = (10.0 / 100.0) * annual_wages
|
||||
taxable_income = annual_wages - personal_exemption_amt - standard_deduction
|
||||
|
||||
# Step 3 - Use the balance (taxable_income) in the tables listed on the state pdf:
|
||||
# https://dor.sc.gov/forms-site/Forms/WH1603F_2019.pdf
|
||||
# to calculate the tax.
|
||||
|
||||
tax_table = [
|
||||
(2450, 1.1, 0.0),
|
||||
(4900, 3.0, 26.95),
|
||||
(7350, 4.0, 100.45),
|
||||
(9800, 5.0, 198.45),
|
||||
(12250, 6.0, 320.95),
|
||||
(float('inf'), 7.0, 467.95)
|
||||
]
|
||||
last = 0.0
|
||||
for cap, rate, flat_amt in tax_table:
|
||||
if cap > taxable_income:
|
||||
result = ((taxable_income - last) * (rate / 100.0)) + flat_amt
|
||||
break
|
||||
last = cap
|
||||
|
||||
# Step 4 - Divide the result by the number of pay periods to get withholding amount per pay period
|
||||
result = (result / pay_period)
|
||||
|
||||
result = -result
|
||||
</field>
|
||||
<field name="register_id" ref="contrib_register_sc_dor_withhold"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
1
l10n_us_sc_hr_payroll/tests/__init__.py
Normal file
1
l10n_us_sc_hr_payroll/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_us_sc_payslip_2019
|
||||
128
l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py
Normal file
128
l10n_us_sc_hr_payroll/tests/test_us_sc_payslip_2019.py
Normal file
@@ -0,0 +1,128 @@
|
||||
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
|
||||
US_SC_exemption_amount = 2510.00
|
||||
|
||||
def test_2019_taxes_weekly(self):
|
||||
# We will hand calculate the amount to test for state withholding.
|
||||
schedule_pay = 'weekly'
|
||||
salary = 50000.00 # Employee is paid 50000 per week to be in top tax bracket
|
||||
exemptions = 2
|
||||
# Calculate annual wages
|
||||
annual = 50000 * 52.0
|
||||
# From our annual we deduct personal exemption amounts.
|
||||
# We deduct 2510.00 per exemption. Since we have two exemptions:
|
||||
personal_exemption = self.US_SC_exemption_amount * exemptions # 5020.0
|
||||
# From annual, we will also deduct a standard_deduction of 3470.00 or .1 of salary, which ever
|
||||
# is small -> if 1 or more exemptions, else 0
|
||||
standard_deduction = 3470.00
|
||||
taxable_income = annual - personal_exemption - standard_deduction # 2591478.0
|
||||
# We then calculate the amounts off the SC tax pdf tables.
|
||||
# 2591478.0 is in the highest bracket
|
||||
test_amt = ((taxable_income - 12250) * (7.0 / 100.0)) + 467.95
|
||||
# test_amt = 181013.91000000003
|
||||
# Make it per period then negative
|
||||
test_amt = (test_amt / 52.0) # Divided by 52 since it is weekly.
|
||||
# test_amt = 3481.0367307692313
|
||||
test_amt = -test_amt
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee,
|
||||
salary,
|
||||
struct_id=self.ref('l10n_us_sc_hr_payroll.hr_payroll_salary_structure_us_sc_employee'),
|
||||
schedule_pay=schedule_pay)
|
||||
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'], self.SC_UNEMP_MAX_WAGE)
|
||||
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], test_amt)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - annual if (annual < self.SC_UNEMP_MAX_WAGE) \
|
||||
else 0.00
|
||||
|
||||
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.assertEqual(0.0, remaining_SC_UNEMP_wages)
|
||||
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP)
|
||||
|
||||
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 = 20000.00 # Wages per pay period
|
||||
schedule_pay = 'monthly'
|
||||
annual = salary * 12
|
||||
w4_filing_status = 'married'
|
||||
allowances = 1
|
||||
# Hand Calculations
|
||||
personal_exemption = 2510.00
|
||||
standard_deduction = min(3470.00, .1 * annual) # 3470.0 but min is shown for the process
|
||||
taxable = annual - personal_exemption - standard_deduction
|
||||
# taxable = 234020
|
||||
test_amt = ((taxable - 12250) * (7.0 / 100.0)) + 467.95 # 15991.850000000002
|
||||
test_amt = test_amt / 12.0 # Put it into monthly -> 1332.654166666667
|
||||
# Make it negative
|
||||
test_amt = -test_amt
|
||||
|
||||
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'], self.SC_UNEMP_MAX_WAGE)
|
||||
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], cats['WAGE_US_SC_UNEMP'] * self.US_SC_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_SC_INC_WITHHOLD'], test_amt)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
# Create a 2nd payslip
|
||||
remaining_SC_UNEMP_wages = self.SC_UNEMP_MAX_WAGE - salary if (salary < self.SC_UNEMP_MAX_WAGE) \
|
||||
else 0.00
|
||||
|
||||
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.assertEqual(0.0, remaining_SC_UNEMP_wages)
|
||||
self.assertPayrollEqual(cats['ER_US_SC_UNEMP'], remaining_SC_UNEMP_wages * self.US_SC_UNEMP)
|
||||
|
||||
21
l10n_us_sc_hr_payroll/views/hr_payroll_views.xml
Normal file
21
l10n_us_sc_hr_payroll/views/hr_payroll_views.xml
Normal 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>
|
||||
|
||||
Reference in New Issue
Block a user