mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
#31 Merge branch 'mig/12.0/l10n_us_pa_hr_payroll' into mig/12.0/us_payroll
This commit is contained in:
45
l10n_us_pa_hr_payroll/README.rst
Normal file
45
l10n_us_pa_hr_payroll/README.rst
Normal file
@@ -0,0 +1,45 @@
|
||||
***************************************
|
||||
Hibou - US Payroll - Pennsylvania State
|
||||
***************************************
|
||||
|
||||
Calculations and contribution registers for Pennsylvania State Payroll.
|
||||
|
||||
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
|
||||
|
||||
=============
|
||||
Main Features
|
||||
=============
|
||||
|
||||
* New Partner for Pennsylvania Department of Revenue
|
||||
* New Contribution Registers for:
|
||||
* Pennsylvania Department of Revenue - Unemployment Insurance
|
||||
* Pennsylvania Department of Revenue - State Income Tax
|
||||
* Contract level Pennsylvania Unemployment Rate
|
||||
* Contract level Pennsylvania State Income Tax Rate
|
||||
* Company level Pennsylvania Unemployment Rate
|
||||
|
||||
|
||||
.. image:: https://user-images.githubusercontent.com/15882954/41480481-7e9c9b16-7083-11e8-83e0-25d8f37fb2c2.png
|
||||
:alt: 'Employee Contract Detail'
|
||||
:width: 988
|
||||
:align: left
|
||||
|
||||
USA Pennsylvania Employee Added to Contract Salary Structure Menu
|
||||
|
||||
.. image:: https://user-images.githubusercontent.com/15882954/41480499-8a2d88e6-7083-11e8-88a0-2811356bca34.png
|
||||
:alt: 'Computed Pay Slip Detail'
|
||||
:width: 988
|
||||
:align: left
|
||||
|
||||
New Payslip Categories for:
|
||||
|
||||
* Pennsylvania Unemployment - Wages
|
||||
* Pennsylvania Income Withholding
|
||||
* Pennsylvania Unemployment - Employee
|
||||
* Pennsylvania Unemployment - Employer
|
||||
|
||||
=======
|
||||
License
|
||||
=======
|
||||
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/master/LICENSE>`_.
|
||||
Copyright Hibou Corp. 2018
|
||||
1
l10n_us_pa_hr_payroll/__init__.py
Normal file
1
l10n_us_pa_hr_payroll/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
29
l10n_us_pa_hr_payroll/__manifest__.py
Executable file
29
l10n_us_pa_hr_payroll/__manifest__.py
Executable file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
'name': 'USA - Pennsylvania - 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::Pennsylvania Payroll Rules.
|
||||
================================
|
||||
|
||||
* Partner for Pennsylvania Department of Revenue
|
||||
* Contribution register for Pennsylvania Department of Revenue - Unemployment Insurance
|
||||
* Contribution register Pennsylvania Department of Revenue - State Income Tax
|
||||
* Contract level Pennsylvania Unemployment Rate
|
||||
* Company level Pennsylvania Unemployement 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
|
||||
}
|
||||
66
l10n_us_pa_hr_payroll/data/base.xml
Executable file
66
l10n_us_pa_hr_payroll/data/base.xml
Executable file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- CONTRIBUTION REGISTERS -->
|
||||
<record id="res_partner_pador_unemp_employee" model="res.partner">
|
||||
<field name="name">Pennsylvania Department of Revenue - Unemployment Tax(Employee)</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_pador_unemp_company" model="res.partner">
|
||||
<field name="name">Pennsylvania Department of Revenue - Unemployment Tax(Employer)</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
|
||||
<record id="res_partner_pador_withhold" model="res.partner">
|
||||
<field name="name">Pennsylvania Department of Revenue - Income Tax</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
|
||||
<record id="contrib_register_pador_unemp_employee" model="hr.contribution.register">
|
||||
<field name="name">Pennsylvania Unemployment(Employee)</field>
|
||||
<field name="note">Pennsylvania Department of Revenue - Unemployment(Employee)</field>
|
||||
<field name="partner_id" ref="res_partner_pador_unemp_employee"/>
|
||||
</record>
|
||||
|
||||
<record id="contrib_register_pador_unemp_company" model="hr.contribution.register">
|
||||
<field name="name">Pennsylvania Unemployment(Employer)</field>
|
||||
<field name="note">Pennsylvania Department of Revenue - Unemployment(Employee)</field>
|
||||
<field name="partner_id" ref="res_partner_pador_unemp_company"/>
|
||||
</record>
|
||||
|
||||
<record id="contrib_register_pador_withhold" model="hr.contribution.register">
|
||||
<field name="name">Pennsylvania Income Tax Withholding</field>
|
||||
<field name="note">Pennsylvania Department of Revenue - Income Tax</field>
|
||||
<field name="partner_id" ref="res_partner_pador_withhold"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- HR SALARY RULE CATEGORIES-->
|
||||
<record id="hr_payroll_pa_unemp_wages" model="hr.salary.rule.category">
|
||||
<field name="name">Wage: ER: US-PA Pennsylvania Unemployment</field>
|
||||
<field name="code">WAGE_ER_US_PA_UNEMP</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_pa_unemp_employee" model="hr.salary.rule.category">
|
||||
<field name="name">EE: US-PA Unemployment</field>
|
||||
<field name="code">EE_US_PA_UNEMP</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_pa_unemp_company" model="hr.salary.rule.category">
|
||||
<field name="name">ER: US-PA Unemployment</field>
|
||||
<field name="code">ER_US_PA_UNEMP</field>
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_pa_withhold" model="hr.salary.rule.category">
|
||||
<field name="name">EE: US-PA Income Withholding</field>
|
||||
<field name="code">EE_US_PA_INC_WITHHOLD</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
21
l10n_us_pa_hr_payroll/data/final.xml
Executable file
21
l10n_us_pa_hr_payroll/data/final.xml
Executable file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR PAYROLL STRUCTURE -->
|
||||
<record id="hr_payroll_salary_structure_us_pa_employee" model="hr.payroll.structure">
|
||||
<field name="code">US_PA_EMP</field>
|
||||
<field name="name">USA Pennsylvania Employee</field>
|
||||
<field eval="[(6, 0, [
|
||||
ref('hr_payroll_rules_pa_unemp_wages_2018'),
|
||||
ref('hr_payroll_rules_pa_unemp_employee_2018'),
|
||||
ref('hr_payroll_rules_pa_unemp_company_2018'),
|
||||
ref('hr_payroll_rules_pa_inc_withhold_2018'),
|
||||
ref('hr_payroll_rules_pa_inc_withhold_add'),
|
||||
])]" 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>
|
||||
24
l10n_us_pa_hr_payroll/data/rates.xml
Normal file
24
l10n_us_pa_hr_payroll/data/rates.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="hr_payroll_rates_pa_unemp_2018" model="hr.payroll.rate">
|
||||
<field name="name">US Pennsylvania Unemployment (Company)</field>
|
||||
<field name="code">ER_US_PA_UNEMP</field>
|
||||
<field name="rate">3.6890</field>
|
||||
<field name="date_from">2018-01-01</field>
|
||||
<field name="wage_limit_year" eval="10000.0"/>
|
||||
</record>
|
||||
<record id="hr_payroll_rates_pa_unemp_ee_2018" model="hr.payroll.rate">
|
||||
<field name="name">UUS Pennsylvania Unemployment (Employee)</field>
|
||||
<field name="code">EE_US_PA_UNEMP</field>
|
||||
<field name="rate">0.06</field>
|
||||
<field name="date_from">2018-01-01</field>
|
||||
</record>
|
||||
<record id="hr_payroll_rates_pa_inc_2018" model="hr.payroll.rate">
|
||||
<field name="name">US Pennsylvania Income Tax Rate (default)</field>
|
||||
<field name="code">US_PA_INC_WITHHOLD</field>
|
||||
<field name="rate">3.07</field>
|
||||
<field name="date_from">2018-01-01</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
107
l10n_us_pa_hr_payroll/data/rules.xml
Executable file
107
l10n_us_pa_hr_payroll/data/rules.xml
Executable file
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR SALARY RULES-->
|
||||
<record id="hr_payroll_rules_pa_unemp_wages_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="143"/>
|
||||
<field name="category_id" ref="hr_payroll_pa_unemp_wages"/>
|
||||
<field name="name">Wage: ER: US-PA Unemployment</field>
|
||||
<field name="code">WAGE_ER_US_PA_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">
|
||||
###
|
||||
year = payslip.dict.date_to.year
|
||||
rate = payslip.dict.get_rate('ER_US_PA_UNEMP')
|
||||
ytd = payslip.sum('WAGE_ER_US_PA_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_pa_unemp_employee_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="145"/>
|
||||
<field name="category_id" ref="hr_payroll_pa_unemp_employee"/>
|
||||
<field name="name">EE: US-PA Unemployment</field>
|
||||
<field name="code">EE_US_PA_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('EE_US_PA_UNEMP')
|
||||
result_rate = -rate.rate
|
||||
result = categories.BASIC
|
||||
|
||||
# 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_pador_unemp_employee"/>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
<record id="hr_payroll_rules_pa_unemp_company_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="443"/>
|
||||
<field name="category_id" ref="hr_payroll_pa_unemp_company"/>
|
||||
<field name="name">ER: US-PA Unemployment</field>
|
||||
<field name="code">ER_US_PA_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('ER_US_PA_UNEMP')
|
||||
result_rate = -rate.rate
|
||||
result = categories.WAGE_ER_US_PA_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_pador_unemp_company"/>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_rules_pa_inc_withhold_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="145"/>
|
||||
<field name="category_id" ref="hr_payroll_pa_withhold"/>
|
||||
<field name="name">EE: US-PA Income Withholding</field>
|
||||
<field name="code">EE_US_PA_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">
|
||||
rate = payslip.dict.get_rate('US_PA_INC_WITHHOLD')
|
||||
wages = categories.GROSS
|
||||
result_rate = -rate.rate
|
||||
result = 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_pador_withhold"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_rules_pa_inc_withhold_add" model="hr.salary.rule">
|
||||
<field name="sequence" eval="146"/>
|
||||
<field name="category_id" ref="hr_payroll_pa_withhold"/>
|
||||
<field name="name">EE: US-PA Income Withholding Additional</field>
|
||||
<field name="code">EE_US_PA_INC_WITHHOLD_ADD</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result = (contract.pa_additional_withholding)</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">
|
||||
result = -contract.pa_additional_withholding
|
||||
</field>
|
||||
<field name="register_id" ref="contrib_register_pador_withhold"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
1
l10n_us_pa_hr_payroll/models/__init__.py
Normal file
1
l10n_us_pa_hr_payroll/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import hr_payroll
|
||||
7
l10n_us_pa_hr_payroll/models/hr_payroll.py
Executable file
7
l10n_us_pa_hr_payroll/models/hr_payroll.py
Executable file
@@ -0,0 +1,7 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class USPAHrContract(models.Model):
|
||||
_inherit = 'hr.contract'
|
||||
|
||||
pa_additional_withholding = fields.Float(string="Additional Withholding")
|
||||
2
l10n_us_pa_hr_payroll/tests/__init__.py
Executable file
2
l10n_us_pa_hr_payroll/tests/__init__.py
Executable file
@@ -0,0 +1,2 @@
|
||||
from . import test_us_pa_payslip_2018
|
||||
from . import test_us_pa_payslip_2019
|
||||
30
l10n_us_pa_hr_payroll/tests/test_us_pa_payslip_2018.py
Executable file
30
l10n_us_pa_hr_payroll/tests/test_us_pa_payslip_2018.py
Executable file
@@ -0,0 +1,30 @@
|
||||
from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip
|
||||
|
||||
|
||||
class TestUsPAPayslip(TestUsPayslip):
|
||||
###
|
||||
# Taxes and Rates
|
||||
###
|
||||
PA_UNEMP_MAX_WAGE = 10000.0
|
||||
ER_PA_UNEMP = -3.6890 / 100.0
|
||||
EE_PA_UNEMP = -0.06 / 100.0
|
||||
PA_INC_WITHHOLD = 3.07
|
||||
|
||||
def test_2018_taxes(self):
|
||||
salary = 4166.67
|
||||
wh = -127.92
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_pa_hr_payroll.hr_payroll_salary_structure_us_pa_employee'))
|
||||
|
||||
self._log('2018 Pennsylvania tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
payslip.onchange_contract()
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['WAGE_ER_US_PA_UNEMP'], salary)
|
||||
self.assertPayrollEqual(cats['EE_US_PA_UNEMP'], cats['BASIC'] * self.EE_PA_UNEMP)
|
||||
self.assertPayrollEqual(cats['ER_US_PA_UNEMP'], cats['WAGE_ER_US_PA_UNEMP'] * self.ER_PA_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_PA_INC_WITHHOLD'], wh)
|
||||
33
l10n_us_pa_hr_payroll/tests/test_us_pa_payslip_2019.py
Executable file
33
l10n_us_pa_hr_payroll/tests/test_us_pa_payslip_2019.py
Executable file
@@ -0,0 +1,33 @@
|
||||
from odoo.addons.l10n_us_hr_payroll.tests.test_us_payslip import TestUsPayslip, process_payslip
|
||||
|
||||
|
||||
class TestUsPAPayslip(TestUsPayslip):
|
||||
###
|
||||
# Taxes and Rates
|
||||
###
|
||||
PA_UNEMP_MAX_WAGE = 10000.0
|
||||
ER_PA_UNEMP = -3.6890 / 100.0
|
||||
EE_PA_UNEMP = -0.06 / 100.0
|
||||
PA_INC_WITHHOLD = 3.07
|
||||
|
||||
def test_2019_taxes(self):
|
||||
salary = 4166.67
|
||||
additional_withhold = 5.0
|
||||
wh = -127.92 - additional_withhold
|
||||
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_pa_hr_payroll.hr_payroll_salary_structure_us_pa_employee'))
|
||||
contract.pa_additional_withholding = additional_withhold
|
||||
|
||||
self._log('2019 Pennsylvania tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
payslip.onchange_contract()
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['WAGE_ER_US_PA_UNEMP'], salary)
|
||||
self.assertPayrollEqual(cats['EE_US_PA_UNEMP'], cats['BASIC'] * self.EE_PA_UNEMP)
|
||||
self.assertPayrollEqual(cats['ER_US_PA_UNEMP'], cats['WAGE_ER_US_PA_UNEMP'] * self.ER_PA_UNEMP)
|
||||
self.assertPayrollEqual(cats['EE_US_PA_INC_WITHHOLD'], wh)
|
||||
20
l10n_us_pa_hr_payroll/views/hr_payroll_views.xml
Executable file
20
l10n_us_pa_hr_payroll/views/hr_payroll_views.xml
Executable file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="hr_contract_form_l10n_us_pa_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.contract.form.inherit</field>
|
||||
<field name="model">hr.contract</field>
|
||||
<field name="priority">148</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="Pennsylvania" name="pa">
|
||||
<field name="pa_additional_withholding"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user