mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of North Carolina Payroll l10n_us_nc_hr_payroll for 11.0
This commit is contained in:
committed by
Jared Kipe
parent
7616db9bf5
commit
d7f17b334a
1
l10n_us_nc_hr_payroll/__init__.py
Executable file
1
l10n_us_nc_hr_payroll/__init__.py
Executable file
@@ -0,0 +1 @@
|
|||||||
|
from . import hr_payroll
|
||||||
27
l10n_us_nc_hr_payroll/__manifest__.py
Executable file
27
l10n_us_nc_hr_payroll/__manifest__.py
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
'name': 'USA - North Carolina - 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::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': [
|
||||||
|
'hr_payroll_view.xml',
|
||||||
|
'data/base.xml',
|
||||||
|
'data/rules_2018.xml',
|
||||||
|
'data/final.xml',
|
||||||
|
],
|
||||||
|
'installable': True
|
||||||
|
}
|
||||||
46
l10n_us_nc_hr_payroll/data/base.xml
Executable file
46
l10n_us_nc_hr_payroll/data/base.xml
Executable 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">North Carolina Unemployment - Wages</field>
|
||||||
|
<field name="code">NC_UNEMP_WAGES</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="hr_payroll_nc_unemp" model="hr.salary.rule.category">
|
||||||
|
<field name="name">North Carolina Unemployment</field>
|
||||||
|
<field name="code">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">North Carolina Income Withholding</field>
|
||||||
|
<field name="code">NC_INC_WITHHOLD</field>
|
||||||
|
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
19
l10n_us_nc_hr_payroll/data/final.xml
Executable file
19
l10n_us_nc_hr_payroll/data/final.xml
Executable 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>
|
||||||
107
l10n_us_nc_hr_payroll/data/rules_2018.xml
Executable file
107
l10n_us_nc_hr_payroll/data/rules_2018.xml
Executable file
@@ -0,0 +1,107 @@
|
|||||||
|
<?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">North Carolina Unemployment - Wages (2018)</field>
|
||||||
|
<field name="code">NC_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('NC_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01')
|
||||||
|
ytd += contract.external_wages
|
||||||
|
remaining = 7000.0 - ytd
|
||||||
|
if remaining <= 0.0:
|
||||||
|
result = 0
|
||||||
|
elif remaining < categories.GROSS:
|
||||||
|
result = remaining
|
||||||
|
else:
|
||||||
|
result = categories.GROSS
|
||||||
|
</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">North Carolina Unemployment (2018)</field>
|
||||||
|
<field name="code">NC_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.nc_unemp_rate(2018)
|
||||||
|
result = categories.NC_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_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="145"/>
|
||||||
|
<field name="category_id" ref="hr_payroll_nc_income_withhold"/>
|
||||||
|
<field name="name">North Carolina Income Withholding</field>
|
||||||
|
<field name="code">NC_INC_WITHHOLD_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">
|
||||||
|
wages = categories.GROSS
|
||||||
|
exemptions = contract.nc_nc4_allowances
|
||||||
|
schedule_pay = contract.schedule_pay
|
||||||
|
val = 0.00
|
||||||
|
|
||||||
|
|
||||||
|
# PST -> Portion of standard deduction
|
||||||
|
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:
|
||||||
|
if contract.w4_is_nonresident_alien:
|
||||||
|
result = round(((wages - (PST + (allowance_multiplier * exemptions))) * 0.05599) - contract.nc_nc4_additional_wh)
|
||||||
|
else:
|
||||||
|
result = round((wages - (PST + (allowance_multiplier * exemptions))) * 0.05599)
|
||||||
|
</field>
|
||||||
|
<field name="register_id" ref="contrib_register_ncdor_withhold"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
33
l10n_us_nc_hr_payroll/hr_payroll.py
Executable file
33
l10n_us_nc_hr_payroll/hr_payroll.py
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def nc_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, 'nc_unemp_rate_' + str(year)):
|
||||||
|
return self.employee_id.company_id['nc_unemp_rate_' + str(year)]
|
||||||
|
|
||||||
|
raise NotImplemented('Year (' + str(year) + ') Not implemented for US North Carolina.')
|
||||||
|
|
||||||
|
|
||||||
|
class NCCompany(models.Model):
|
||||||
|
_inherit = 'res.company'
|
||||||
|
|
||||||
|
# Unemployment rate provided by Katherine
|
||||||
|
nc_unemp_rate_2018 = fields.Float(string="North Carolina Unemployment Rate 2018", default=0.06)
|
||||||
35
l10n_us_nc_hr_payroll/hr_payroll_view.xml
Executable file
35
l10n_us_nc_hr_payroll/hr_payroll_view.xml
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="us_nc_view_company_form" model="ir.ui.view">
|
||||||
|
<field name="name">res.company.form</field>
|
||||||
|
<field name="model">res.company</field>
|
||||||
|
<field name="priority">64</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="nc_unemp_rate_2018"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<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>
|
||||||
1
l10n_us_nc_hr_payroll/tests/__init__.py
Executable file
1
l10n_us_nc_hr_payroll/tests/__init__.py
Executable file
@@ -0,0 +1 @@
|
|||||||
|
from . import test_us_nc_payslip_2018
|
||||||
322
l10n_us_nc_hr_payroll/tests/test_us_nc_payslip_2018.py
Executable file
322
l10n_us_nc_hr_payroll/tests/test_us_nc_payslip_2018.py
Executable file
@@ -0,0 +1,322 @@
|
|||||||
|
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 TestUsNCPayslip(TestUsPayslip):
|
||||||
|
###
|
||||||
|
# Taxes and Rates
|
||||||
|
###
|
||||||
|
NC_UNEMP_MAX_WAGE = 7000.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()
|
||||||
|
employee.company_id.nc_unemp_rate_2018 = 0.06
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
# tax rates
|
||||||
|
nc_unemp = contract.nc_unemp_rate(2018) / -100.0
|
||||||
|
|
||||||
|
|
||||||
|
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['NC_UNEMP_WAGES'], salary)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], cats['NC_UNEMP_WAGES'] * nc_unemp)
|
||||||
|
self.assertPayrollEqual(cats['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['NC_UNEMP_WAGES'], remaining_nc_unemp_wages)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], remaining_nc_unemp_wages * nc_unemp)
|
||||||
|
|
||||||
|
def test_2018_taxes_with_external_weekly(self):
|
||||||
|
salary = 5000.0
|
||||||
|
external_wages = 7000.0
|
||||||
|
|
||||||
|
schedule_pay = 'weekly'
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
employee.company_id.nc_unemp_rate_2018 = 0.06
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
# tax rates
|
||||||
|
nc_unemp = contract.nc_unemp_rate(2018) / -100.0
|
||||||
|
|
||||||
|
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['NC_UNEMP_WAGES'], self.NC_UNEMP_MAX_WAGE - external_wages)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], cats['NC_UNEMP_WAGES'] * nc_unemp)
|
||||||
|
|
||||||
|
def test_2018_taxes_with_state_exempt_weekly(self):
|
||||||
|
salary = 5000.0
|
||||||
|
external_wages = 6000.0
|
||||||
|
schedule_pay = 'weekly'
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
employee.company_id.nc_unemp_rate_2018 = 0.06
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
# tax rates
|
||||||
|
nc_unemp = contract.nc_unemp_rate(2018) / -100.0
|
||||||
|
|
||||||
|
self.assertPayrollEqual(nc_unemp, 0.0)
|
||||||
|
|
||||||
|
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['NC_UNEMP_WAGES'], self.NC_UNEMP_MAX_WAGE - external_wages)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], cats['NC_UNEMP_WAGES'] * 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
|
||||||
|
|
||||||
|
exceptions = 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 * exceptions))) * 0.05599)
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
employee.company_id.nc_unemp_rate_2018 = 0.06
|
||||||
|
|
||||||
|
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 = exceptions
|
||||||
|
|
||||||
|
self.assertEqual(contract.schedule_pay, 'bi-weekly')
|
||||||
|
|
||||||
|
# tax rates
|
||||||
|
nc_unemp = contract.nc_unemp_rate(2018) / -100.0
|
||||||
|
|
||||||
|
|
||||||
|
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['NC_UNEMP_WAGES'], salary)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], cats['NC_UNEMP_WAGES'] * nc_unemp)
|
||||||
|
self.assertPayrollEqual(cats['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['NC_UNEMP_WAGES'], remaining_nc_unemp_wages)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], remaining_nc_unemp_wages * 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
|
||||||
|
|
||||||
|
exceptions = 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 * exceptions))) * 0.05599)
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
employee.company_id.nc_unemp_rate_2018 = 0.06
|
||||||
|
|
||||||
|
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 = exceptions
|
||||||
|
contract.nc_nc4_filing_status = nc_nc4_filing_status
|
||||||
|
|
||||||
|
self.assertEqual(contract.schedule_pay, 'semi-monthly')
|
||||||
|
|
||||||
|
# tax rates
|
||||||
|
nc_unemp = contract.nc_unemp_rate(2018) / -100.0
|
||||||
|
|
||||||
|
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['NC_UNEMP_WAGES'], salary)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], cats['NC_UNEMP_WAGES'] * nc_unemp)
|
||||||
|
self.assertPayrollEqual(cats['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['NC_UNEMP_WAGES'], remaining_nc_unemp_wages)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], remaining_nc_unemp_wages * nc_unemp)
|
||||||
|
|
||||||
|
def test_2018_taxes_monthly(self):
|
||||||
|
self.debug = True
|
||||||
|
salary = 4000.0
|
||||||
|
schedule_pay = 'monthly'
|
||||||
|
# allowance_multiplier and Portion of Standard Deduction for weekly
|
||||||
|
allowance_multiplier = 208.33
|
||||||
|
PST = 729.17
|
||||||
|
|
||||||
|
exceptions = 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 * exceptions))) * 0.05599)
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
employee.company_id.nc_unemp_rate_2018 = 0.06
|
||||||
|
|
||||||
|
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 = exceptions
|
||||||
|
|
||||||
|
self.assertEqual(contract.schedule_pay, 'monthly')
|
||||||
|
|
||||||
|
# tax rates
|
||||||
|
nc_unemp = contract.nc_unemp_rate(2018) / -100.0
|
||||||
|
|
||||||
|
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['NC_UNEMP_WAGES'], salary)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], cats['NC_UNEMP_WAGES'] * nc_unemp)
|
||||||
|
self.assertPayrollEqual(cats['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['NC_UNEMP_WAGES'], remaining_nc_unemp_wages)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], remaining_nc_unemp_wages * nc_unemp)
|
||||||
|
|
||||||
|
def test_tax_exempt(self):
|
||||||
|
salary = 4000.0
|
||||||
|
wh = 0
|
||||||
|
schedule_pay = 'weekly'
|
||||||
|
excemptions = 1
|
||||||
|
|
||||||
|
employee = self._createEmployee()
|
||||||
|
employee.company_id.nc_unemp_rate_2018 = 0.06
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
# tax rates
|
||||||
|
nc_unemp = contract.nc_unemp_rate(2018) / -100.0
|
||||||
|
|
||||||
|
|
||||||
|
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['NC_UNEMP_WAGES'], salary)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], cats['NC_UNEMP_WAGES'] * nc_unemp)
|
||||||
|
self.assertPayrollEqual(cats['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['NC_UNEMP_WAGES'], remaining_nc_unemp_wages)
|
||||||
|
self.assertPayrollEqual(cats['NC_UNEMP'], remaining_nc_unemp_wages * nc_unemp)
|
||||||
Reference in New Issue
Block a user