mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
Initial commit of l10n_us_wa_hr_payroll for 11.0
This commit is contained in:
20
l10n_us_wa_hr_payroll/README.rst
Normal file
20
l10n_us_wa_hr_payroll/README.rst
Normal file
@@ -0,0 +1,20 @@
|
||||
*************************************
|
||||
Hibou - US Payroll - Washington State
|
||||
*************************************
|
||||
|
||||
Calculations and contribution registers for Washington State Payroll.
|
||||
|
||||
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
|
||||
|
||||
=============
|
||||
Main Features
|
||||
=============
|
||||
|
||||
* LNI (Labor and Industries) defined on HR Contracts that can be shared between contracts.
|
||||
* Company level State Unemployment Rate (SUTA)
|
||||
|
||||
=======
|
||||
License
|
||||
=======
|
||||
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/master/LICENSE>`_.
|
||||
Copyright Hibou Corp. 2018
|
||||
1
l10n_us_wa_hr_payroll/__init__.py
Normal file
1
l10n_us_wa_hr_payroll/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import hr_payroll
|
||||
28
l10n_us_wa_hr_payroll/__manifest__.py
Executable file
28
l10n_us_wa_hr_payroll/__manifest__.py
Executable file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
'name': 'USA - Washington - 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::Washington Payroll Rules.
|
||||
==============================
|
||||
|
||||
* Contribution register and partner for Washington Employment Security Department - Unemployment
|
||||
* Contribution register and partner for Washington Labor & Industries - (LNI)
|
||||
* Contract level LNI
|
||||
* Company level Washington Unemployment Rate
|
||||
""",
|
||||
|
||||
'auto_install': False,
|
||||
'website': 'https://hibou.io/',
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'hr_payroll_view.xml',
|
||||
'data/base.xml',
|
||||
'data/rules_2018.xml',
|
||||
'data/final.xml',
|
||||
],
|
||||
'installable': True
|
||||
}
|
||||
88
l10n_us_wa_hr_payroll/data/base.xml
Executable file
88
l10n_us_wa_hr_payroll/data/base.xml
Executable file
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<!-- CONTRIBUTION REGISTERS -->
|
||||
<record id="res_partner_wador_unemp" model="res.partner">
|
||||
<field name="name">Washington Employment Security Department - Unemployment Tax</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
<record id="res_partner_wador_lni" model="res.partner">
|
||||
<field name="name">Washington Labor & Industries - LNI</field>
|
||||
<field name="supplier">1</field>
|
||||
<field eval="0" name="customer"/>
|
||||
</record>
|
||||
<record id="contrib_register_wador_unemp" model="hr.contribution.register">
|
||||
<field name="name">Washington Employment</field>
|
||||
<field name="note">Washington Employment Security Department - Unemployment</field>
|
||||
<field name="partner_id" ref="res_partner_wador_unemp"/>
|
||||
</record>
|
||||
<record id="contrib_register_wador_lni" model="hr.contribution.register">
|
||||
<field name="name">Washington Labor & Industries</field>
|
||||
<field name="note">Washington Labor & Industries - LNI</field>
|
||||
<field name="partner_id" ref="res_partner_wador_lni"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- HR SALARY RULE CATEGORIES-->
|
||||
<record id="hr_payroll_wa_unemp_wages" model="hr.salary.rule.category">
|
||||
<field name="name">Washington Unemployment - Wages</field>
|
||||
<field name="code">WA_UNEMP_WAGES</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_wa_unemp" model="hr.salary.rule.category">
|
||||
<field name="name">Washington Unemployment</field>
|
||||
<field name="code">WA_UNEMP</field>
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_wa_lni" model="hr.salary.rule.category">
|
||||
<field name="name">Washington LNI</field>
|
||||
<field name="code">WA_LNI</field>
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<record id="hr_payroll_wa_lni_withhold" model="hr.salary.rule.category">
|
||||
<field name="name">Washington LNI Withholding</field>
|
||||
<field name="code">WA_LNI_WITHHOLD</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
|
||||
<!-- HR SALARY RULES -->
|
||||
<record id="hr_payroll_rules_wa_lni_withhold" model="hr.salary.rule">
|
||||
<field name="sequence" eval="150"/>
|
||||
<field name="category_id" ref="hr_payroll_wa_lni_withhold"/>
|
||||
<field name="name">Washington LNI Withholding</field>
|
||||
<field name="code">WA_LNI_WITHHOLD</field>
|
||||
<field name="condition_select">none</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">
|
||||
hours = worked_days.WORK100.number_of_hours
|
||||
rate = contract.wa_lni.rate_emp_withhold
|
||||
if rate:
|
||||
result = -(hours * rate)
|
||||
|
||||
</field>
|
||||
<field name="register_id" ref="contrib_register_wador_lni"/>
|
||||
</record>
|
||||
<record id="hr_payroll_rules_wa_lni" model="hr.salary.rule">
|
||||
<field name="sequence" eval="155"/>
|
||||
<field name="category_id" ref="hr_payroll_wa_lni"/>
|
||||
<field name="name">Washington LNI</field>
|
||||
<field name="code">WA_LNI</field>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
<field name="condition_select">none</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">
|
||||
hours = worked_days.WORK100.number_of_hours
|
||||
rate = contract.wa_lni.rate
|
||||
withholding = categories.WA_LNI_WITHHOLD
|
||||
if rate:
|
||||
result = -(hours * rate) - withholding
|
||||
|
||||
</field>
|
||||
<field name="register_id" ref="contrib_register_wador_lni"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
20
l10n_us_wa_hr_payroll/data/final.xml
Executable file
20
l10n_us_wa_hr_payroll/data/final.xml
Executable file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR PAYROLL STRUCTURE -->
|
||||
<record id="hr_payroll_salary_structure_us_wa_employee" model="hr.payroll.structure">
|
||||
<field name="code">US_WA_EMP</field>
|
||||
<field name="name">USA Washington Employee</field>
|
||||
<field eval="[(6, 0, [
|
||||
ref('hr_payroll_rules_wa_unemp_wages_2018'),
|
||||
ref('hr_payroll_rules_wa_unemp_2018'),
|
||||
ref('hr_payroll_rules_wa_lni'),
|
||||
ref('hr_payroll_rules_wa_lni_withhold'),
|
||||
])]" name="rule_ids"/>
|
||||
<field name="company_id" ref="base.main_company"/>
|
||||
<field name="parent_id" ref="l10n_us_hr_payroll.hr_payroll_salary_structure_us_employee"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
49
l10n_us_wa_hr_payroll/data/rules_2018.xml
Executable file
49
l10n_us_wa_hr_payroll/data/rules_2018.xml
Executable file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- HR SALARY RULES-->
|
||||
<record id="hr_payroll_rules_wa_unemp_wages_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="423"/>
|
||||
<field name="category_id" ref="hr_payroll_wa_unemp_wages"/>
|
||||
<field name="name">Washington Unemployment - Wages (2018)</field>
|
||||
<field name="code">WA_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('WA_UNEMP_WAGES_2018', '2018-01-01', '2019-01-01')
|
||||
ytd += contract.external_wages
|
||||
remaining = 47300.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_wa_unemp_2018" model="hr.salary.rule">
|
||||
<field name="sequence" eval="443"/>
|
||||
<field name="category_id" ref="hr_payroll_wa_unemp"/>
|
||||
<field name="name">Washington Unemployment (2018)</field>
|
||||
<field name="code">WA_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.wa_unemp_rate(2018)
|
||||
result = categories.WA_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_wador_unemp"/>
|
||||
<field name="appears_on_payslip" eval="False"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
33
l10n_us_wa_hr_payroll/hr_payroll.py
Executable file
33
l10n_us_wa_hr_payroll/hr_payroll.py
Executable file
@@ -0,0 +1,33 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class USWAHrContract(models.Model):
|
||||
_inherit = 'hr.contract'
|
||||
|
||||
wa_lni = fields.Many2one('hr.contract.lni.wa', string='WA State LNI')
|
||||
|
||||
@api.multi
|
||||
def wa_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, 'wa_unemp_rate_' + str(year)):
|
||||
return self.employee_id.company_id['wa_unemp_rate_' + str(year)]
|
||||
|
||||
raise NotImplemented('Year (' + str(year) + ') Not implemented for US Washington.')
|
||||
|
||||
|
||||
class WACompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
# No Defaults, need to sign up with the Employment Security Department
|
||||
wa_unemp_rate_2018 = fields.Float(string="Washington Unemployment Rate 2018", default=0.0)
|
||||
|
||||
|
||||
class WALNI(models.Model):
|
||||
_name = 'hr.contract.lni.wa'
|
||||
|
||||
name = fields.Char(string='Name')
|
||||
rate = fields.Float(string='Rate (per hour worked)', digits=(7, 6))
|
||||
rate_emp_withhold = fields.Float(string='Employee Payroll Deduction Rate (per hour worked)', digits=(7, 6))
|
||||
31
l10n_us_wa_hr_payroll/hr_payroll_view.xml
Executable file
31
l10n_us_wa_hr_payroll/hr_payroll_view.xml
Executable file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<record id="us_wa_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="wa_unemp_rate_2018"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
<record id="hr_contract_form_l10n_us_wa_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.contract.form.inherit</field>
|
||||
<field name="model">hr.contract</field>
|
||||
<field name="priority">64</field>
|
||||
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='w4_filing_status']" position="before">
|
||||
<field name="wa_lni"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
3
l10n_us_wa_hr_payroll/security/ir.model.access.csv
Normal file
3
l10n_us_wa_hr_payroll/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_hr_contract_lni_wa,access_hr_contract_lni_wa,model_hr_contract_lni_wa,base.group_user,1,0,0,0
|
||||
manage_hr_contract_lni_wa,manage_hr_contract_lni_wa,model_hr_contract_lni_wa,hr_payroll.group_hr_payroll_manager,1,1,1,1
|
||||
|
1
l10n_us_wa_hr_payroll/tests/__init__.py
Executable file
1
l10n_us_wa_hr_payroll/tests/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from . import test_us_wa_payslip_2018
|
||||
61
l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2018.py
Executable file
61
l10n_us_wa_hr_payroll/tests/test_us_wa_payslip_2018.py
Executable file
@@ -0,0 +1,61 @@
|
||||
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 TestUsWAPayslip(TestUsPayslip):
|
||||
###
|
||||
# Taxes and Rates
|
||||
###
|
||||
WA_UNEMP_MAX_WAGE = 47300.0
|
||||
|
||||
def setUp(self):
|
||||
super(TestUsWAPayslip, self).setUp()
|
||||
self.lni = self.env['hr.contract.lni.wa'].create({
|
||||
'name': '5302 Computer Consulting',
|
||||
'rate': 0.1261,
|
||||
'rate_emp_withhold': 0.05575,
|
||||
})
|
||||
|
||||
def test_2018_taxes(self):
|
||||
salary = 25000.0
|
||||
|
||||
employee = self._createEmployee()
|
||||
employee.company_id.wa_unemp_rate_2018 = 1.16
|
||||
|
||||
contract = self._createContract(employee, salary, struct_id=self.ref('l10n_us_wa_hr_payroll.hr_payroll_salary_structure_us_wa_employee'))
|
||||
self._log(str(contract.resource_calendar_id) + ' ' + contract.resource_calendar_id.name)
|
||||
contract.wa_lni = self.lni
|
||||
|
||||
# tax rates
|
||||
wa_unemp = contract.wa_unemp_rate(2018) / -100.0
|
||||
|
||||
self._log('2018 Washington tax first payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-01-01', '2018-01-31')
|
||||
payslip.onchange_contract()
|
||||
hours_in_period = payslip.worked_days_line_ids.filtered(lambda l: l.code == 'WORK100').number_of_hours
|
||||
payslip.compute_sheet()
|
||||
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['WA_UNEMP_WAGES'], salary)
|
||||
self.assertPayrollEqual(cats['WA_UNEMP'], cats['WA_UNEMP_WAGES'] * wa_unemp)
|
||||
self.assertPayrollEqual(cats['WA_LNI_WITHHOLD'], -(self.lni.rate_emp_withhold * hours_in_period))
|
||||
self.assertPayrollEqual(cats['WA_LNI'], -(self.lni.rate * hours_in_period) - cats['WA_LNI_WITHHOLD'])
|
||||
|
||||
process_payslip(payslip)
|
||||
|
||||
# Make a new payslip, this one will have maximums
|
||||
|
||||
remaining_wa_unemp_wages = self.WA_UNEMP_MAX_WAGE - salary if (self.WA_UNEMP_MAX_WAGE - 2*salary < salary) \
|
||||
else salary
|
||||
|
||||
self._log('2018 Washington tax second payslip:')
|
||||
payslip = self._createPayslip(employee, '2018-02-01', '2018-02-28')
|
||||
payslip.onchange_contract()
|
||||
payslip.compute_sheet()
|
||||
|
||||
cats = self._getCategories(payslip)
|
||||
|
||||
self.assertPayrollEqual(cats['WA_UNEMP_WAGES'], remaining_wa_unemp_wages)
|
||||
self.assertPayrollEqual(cats['WA_UNEMP'], remaining_wa_unemp_wages * wa_unemp)
|
||||
Reference in New Issue
Block a user