#31 Merge branch 'mig/12.0/l10n_us_nc_hr_payroll' into mig/12.0/us_payroll

This commit is contained in:
Jared Kipe
2019-02-10 15:52:19 -08:00
13 changed files with 1107 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
*****************************************
Hibou - US Payroll - North Carolina State
*****************************************
Calculations and contribution registers for North Carolina State Payroll.
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
=============
Main Features
=============
* Contribution registers and partners for:
* North Carolina Department of Revenue - Income Tax withholding
* North Carolina Department of Taxation - Unemployment
* Contract level North Carolina Exemptions
* Company level North Carolina Unemployment Rate
.. image:: https://user-images.githubusercontent.com/15882954/41436210-cb7f6a52-6fd5-11e8-9095-48799360f4e9.png
:alt: 'Employee Contract Detail'
:width: 988
:align: left
USA North Carolina Employee added to Contract Salary Structure menu
.. image:: https://user-images.githubusercontent.com/15882954/41436282-fcfd3096-6fd5-11e8-8bc8-3c4985908b23.png
:alt: 'Computed Pay Slip Detail'
:width: 988
:align: left
New Payslip Categories for:
* North Carolina Income Withholding
* North Carolina Unemployment - Wages
* North Carolina Unemployment.
=======
License
=======
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/master/LICENSE>`_.
Copyright Hibou Corp. 2018

View File

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

View File

@@ -0,0 +1,28 @@
{
'name': 'USA - North Carolina - Payroll',
'author': 'Hibou Corp. <hello@hibou.io>',
'license': 'AGPL-3',
'category': 'Localization',
'depends': ['l10n_us_hr_payroll'],
'version': '12.0.2019.0.0',
'description': """
USA::North Carolina Payroll Rules.
==================================
* Contribution register and partner for North Carolina Department of Taxaction - Unemployment
* Contribution register and partner for North Carolina Department of Taxaction - Income Tax Withholding
* Contract level North Carolina Exemptions
* Company level North Carolina Unemployment Rate
""",
'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,46 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- CONTRIBUTION REGISTERS -->
<record id="res_partner_ncdor_unemp" model="res.partner">
<field name="name">North Carolina Division of Unemployment Security - Unemployment Tax</field>
<field name="supplier">1</field>
<field eval="0" name="customer"/>
</record>
<record id="res_partner_ncdor_withhold" model="res.partner">
<field name="name">North Carolina Department of Revenue - Income Tax Withholding</field>
<field name="supplier">1</field>
<field eval="0" name="customer"/>
</record>
<record id="contrib_register_ncdor_unemp" model="hr.contribution.register">
<field name="name">North Carolina Unemployment</field>
<field name="note">North Carolina Division of Unemployment Security - Unemployment</field>
<field name="partner_id" ref="res_partner_ncdor_unemp"/>
</record>
<record id="contrib_register_ncdor_withhold" model="hr.contribution.register">
<field name="name">North Carolina Income Tax Withholding</field>
<field name="note">North Carolina Department of Revenue - Income Tax Withholding</field>
<field name="partner_id" ref="res_partner_ncdor_withhold"/>
</record>
<!-- HR SALARY RULE CATEGORIES-->
<record id="hr_payroll_nc_unemp_wages" model="hr.salary.rule.category">
<field name="name">Wage: US-NC Unemployment</field>
<field name="code">WAGE_US_NC_UNEMP</field>
</record>
<record id="hr_payroll_nc_unemp" model="hr.salary.rule.category">
<field name="name">ER: US-NC Unemployment</field>
<field name="code">ER_US_NC_UNEMP</field>
<field name="parent_id" ref="hr_payroll.COMP"/>
</record>
<record id="hr_payroll_nc_income_withhold" model="hr.salary.rule.category">
<field name="name">EE: US-NC Income Tax Withholding</field>
<field name="code">EE_US_NC_INC_WITHHOLD</field>
<field name="parent_id" ref="hr_payroll.DED"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR PAYROLL STRUCTURE -->
<record id="hr_payroll_salary_structure_us_nc_employee" model="hr.payroll.structure">
<field name="code">US_NC_EMP</field>
<field name="name">USA North Carolina Employee</field>
<field eval="[(6, 0, [
ref('hr_payroll_rules_nc_unemp_wages_2018'),
ref('hr_payroll_rules_nc_unemp_2018'),
ref('hr_payroll_rules_nc_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>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="hr_payroll_rates_nc_unemp_2018" model="hr.payroll.rate">
<field name="name">US NC Unemployment</field>
<field name="code">US_NC_UNEMP</field>
<field name="rate">0.6</field>
<field name="date_from">2018-01-01</field>
<field name="wage_limit_year" eval="23500.0"/>
</record>
<record id="hr_payroll_rates_nc_unemp_2019" model="hr.payroll.rate">
<field name="name">US NC Unemployment</field>
<field name="code">US_NC_UNEMP</field>
<field name="rate">1.0</field>
<field name="date_from">2019-01-01</field>
<field name="wage_limit_year" eval="24300.0"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- HR SALARY RULES-->
<record id="hr_payroll_rules_nc_unemp_wages_2018" model="hr.salary.rule">
<field name="sequence" eval="423"/>
<field name="category_id" ref="hr_payroll_nc_unemp_wages"/>
<field name="name">Wage: US-NC Unemployment</field>
<field name="code">WAGE_US_NC_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_NC_UNEMP')
year = payslip.dict.date_to.year
ytd = payslip.sum('NC_UNEMP_WAGES_2018', 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_nc_unemp_2018" model="hr.salary.rule">
<field name="sequence" eval="443"/>
<field name="category_id" ref="hr_payroll_nc_unemp"/>
<field name="name">ER: US-NC Unemployment</field>
<field name="code">ER_US_NC_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_NC_UNEMP')
result_rate = -rate.rate
result = categories.WAGE_US_NC_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_ncdor_unemp"/>
<field name="appears_on_payslip" eval="False"/>
</record>
<record id="hr_payroll_rules_nc_inc_withhold_2018" model="hr.salary.rule">
<field name="sequence" eval="155"/>
<field name="category_id" ref="hr_payroll_nc_income_withhold"/>
<field name="name">EE: US-NC Income Tax Withholding</field>
<field name="code">EE_US_NC_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">
year = payslip.dict.date_to.year
wages = categories.GROSS
allowances = contract.nc_nc4_allowances
schedule_pay = contract.schedule_pay
val = 0.00
# PST -> Portion of standard deduction
if year == 2018:
PST = 0.0
allowance_multiplier = 0.0
if 'weekly' == schedule_pay:
allowance_multiplier = 48.08
if contract.nc_nc4_filing_status == 'head_household':
PST = 269.23
else:
PST = 168.27
elif 'bi-weekly' == schedule_pay:
allowance_multiplier = 96.15
if contract.nc_nc4_filing_status == 'head_household':
PST = 538.46
else:
PST = 336.54
elif 'semi-monthly' == schedule_pay:
allowance_multiplier = 104.17
if contract.nc_nc4_filing_status == 'head_household':
PST = 583.33
else:
PST = 364.58
elif 'monthly' == schedule_pay:
allowance_multiplier = 208.33
if contract.nc_nc4_filing_status == 'head_household':
PST = 1166.67
else:
PST = 729.17
else:
raise Exception('Invalid schedule_pay="' + schedule_pay + '" for NC Income Withholding calculation')
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
if contract.nc_nc4_filing_status == 'exempt':
result = 0
else:
withholding = round(((wages - (PST + (allowance_multiplier * allowances))) * 0.05599) + contract.nc_nc4_additional_wh)
if withholding > 0.0:
result = - withholding
else:
result = 0
else:
PST = 0.0
allowance_multiplier = 0.0
if 'weekly' == schedule_pay:
allowance_multiplier = 48.08
if contract.nc_nc4_filing_status == 'head_household':
PST = 288.46
else:
PST = 192.31
elif 'bi-weekly' == schedule_pay:
allowance_multiplier = 96.15
if contract.nc_nc4_filing_status == 'head_household':
PST = 576.92
else:
PST = 384.62
elif 'semi-monthly' == schedule_pay:
allowance_multiplier = 104.17
if contract.nc_nc4_filing_status == 'head_household':
PST = 625.00
else:
PST = 416.67
elif 'monthly' == schedule_pay:
allowance_multiplier = 208.33
if contract.nc_nc4_filing_status == 'head_household':
PST = 1250.00
else:
PST = 833.33
else:
raise Exception('Invalid schedule_pay="' + schedule_pay + '" for NC Income Withholding calculation')
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
if contract.nc_nc4_filing_status == 'exempt':
result = 0
else:
withholding = round(((wages - (PST + (allowance_multiplier * allowances))) * 0.0535) + contract.nc_nc4_additional_wh)
if withholding > 0.0:
result = - withholding
else:
result = 0
</field>
<field name="register_id" ref="contrib_register_ncdor_withhold"/>
</record>
</data>
</odoo>

View File

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

View File

@@ -0,0 +1,17 @@
from odoo import models, fields, api
class USNCHrContract(models.Model):
_inherit = 'hr.contract'
nc_nc4_allowances = fields.Integer(string='North Carolina NC-4 Allowances', default=0)
nc_nc4_filing_status = fields.Selection([
('exempt', 'Exempt'),
('single', 'Single'),
('married', 'Married'),
('surviving_spouse', 'Surviving Spouse'),
('head_household', 'Head of Household')
], string='NC Filing Status', default='single')
nc_nc4_additional_wh = fields.Float(string="Additional Witholding", default=0.0,
help="If you are filling out NC-4 NRA, this would be box 4; " \
"otherwise box 2.")

View File

@@ -0,0 +1,2 @@
from . import test_us_nc_payslip_2018
from . import test_us_nc_payslip_2019

View File

@@ -0,0 +1,378 @@
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 TestUsNCPayslip(TestUsPayslip):
###
# Taxes and Rates
###
NC_UNEMP_MAX_WAGE = 23500.0
NC_UNEMP = -0.6 / 100.0
def test_2018_taxes_weekly(self):
salary = 5000.0
schedule_pay = 'weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 48.08
PST = 168.27
exemption = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * exemption))) * 0.05599)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = exemption
self.assertEqual(contract.schedule_pay, 'weekly')
self._log('2018 North Carolina tax first payslip weekly:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2*salary < salary) \
else salary
self._log('2018 North Carolina tax second payslip weekly:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_2018_taxes_with_external_weekly(self):
salary = 5000.0
external_wages = 30000.0
schedule_pay = 'weekly'
employee = self._createEmployee()
contract = self._createContract(employee, salary, external_wages=external_wages,
struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
self._log('2018 NorthCarolina_external tax first payslip weekly:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], max(self.NC_UNEMP_MAX_WAGE - external_wages, 0.0))
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
def test_2018_taxes_with_state_exempt_weekly(self):
salary = 5000.0
external_wages = 10000.0
schedule_pay = 'weekly'
employee = self._createEmployee()
contract = self._createContract(employee, salary, external_wages=external_wages, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), futa_type=USHrContract.FUTA_TYPE_BASIC, schedule_pay=schedule_pay)
self._log('2018 North Carolina exempt tax first payslip weekly:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats.get('WAGE_US_NC_UNEMP', 0.0), 0.0)
self.assertPayrollEqual(cats.get('ER_US_NC_UNEMP', 0.0), cats.get('WAGE_US_NC_UNEMP', 0.0) * self.NC_UNEMP)
def test_2018_taxes_biweekly(self):
salary = 5000.0
schedule_pay = 'bi-weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 96.15
PST = 336.54
allowances = 2
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * allowances))) * 0.05599)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = allowances
self.assertEqual(contract.schedule_pay, 'bi-weekly')
self._log('2018 North Carolina tax first payslip bi-weekly:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2*salary < salary) \
else salary
self._log('2018 North Carolina tax second payslip bi-weekly:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_2018_taxes_semimonthly(self):
salary = 4000.0
schedule_pay = 'semi-monthly'
nc_nc4_filing_status = 'head_household'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 104.17
PST = 583.33
allowances = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * allowances))) * 0.05599)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = allowances
contract.nc_nc4_filing_status = nc_nc4_filing_status
self.assertEqual(contract.schedule_pay, 'semi-monthly')
self._log('2018 North Carolina tax first payslip:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2018 North Carolina tax second payslip:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_2018_taxes_monthly(self):
salary = 4000.0
schedule_pay = 'monthly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 208.33
PST = 729.17
allowances = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * allowances))) * 0.05599)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = allowances
self.assertEqual(contract.schedule_pay, 'monthly')
self._log('2018 North Carolina tax first payslip:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (
self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2018 North Carolina tax second payslip:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_tax_exempt(self):
salary = 4000.0
wh = 0
schedule_pay = 'weekly'
excemptions = 1
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = excemptions
contract.nc_nc4_filing_status = 'exempt'
self.assertEqual(contract.schedule_pay, 'weekly')
self._log('2018 North Carolina tax first payslip:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (
self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2018 North Carolina tax second payslip:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_additional_withholding(self):
salary = 4000.0
schedule_pay = 'weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 48.08
PST = 168.27
additional_wh = 40.0
#4000 - (168.27 + (48.08 * 1)
allowances = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round(((salary - (PST + (allowance_multiplier * allowances))) * 0.05599) + additional_wh)
employee = self._createEmployee()
contract = self._createContract(employee,
salary,
struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'),
schedule_pay=schedule_pay)
contract.w4_is_nonresident_alien = True
contract.nc_nc4_additional_wh = additional_wh
contract.nc_nc4_allowances = allowances
self.assertEqual(contract.schedule_pay, 'weekly')
self.assertEqual(contract.w4_is_nonresident_alien, True)
self._log('2018 North Carolina tax first payslip weekly:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2018 North Carolina tax second payslip weekly:')
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_underflow(self):
salary = 150.0
schedule_pay = 'weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 48.08
PST = 168.27
exemption = 1
# Withholding should be 0, since pay is so low it's less than PST.
wh = 0.0
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = exemption
self.assertEqual(contract.schedule_pay, 'weekly')
self._log('2018 North Carolina tax first payslip weekly:')
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)

View File

@@ -0,0 +1,379 @@
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 TestUsNCPayslip(TestUsPayslip):
###
# Taxes and Rates
###
NC_UNEMP_MAX_WAGE = 24300.0
NC_UNEMP = -1.0 / 100.0
NC_INC_TAX = -0.0535
def test_2019_taxes_weekly(self):
salary = 5000.0
schedule_pay = 'weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 48.08
PST = 192.31
exemption = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * exemption))) * -self.NC_INC_TAX)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = exemption
self.assertEqual(contract.schedule_pay, 'weekly')
self._log('2019 North Carolina tax first payslip weekly:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2*salary < salary) \
else salary
self._log('2019 North 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_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_2019_taxes_with_external_weekly(self):
salary = 5000.0
external_wages = 30000.0
schedule_pay = 'weekly'
employee = self._createEmployee()
contract = self._createContract(employee, salary, external_wages=external_wages,
struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
self._log('2019 NorthCarolina_external tax first payslip weekly:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], max(self.NC_UNEMP_MAX_WAGE - external_wages, 0.0))
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
def test_2019_taxes_with_state_exempt_weekly(self):
salary = 5000.0
external_wages = 10000.0
schedule_pay = 'weekly'
employee = self._createEmployee()
contract = self._createContract(employee, salary, external_wages=external_wages, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), futa_type=USHrContract.FUTA_TYPE_BASIC, schedule_pay=schedule_pay)
self._log('2019 North Carolina exempt tax first payslip weekly:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats.get('WAGE_US_NC_UNEMP', 0.0), 0.0)
self.assertPayrollEqual(cats.get('ER_US_NC_UNEMP', 0.0), cats.get('WAGE_US_NC_UNEMP', 0.0) * self.NC_UNEMP)
def test_2019_taxes_biweekly(self):
salary = 5000.0
schedule_pay = 'bi-weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 96.15
PST = 384.62
allowances = 2
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * allowances))) * -self.NC_INC_TAX)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = allowances
self.assertEqual(contract.schedule_pay, 'bi-weekly')
self._log('2019 North Carolina tax first payslip bi-weekly:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2*salary < salary) \
else salary
self._log('2019 North Carolina tax second payslip bi-weekly:')
payslip = self._createPayslip(employee, '2019-02-01', '2019-02-28')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_2019_taxes_semimonthly(self):
salary = 4000.0
schedule_pay = 'semi-monthly'
nc_nc4_filing_status = 'head_household'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 104.17
PST = 625.00
allowances = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * allowances))) * -self.NC_INC_TAX)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = allowances
contract.nc_nc4_filing_status = nc_nc4_filing_status
self.assertEqual(contract.schedule_pay, 'semi-monthly')
self._log('2019 North 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_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2019 North 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_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_2019_taxes_monthly(self):
salary = 4000.0
schedule_pay = 'monthly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 208.33
PST = 833.33
allowances = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round((salary - (PST + (allowance_multiplier * allowances))) * -self.NC_INC_TAX)
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = allowances
self.assertEqual(contract.schedule_pay, 'monthly')
self._log('2019 North 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_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (
self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2019 North 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_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_tax_exempt(self):
salary = 4000.0
wh = 0
schedule_pay = 'weekly'
excemptions = 1
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = excemptions
contract.nc_nc4_filing_status = 'exempt'
self.assertEqual(contract.schedule_pay, 'weekly')
self._log('2019 North 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_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (
self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2019 North 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_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_additional_withholding(self):
salary = 4000.0
schedule_pay = 'weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 48.08
PST = 192.31
additional_wh = 40.0
#4000 - (168.27 + (48.08 * 1)
allowances = 1
# Algorithm derived from percentage method in https://files.nc.gov/ncdor/documents/files/nc-30_book_web.pdf
wh = -round(((salary - (PST + (allowance_multiplier * allowances))) * -self.NC_INC_TAX) + additional_wh)
employee = self._createEmployee()
contract = self._createContract(employee,
salary,
struct_id=self.ref('l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'),
schedule_pay=schedule_pay)
contract.w4_is_nonresident_alien = True
contract.nc_nc4_additional_wh = additional_wh
contract.nc_nc4_allowances = allowances
self.assertEqual(contract.schedule_pay, 'weekly')
self.assertEqual(contract.w4_is_nonresident_alien, True)
self._log('2019 North Carolina tax first payslip weekly:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)
# Make a new payslip, this one will have maximums
remaining_NC_UNEMP_wages = self.NC_UNEMP_MAX_WAGE - salary if (self.NC_UNEMP_MAX_WAGE - 2 * salary < salary) \
else salary
self._log('2019 North 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_NC_UNEMP'], remaining_NC_UNEMP_wages)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], remaining_NC_UNEMP_wages * self.NC_UNEMP)
def test_underflow(self):
salary = 150.0
schedule_pay = 'weekly'
# allowance_multiplier and Portion of Standard Deduction for weekly
allowance_multiplier = 48.08
PST = 192.31
exemption = 1
# Withholding should be 0, since pay is so low it's less than PST.
wh = 0.0
employee = self._createEmployee()
contract = self._createContract(employee, salary, struct_id=self.ref(
'l10n_us_nc_hr_payroll.hr_payroll_salary_structure_us_nc_employee'), schedule_pay=schedule_pay)
contract.nc_nc4_allowances = exemption
self.assertEqual(contract.schedule_pay, 'weekly')
self._log('2019 North Carolina tax first payslip weekly:')
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
payslip.compute_sheet()
cats = self._getCategories(payslip)
self.assertPayrollEqual(cats['WAGE_US_NC_UNEMP'], salary)
self.assertPayrollEqual(cats['ER_US_NC_UNEMP'], cats['WAGE_US_NC_UNEMP'] * self.NC_UNEMP)
self.assertPayrollEqual(cats['EE_US_NC_INC_WITHHOLD'], wh)
process_payslip(payslip)

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="hr_contract_form_l10n_us_nc_inherit" model="ir.ui.view">
<field name="name">hr.contract.form.inherit</field>
<field name="model">hr.contract</field>
<field name="priority">128</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="North Carolina" name="nc">
<field name="nc_nc4_allowances" string="Allowances"/>
<field name="nc_nc4_filing_status" string="Filing Status"/>
<field name="nc_nc4_additional_wh" string="Additional Withholding"/>
</group>
</xpath>
</data>
</field>
</record>
</data>
</odoo>