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_fl_hr_payroll' into mig/12.0/us_payroll
This commit is contained in:
63
l10n_us_fl_hr_payroll/README.rst
Normal file
63
l10n_us_fl_hr_payroll/README.rst
Normal file
@@ -0,0 +1,63 @@
|
||||
**********************************
|
||||
Hibou - US Payroll - Florida State
|
||||
**********************************
|
||||
|
||||
Calculations and contribution registers for Florida State Payroll.
|
||||
|
||||
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
|
||||
|
||||
=============
|
||||
Main Features
|
||||
=============
|
||||
|
||||
* New Partner and Contribution Register for Florida Department of Revenue
|
||||
* Company level Florida Unemployment Rate
|
||||
|
||||
.. image:: https://user-images.githubusercontent.com/15882954/41440232-a2ca8cb0-6fe2-11e8-9640-0bfd61ae6108.png
|
||||
:alt: 'Employee Contract Detail'
|
||||
:width: 988
|
||||
:align: left
|
||||
|
||||
USA Florida Employee Added to Contract Salary Structure Menu
|
||||
|
||||
.. image:: https://user-images.githubusercontent.com/15882954/41440247-b7b42744-6fe2-11e8-8ffb-d259eb893646.png
|
||||
:alt: 'Computed Pay Slip Detail'
|
||||
:width: 988
|
||||
:align: left
|
||||
|
||||
New Payslip Categories for:
|
||||
|
||||
* Florida Unemployment
|
||||
* Florida Unemployment - Wages
|
||||
|
||||
Upgrading to 2019
|
||||
==========================
|
||||
|
||||
If you were using this prior to January 2019, then you will need to run the following
|
||||
migration script.
|
||||
|
||||
Odoo Shell code::
|
||||
|
||||
def migrate_rule_name(rule_id):
|
||||
main = env.ref(rule_id)
|
||||
old_2017 = env.ref(rule_id.replace('2018', '2017'))
|
||||
old_2016 = env.ref(rule_id.replace('2018', '2016'))
|
||||
lines = env['hr.payslip.line'].search([('salary_rule_id', 'in', [old_2017.id, old_2016.id,])])
|
||||
lines.write({'salary_rule_id': main.id})
|
||||
|
||||
rules = [
|
||||
'l10n_us_fl_hr_payroll.hr_payroll_rules_fl_unemp_wages_2018',
|
||||
'l10n_us_fl_hr_payroll.hr_payroll_rules_fl_unemp_2018',
|
||||
]
|
||||
for rule_id in rules:
|
||||
migrate_rule_name(rule_id)
|
||||
|
||||
env.cr.commit()
|
||||
|
||||
|
||||
|
||||
=======
|
||||
License
|
||||
=======
|
||||
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/master/LICENSE>`_.
|
||||
Copyright Hibou Corp. 2018
|
||||
0
l10n_us_fl_hr_payroll/__init__.py
Executable file
0
l10n_us_fl_hr_payroll/__init__.py
Executable file
27
l10n_us_fl_hr_payroll/__manifest__.py
Executable file
27
l10n_us_fl_hr_payroll/__manifest__.py
Executable file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
'name': 'USA - Florida - 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::Florida Payroll Rules.
|
||||
===========================
|
||||
|
||||
* Florida Department of Revenue partner
|
||||
* Contribution register for Florida DoR
|
||||
* Company level Florida Unemployment Rate
|
||||
""",
|
||||
|
||||
'auto_install': False,
|
||||
'website': 'https://hibou.io/',
|
||||
'data':[
|
||||
'views/us_fl_hr_payroll_views.xml',
|
||||
'data/base.xml',
|
||||
'data/rates.xml',
|
||||
'data/rules.xml',
|
||||
'data/final.xml',
|
||||
],
|
||||
'installable': True
|
||||
}
|
||||
31
l10n_us_fl_hr_payroll/data/base.xml
Executable file
31
l10n_us_fl_hr_payroll/data/base.xml
Executable file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- CONTRIBUTION REGISTERS -->
|
||||
<record id="res_partner_fldor" model="res.partner">
|
||||
<field name="name">Florida Department of Revenue</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
<record id="contrib_register_fldor" model="hr.contribution.register">
|
||||
<field name="name">Florida Unemployment</field>
|
||||
<field name="note">Florida Department of Revenue - Unemployment</field>
|
||||
<field name="partner_id" ref="res_partner_fldor"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- HR SALARY RULE CATEGORIES-->
|
||||
<record id="hr_payroll_fl_unemp_wages" model="hr.salary.rule.category">
|
||||
<field name="name">Wage: US-FL Unemployment</field>
|
||||
<field name="code">WAGE_US_FL_UNEMP</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_fl_unemp" model="hr.salary.rule.category">
|
||||
<field name="name">ER: US-FL Unemployment</field>
|
||||
<field name="code">ER_US_FL_UNEMP</field>
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
18
l10n_us_fl_hr_payroll/data/final.xml
Executable file
18
l10n_us_fl_hr_payroll/data/final.xml
Executable file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR PAYROLL STRUCTURE -->
|
||||
<record id="hr_payroll_salary_structure_us_fl_employee" model="hr.payroll.structure">
|
||||
<field name="code">US_FL_EMP</field>
|
||||
<field name="name">USA Florida Employee</field>
|
||||
<field eval="[(6, 0, [
|
||||
ref('hr_payroll_rules_fl_unemp_wages_2018'),
|
||||
ref('hr_payroll_rules_fl_unemp_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>
|
||||
19
l10n_us_fl_hr_payroll/data/rates.xml
Normal file
19
l10n_us_fl_hr_payroll/data/rates.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="hr_payroll_rates_fl_unemp_2018" model="hr.payroll.rate">
|
||||
<field name="name">US Florida Unemployment</field>
|
||||
<field name="code">US_FL_UNEMP</field>
|
||||
<field name="rate">2.7</field>
|
||||
<field name="date_from">2018-01-01</field>
|
||||
<field name="wage_limit_year" eval="7000.0"/>
|
||||
</record>
|
||||
<record id="hr_payroll_rates_fl_unemp_2019" model="hr.payroll.rate">
|
||||
<field name="name">US Florida Unemployment</field>
|
||||
<field name="code">US_FL_UNEMP</field>
|
||||
<field name="rate">2.7</field>
|
||||
<field name="date_from">2019-01-01</field>
|
||||
<field name="wage_limit_year" eval="7000.0"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
52
l10n_us_fl_hr_payroll/data/rules.xml
Executable file
52
l10n_us_fl_hr_payroll/data/rules.xml
Executable file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR SALARY RULES-->
|
||||
<record id="hr_payroll_rules_fl_unemp_wages_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="423"/>
|
||||
<field name="category_id" ref="hr_payroll_fl_unemp_wages"/>
|
||||
<field name="name">Wage: US-FL Unemployment</field>
|
||||
<field name="code">WAGE_US_FL_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('US_FL_UNEMP')
|
||||
ytd = payslip.sum('WAGE_US_FL_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_fl_unemp_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="443"/>
|
||||
<field name="category_id" ref="hr_payroll_fl_unemp"/>
|
||||
<field name="name">ER: US-FL Unemployment</field>
|
||||
<field name="code">ER_US_FL_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_FL_UNEMP')
|
||||
result_rate = -rate.rate
|
||||
result = categories.WAGE_US_FL_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_fldor"/>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
2
l10n_us_fl_hr_payroll/tests/__init__.py
Executable file
2
l10n_us_fl_hr_payroll/tests/__init__.py
Executable file
@@ -0,0 +1,2 @@
|
||||
from . import test_us_fl_payslip_2018
|
||||
from . import test_us_fl_payslip_2019
|
||||
79
l10n_us_fl_hr_payroll/tests/test_us_fl_payslip_2018.py
Executable file
79
l10n_us_fl_hr_payroll/tests/test_us_fl_payslip_2018.py
Executable file
@@ -0,0 +1,79 @@
|
||||
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 TestUsFlPayslip(TestUsPayslip):
|
||||
###
|
||||
# 2018 Taxes and Rates
|
||||
###
|
||||
FL_UNEMP_MAX_WAGE = 7000.0
|
||||
FL_UNEMP = -2.7 / 100.0
|
||||
|
||||
def test_2018_taxes(self):
|
||||
salary = 5000.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_fl_hr_payroll.hr_payroll_salary_structure_us_fl_employee'))
|
||||
|
||||
self._log('2018 Florida 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_FL_UNEMP'], salary)
|
||||
self.assertPayrollEqual(cats['ER_US_FL_UNEMP'], cats['WAGE_US_FL_UNEMP'] * self.FL_UNEMP)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
# Make a new payslip, this one will have maximums
|
||||
|
||||
remaining_fl_unemp_wages = self.FL_UNEMP_MAX_WAGE - salary if (self.FL_UNEMP_MAX_WAGE - 2*salary < salary) \
|
||||
else salary
|
||||
|
||||
self._log('2018 Florida 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_FL_UNEMP'], remaining_fl_unemp_wages)
|
||||
self.assertPayrollEqual(cats['ER_US_FL_UNEMP'], remaining_fl_unemp_wages * self.FL_UNEMP)
|
||||
|
||||
def test_2018_taxes_with_external(self):
|
||||
salary = 5000.0
|
||||
external_wages = 6000.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, external_wages=external_wages,
|
||||
struct_id=self.ref('l10n_us_fl_hr_payroll.hr_payroll_salary_structure_us_fl_employee'))
|
||||
|
||||
self._log('2018 Forida_external 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_FL_UNEMP'], self.FL_UNEMP_MAX_WAGE - external_wages)
|
||||
self.assertPayrollEqual(cats['ER_US_FL_UNEMP'], cats['WAGE_US_FL_UNEMP'] * self.FL_UNEMP)
|
||||
|
||||
def test_2018_taxes_with_state_exempt(self):
|
||||
salary = 5000.0
|
||||
external_wages = 6000.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, external_wages=external_wages, struct_id=self.ref(
|
||||
'l10n_us_fl_hr_payroll.hr_payroll_salary_structure_us_fl_employee'), futa_type=USHrContract.FUTA_TYPE_BASIC)
|
||||
|
||||
self._log('2018 Forida_external tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats.get('WAGE_US_FL_UNEMP', 0.0), 0.0)
|
||||
self.assertPayrollEqual(cats.get('ER_US_FL_UNEMP', 0.0), 0.0)
|
||||
79
l10n_us_fl_hr_payroll/tests/test_us_fl_payslip_2019.py
Executable file
79
l10n_us_fl_hr_payroll/tests/test_us_fl_payslip_2019.py
Executable file
@@ -0,0 +1,79 @@
|
||||
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 TestUsFlPayslip(TestUsPayslip):
|
||||
###
|
||||
# 2019 Taxes and Rates
|
||||
###
|
||||
FL_UNEMP_MAX_WAGE = 7000.0
|
||||
FL_UNEMP = -2.7 / 100.0
|
||||
|
||||
def test_2019_taxes(self):
|
||||
salary = 5000.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_fl_hr_payroll.hr_payroll_salary_structure_us_fl_employee'))
|
||||
|
||||
self._log('2019 Florida 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_FL_UNEMP'], salary)
|
||||
self.assertPayrollEqual(cats['ER_US_FL_UNEMP'], cats['WAGE_US_FL_UNEMP'] * self.FL_UNEMP)
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
# Make a new payslip, this one will have maximums
|
||||
|
||||
remaining_fl_unemp_wages = self.FL_UNEMP_MAX_WAGE - salary if (self.FL_UNEMP_MAX_WAGE - 2*salary < salary) \
|
||||
else salary
|
||||
|
||||
self._log('2019 Florida 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_FL_UNEMP'], remaining_fl_unemp_wages)
|
||||
self.assertPayrollEqual(cats['ER_US_FL_UNEMP'], remaining_fl_unemp_wages * self.FL_UNEMP)
|
||||
|
||||
def test_2019_taxes_with_external(self):
|
||||
salary = 5000.0
|
||||
external_wages = 6000.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, external_wages=external_wages,
|
||||
struct_id=self.ref('l10n_us_fl_hr_payroll.hr_payroll_salary_structure_us_fl_employee'))
|
||||
|
||||
self._log('2019 Forida_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_FL_UNEMP'], self.FL_UNEMP_MAX_WAGE - external_wages)
|
||||
self.assertPayrollEqual(cats['ER_US_FL_UNEMP'], cats['WAGE_US_FL_UNEMP'] * self.FL_UNEMP)
|
||||
|
||||
def test_2019_taxes_with_state_exempt(self):
|
||||
salary = 5000.0
|
||||
external_wages = 6000.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
contract = self._createContract(employee, salary, external_wages=external_wages, struct_id=self.ref(
|
||||
'l10n_us_fl_hr_payroll.hr_payroll_salary_structure_us_fl_employee'), futa_type=USHrContract.FUTA_TYPE_BASIC)
|
||||
|
||||
self._log('2019 Forida_external tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2019-01-01', '2019-01-31')
|
||||
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats.get('WAGE_US_FL_UNEMP', 0.0), 0.0)
|
||||
self.assertPayrollEqual(cats.get('ER_US_FL_UNEMP', 0.0), 0.0)
|
||||
20
l10n_us_fl_hr_payroll/views/us_fl_hr_payroll_views.xml
Executable file
20
l10n_us_fl_hr_payroll/views/us_fl_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_fl_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.contract.form.inherit</field>
|
||||
<field name="model">hr.contract</field>
|
||||
<field name="priority">110</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="Florida" name="fl">
|
||||
<p>No additional fields.</p>
|
||||
</group>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user