mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[REM] l10n_us_hr_payroll_401k: available in professional
H14528
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
@@ -1,25 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'USA - 401K Payroll',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'version': '15.0.1.0.0',
|
||||
'category': 'Payroll',
|
||||
'depends': [
|
||||
'l10n_us_hr_payroll',
|
||||
],
|
||||
'description': """
|
||||
* Adds fields to HR Contract for amount or percentage to withhold for retirement savings.
|
||||
* Adds rules to withhold and have a company match.
|
||||
""",
|
||||
|
||||
'data': [
|
||||
'data/payroll.xml',
|
||||
'views/contract_views.xml',
|
||||
'views/payroll_views.xml',
|
||||
],
|
||||
'demo': [
|
||||
],
|
||||
'auto_install': False,
|
||||
'license': 'OPL-1',
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- Partners and Contribution Registers -->
|
||||
<record id="res_partner_ira_provider" model="res.partner">
|
||||
<field name="name">IRA Provider</field>
|
||||
<field name="supplier_rank">1</field>
|
||||
</record>
|
||||
|
||||
<!-- Rule Parameters -->
|
||||
<record id="rule_parameter_ee_401k_contribution_limit" model="hr.rule.parameter">
|
||||
<field name="name">Employee 401K Contribution Limit</field>
|
||||
<field name="code">ee_401k_contribution_limit</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<record id="rule_parameter_ee_401k_contribution_limit_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">19500.0</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_ee_401k_contribution_limit"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
|
||||
<record id="rule_parameter_ee_401k_catchup" model="hr.rule.parameter">
|
||||
<field name="name">Employee 401K Catch-up</field>
|
||||
<field name="code">ee_401k_catchup</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<record id="rule_parameter_ee_401k_catchup_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">6500.0</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_ee_401k_catchup"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
|
||||
<record id="rule_parameter_er_401k_contribution_limit" model="hr.rule.parameter">
|
||||
<field name="name">Employer 401K Contribution Limit</field>
|
||||
<field name="code">er_401k_contribution_limit</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<record id="rule_parameter_er_401k_contribution_limit_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">37500.0</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_er_401k_contribution_limit"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
|
||||
<record id="rule_parameter_er_401k_match_percent" model="hr.rule.parameter">
|
||||
<field name="name">Employer 401K Match (%)</field>
|
||||
<field name="code">er_401k_match_percent</field>
|
||||
<field name="country_id" ref="base.us"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
<record id="rule_parameter_er_401k_match_percent_2020" model="hr.rule.parameter.value">
|
||||
<field name="parameter_value">0.0</field>
|
||||
<field name="rule_parameter_id" ref="rule_parameter_er_401k_match_percent"/>
|
||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<!-- Categories -->
|
||||
<record id="category_ee_401k_traditional" model="hr.salary.rule.category">
|
||||
<field name="name">EE: 401K Traditional</field>
|
||||
<field name="code">EE_IRA</field>
|
||||
<field name="parent_id" ref="l10n_us_hr_payroll.hr_payroll_category_ded_fit_exempt"/>
|
||||
</record>
|
||||
<record id="category_ee_401k_roth" model="hr.salary.rule.category">
|
||||
<field name="name">EE: 401K Roth</field>
|
||||
<field name="code">EE_IRA_ROTH</field>
|
||||
<field name="parent_id" ref="hr_payroll.DED"/>
|
||||
</record>
|
||||
<!-- It is impossible for only match to meet the limits, but the category exists
|
||||
and the limits are checked against this category. -->
|
||||
<record id="category_er_401k" model="hr.salary.rule.category">
|
||||
<field name="name">ER: 401K Contribution</field>
|
||||
<field name="code">ER_IRA</field>
|
||||
<field name="parent_id" ref="hr_payroll.COMP"/>
|
||||
</record>
|
||||
|
||||
<!-- Rules -->
|
||||
<record id="rule_ee_ira" model="hr.salary.rule">
|
||||
<field name="sequence" eval="110"/>
|
||||
<field name="struct_id" ref="l10n_us_hr_payroll.hr_payroll_structure"/>
|
||||
<field name="category_id" ref="category_ee_401k_traditional"/>
|
||||
<field name="name">EE: 401K</field>
|
||||
<field name="code">EE_IRA</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result = ee_401k(contract.ira_amount, contract.ira_rate, payslip, categories, worked_days, inputs)</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">result = ee_401k(contract.ira_amount, contract.ira_rate, payslip, categories, worked_days, inputs)</field>
|
||||
<field name="appears_on_payslip" eval="True"/>
|
||||
<field name="partner_id" ref="res_partner_ira_provider"/>
|
||||
</record>
|
||||
|
||||
<record id="rule_ee_ira_roth" model="hr.salary.rule">
|
||||
<field name="sequence" eval="196"/>
|
||||
<field name="struct_id" ref="l10n_us_hr_payroll.hr_payroll_structure"/>
|
||||
<field name="category_id" ref="category_ee_401k_roth"/>
|
||||
<field name="name">EE: 401K Roth</field>
|
||||
<field name="code">EE_IRA_ROTH</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result = ee_401k(contract.ira_roth_amount, contract.ira_roth_rate, payslip, categories, worked_days, inputs)</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">result = ee_401k(contract.ira_roth_amount, contract.ira_roth_rate, payslip, categories, worked_days, inputs)</field>
|
||||
<field name="appears_on_payslip" eval="True"/>
|
||||
<field name="partner_id" ref="res_partner_ira_provider"/>
|
||||
</record>
|
||||
|
||||
<record id="rule_er_ira" model="hr.salary.rule">
|
||||
<field name="sequence" eval="445"/>
|
||||
<field name="struct_id" ref="l10n_us_hr_payroll.hr_payroll_structure"/>
|
||||
<field name="category_id" ref="category_er_401k"/>
|
||||
<field name="name">ER: 401K Match</field>
|
||||
<field name="code">ER_IRA_MATCH</field>
|
||||
<field name="condition_select">python</field>
|
||||
<field name="condition_python">result = er_401k_match(categories.BASIC, payslip, categories, worked_days, inputs)</field>
|
||||
<field name="amount_select">code</field>
|
||||
<field name="amount_python_compute">result = er_401k_match(categories.BASIC, payslip, categories, worked_days, inputs)</field>
|
||||
<!-- Normally company contributions are not on Payslip, but this is an additional amount -->
|
||||
<field name="appears_on_payslip" eval="True"/>
|
||||
<field name="partner_id" ref="res_partner_ira_provider"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,102 +0,0 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * l10n_us_hr_payroll_401k
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 15.0+e\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-10-12 01:34+0000\n"
|
||||
"PO-Revision-Date: 2021-10-12 01:34+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model_terms:ir.ui.view,arch_db:l10n_us_hr_payroll_401k.hr_contract_view_form_inherit
|
||||
msgid "401K"
|
||||
msgstr "401K"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,field_description:l10n_us_hr_payroll_401k.field_hr_contract__ira_rate
|
||||
msgid "401K Contribution (%)"
|
||||
msgstr "Contribución (%) de 401K"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,field_description:l10n_us_hr_payroll_401k.field_hr_contract__ira_amount
|
||||
msgid "401K Contribution Amount"
|
||||
msgstr "Monto de Contribución de 401K"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:hr.salary.rule,name:l10n_us_hr_payroll_401k.rule_ee_ira
|
||||
msgid "EE: 401K"
|
||||
msgstr "EE: 401K"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:hr.salary.rule,name:l10n_us_hr_payroll_401k.rule_ee_ira_roth
|
||||
#: model:hr.salary.rule.category,name:l10n_us_hr_payroll_401k.category_ee_401k_roth
|
||||
msgid "EE: 401K Roth"
|
||||
msgstr "EE: 401K Roth"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:hr.salary.rule.category,name:l10n_us_hr_payroll_401k.category_ee_401k_traditional
|
||||
msgid "EE: 401K Traditional"
|
||||
msgstr "EE: 401K Tradicional"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:hr.salary.rule.category,name:l10n_us_hr_payroll_401k.category_er_401k
|
||||
msgid "ER: 401K Contribution"
|
||||
msgstr "ER: 401K Contribución"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:hr.salary.rule,name:l10n_us_hr_payroll_401k.rule_er_ira
|
||||
msgid "ER: 401K Match"
|
||||
msgstr "ER: 401K Aportación Paralela"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model,name:l10n_us_hr_payroll_401k.model_hr_contract
|
||||
msgid "Employee Contract"
|
||||
msgstr "Contrato del empleado"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model,name:l10n_us_hr_payroll_401k.model_hr_payslip
|
||||
msgid "Pay Slip"
|
||||
msgstr "Recibo de nómina"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,help:l10n_us_hr_payroll_401k.field_hr_contract__ira_roth_amount
|
||||
msgid "Post-Tax Contribution Amount"
|
||||
msgstr "Monto de contribución tras impuestos"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,help:l10n_us_hr_payroll_401k.field_hr_contract__ira_roth_rate
|
||||
msgid "Post-Tax Contribution Percentage"
|
||||
msgstr "Porcentaje de contribución tras impuestos"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,help:l10n_us_hr_payroll_401k.field_hr_contract__ira_amount
|
||||
msgid "Pre-Tax (traditional) Contribution Amount"
|
||||
msgstr "Monto de contribución pre impuestos (tradicional)"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,help:l10n_us_hr_payroll_401k.field_hr_contract__ira_rate
|
||||
msgid "Pre-Tax (traditional) Contribution Percentage"
|
||||
msgstr "Porcentaje de contribución pre impuestos (Tradicional)"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,field_description:l10n_us_hr_payroll_401k.field_hr_contract__ira_roth_rate
|
||||
msgid "Roth 401K Contribution (%)"
|
||||
msgstr "Contribución (%) de Roth 401K"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model:ir.model.fields,field_description:l10n_us_hr_payroll_401k.field_hr_contract__ira_roth_amount
|
||||
msgid "Roth 401K Contribution Amount"
|
||||
msgstr "Monto de Contribución de Roth 401K"
|
||||
|
||||
#. module: l10n_us_hr_payroll_401k
|
||||
#: model_terms:ir.ui.view,arch_db:l10n_us_hr_payroll_401k.hr_rule_parameter_view_search_inherit
|
||||
msgid "US Payroll 401k"
|
||||
msgstr "Nómina de EE.UU 401K"
|
||||
@@ -1,22 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
import odoo
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
"""
|
||||
Salary Rules can be archived by Odoo S.A. during migration.
|
||||
This leaves them archived after the migration, and even un-archiving them
|
||||
is not enough because they will then be pointed to a "migrated" structure.
|
||||
"""
|
||||
env = odoo.api.Environment(cr, odoo.SUPERUSER_ID, {})
|
||||
xml_refs = env['ir.model.data'].search([
|
||||
('module', '=', 'l10n_us_hr_payroll_401k'),
|
||||
('model', '=', 'hr.salary.rule'),
|
||||
])
|
||||
# I don't know why Odoo makes these non-updatable...
|
||||
xml_refs.write({'noupdate': False})
|
||||
|
||||
rule_ids = xml_refs.mapped('res_id')
|
||||
rules = env['hr.salary.rule'].browse(rule_ids)
|
||||
rules.write({'active': True})
|
||||
@@ -1,5 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from . import contract
|
||||
from . import payslip
|
||||
from . import update
|
||||
@@ -1,21 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class HRContract(models.Model):
|
||||
_inherit = 'hr.contract'
|
||||
|
||||
ira_amount = fields.Float(string="401K Contribution Amount",
|
||||
help="Pre-Tax (traditional) Contribution Amount")
|
||||
ira_rate = fields.Float(string="401K Contribution (%)",
|
||||
help="Pre-Tax (traditional) Contribution Percentage")
|
||||
ira_roth_amount = fields.Float(string="Roth 401K Contribution Amount",
|
||||
help="Post-Tax Contribution Amount")
|
||||
ira_roth_rate = fields.Float(string="Roth 401K Contribution (%)",
|
||||
help="Post-Tax Contribution Percentage")
|
||||
|
||||
def company_401k_match_percent(self, payslip):
|
||||
# payslip is payslip rule's current payslip browse object
|
||||
# Override if you have employee, payslip, or contract differences.
|
||||
return payslip.rule_parameter('er_401k_match_percent')
|
||||
@@ -1,83 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from datetime import date
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
def ee_401k(amount, rate, payslip, categories, worked_days, inputs):
|
||||
MAX = payslip.rule_parameter('ee_401k_contribution_limit')
|
||||
if payslip.dict.ira_period_age() >= 50:
|
||||
MAX += payslip.rule_parameter('ee_401k_catchup')
|
||||
wages = categories.BASIC
|
||||
year = payslip.date_to.year
|
||||
next_year = str(year + 1)
|
||||
from_ = str(year) + '-01-01'
|
||||
to = next_year + '-01-01'
|
||||
ytd = payslip.sum_category('EE_IRA', from_, to)
|
||||
ytd += payslip.sum_category('EE_IRA_ROTH', from_, to)
|
||||
remaining = MAX + ytd
|
||||
if remaining <= 0.0:
|
||||
result = 0
|
||||
else:
|
||||
result = -amount
|
||||
result -= (wages * rate) / 100.0
|
||||
if remaining + result <= 0.0:
|
||||
result = -remaining
|
||||
return result
|
||||
|
||||
|
||||
def er_401k_match(wages, payslip, categories, worked_days, inputs):
|
||||
MAX = payslip.rule_parameter('er_401k_contribution_limit')
|
||||
employee_contrib = -(categories.EE_IRA + categories.EE_IRA_ROTH)
|
||||
|
||||
year = payslip.date_to.year
|
||||
next_year = str(year + 1)
|
||||
from_ = str(year) + '-01-01'
|
||||
to = next_year + '-01-01'
|
||||
ytd = payslip.sum_category('ER_IRA', from_, to)
|
||||
|
||||
rate = payslip.contract_id.company_401k_match_percent(payslip)
|
||||
wages_match = (wages * rate) / 100.0
|
||||
if employee_contrib <= wages_match:
|
||||
result = employee_contrib
|
||||
else:
|
||||
result = wages_match
|
||||
remaining = MAX - ytd
|
||||
if remaining <= 0.0:
|
||||
result = 0
|
||||
else:
|
||||
if remaining - result < 0.0:
|
||||
result = remaining
|
||||
return -result
|
||||
|
||||
|
||||
class HRPayslip(models.Model):
|
||||
_inherit = 'hr.payslip'
|
||||
|
||||
def _age_on_date(self, birthday, cutoff):
|
||||
if isinstance(cutoff, str):
|
||||
try:
|
||||
cutoff = fields.Date.from_string(cutoff)
|
||||
except:
|
||||
cutoff = None
|
||||
if cutoff is None:
|
||||
# Dec. 31st in calendar year
|
||||
cutoff = date(self.date_to.year, 12, 31)
|
||||
if not birthday:
|
||||
return -1
|
||||
years = cutoff.year - birthday.year
|
||||
if birthday.month > cutoff.month or (birthday.month == cutoff.month and birthday.day > cutoff.day):
|
||||
years -= 1
|
||||
return years
|
||||
|
||||
def ira_period_age(self, cutoff=None):
|
||||
birthday = self.employee_id.birthday
|
||||
return self._age_on_date(birthday, cutoff)
|
||||
|
||||
def _get_base_local_dict(self):
|
||||
res = super()._get_base_local_dict()
|
||||
res.update({
|
||||
'ee_401k': ee_401k,
|
||||
'er_401k_match': er_401k_match,
|
||||
})
|
||||
return res
|
||||
@@ -1,13 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class PublisherWarrantyContract(models.AbstractModel):
|
||||
_inherit = 'publisher_warranty.contract'
|
||||
|
||||
@api.model
|
||||
def hibou_payroll_modules_to_update(self):
|
||||
res = super().hibou_payroll_modules_to_update()
|
||||
res.append('l10n_us_hr_payroll_401k')
|
||||
return res
|
||||
@@ -1,3 +0,0 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
# Moved to l10n_us_hr_payroll_401k_params
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="hr_contract_view_form_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.contract.form.inherit</field>
|
||||
<field name="model">hr.contract</field>
|
||||
<field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='salary_info']" position="after">
|
||||
<group name="usa_advantages_401k" string="401K">
|
||||
<field name="ira_amount"/>
|
||||
<field name="ira_rate"/>
|
||||
<field name="ira_roth_amount"/>
|
||||
<field name="ira_roth_rate"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<record id="hr_rule_parameter_view_search_inherit" model="ir.ui.view">
|
||||
<field name="name">hr.rule.parameter.search.inherit</field>
|
||||
<field name="model">hr.rule.parameter</field>
|
||||
<field name="inherit_id" ref="hr_payroll.hr_rule_parameter_view_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//search" position="inside">
|
||||
<filter name="us_payroll_401k"
|
||||
domain="[('code', 'ilike', '401k')]"
|
||||
string="US Payroll 401k"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user