mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] l10n_pe_hr_payroll: numerous improvements and simplifications (list)
Removed partners as chart of accounts is detailed enough to allow reconciliation. No support for EPS as discussed as legacy. No wage base, but rather 'monthly maximum' on Seguo. NEEDS IR 5TH CAT. refactor to use partial pay period and true up on month 6 and 12
This commit is contained in:
@@ -26,7 +26,6 @@ Peru - Payroll Rules.
|
|||||||
'data/er_rules.xml',
|
'data/er_rules.xml',
|
||||||
'views/hr_contract_views.xml',
|
'views/hr_contract_views.xml',
|
||||||
'views/pe_payroll_config_views.xml',
|
'views/pe_payroll_config_views.xml',
|
||||||
'views/res_config_settings_views.xml',
|
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -19,11 +19,6 @@
|
|||||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Partner -->
|
|
||||||
<record id="res_partner_afp" model="res.partner">
|
|
||||||
<field name="name">AFP</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- EE Rules -->
|
<!-- EE Rules -->
|
||||||
<record id="hr_payroll_rule_ee_afp_pensiones" model="hr.salary.rule">
|
<record id="hr_payroll_rule_ee_afp_pensiones" model="hr.salary.rule">
|
||||||
<field name="sequence" eval="190"/>
|
<field name="sequence" eval="190"/>
|
||||||
@@ -35,7 +30,6 @@
|
|||||||
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp'</field>
|
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp'</field>
|
||||||
<field name="amount_select">code</field>
|
<field name="amount_select">code</field>
|
||||||
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][4]</field>
|
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][4]</field>
|
||||||
<field name="partner_id" ref="res_partner_afp"/>
|
|
||||||
<field name="appears_on_payslip" eval="True"/>
|
<field name="appears_on_payslip" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -49,14 +43,16 @@
|
|||||||
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp'</field>
|
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp'</field>
|
||||||
<field name="amount_select">code</field>
|
<field name="amount_select">code</field>
|
||||||
<field name="amount_python_compute">
|
<field name="amount_python_compute">
|
||||||
year = payslip.dict.get_year()
|
|
||||||
ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year+1) + '-01-01')
|
|
||||||
wage = categories.GROSS
|
wage = categories.GROSS
|
||||||
wage_base = payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][5]
|
# wage_max is monthly
|
||||||
rate = payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][3]
|
wage_max = payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][5]
|
||||||
result, result_rate = general_rate(payslip, wage, ytd_wage, wage_base=wage_base, rate=rate)
|
# normalize wage_max to pay period
|
||||||
|
pay_periods_in_year = payslip.pay_periods_in_year
|
||||||
|
wage_max = (wage_max * 12.0) / pay_periods_in_year
|
||||||
|
eligible_wage = min(wage, wage_max)
|
||||||
|
rate = -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][3]
|
||||||
|
result, result_rate = eligible_wage, rate
|
||||||
</field>
|
</field>
|
||||||
<field name="partner_id" ref="res_partner_afp"/>
|
|
||||||
<field name="appears_on_payslip" eval="True"/>
|
<field name="appears_on_payslip" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -70,7 +66,6 @@ result, result_rate = general_rate(payslip, wage, ytd_wage, wage_base=wage_base,
|
|||||||
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' and contract.pe_payroll_config_value('afp_comision_type') == 'mixta'</field>
|
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' and contract.pe_payroll_config_value('afp_comision_type') == 'mixta'</field>
|
||||||
<field name="amount_select">code</field>
|
<field name="amount_select">code</field>
|
||||||
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][1]</field>
|
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][1]</field>
|
||||||
<field name="partner_id" ref="res_partner_afp"/>
|
|
||||||
<field name="appears_on_payslip" eval="True"/>
|
<field name="appears_on_payslip" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
@@ -84,7 +79,6 @@ result, result_rate = general_rate(payslip, wage, ytd_wage, wage_base=wage_base,
|
|||||||
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' and contract.pe_payroll_config_value('afp_comision_type') == 'non_mixta'</field>
|
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' and contract.pe_payroll_config_value('afp_comision_type') == 'non_mixta'</field>
|
||||||
<field name="amount_select">code</field>
|
<field name="amount_select">code</field>
|
||||||
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][0]</field>
|
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][0]</field>
|
||||||
<field name="partner_id" ref="res_partner_afp"/>
|
|
||||||
<field name="appears_on_payslip" eval="True"/>
|
<field name="appears_on_payslip" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,10 @@
|
|||||||
<record id="input_type_bono" model="hr.payslip.input.type">
|
<record id="input_type_bono" model="hr.payslip.input.type">
|
||||||
<field name="name">Bono</field>
|
<field name="name">Bono</field>
|
||||||
<field name="code">BONO</field>
|
<field name="code">BONO</field>
|
||||||
|
<field name="country_id" ref="base.pe" />
|
||||||
|
<field name="struct_ids" eval="[
|
||||||
|
(4, ref('l10n_pe_hr_payroll.hr_payroll_structure')),
|
||||||
|
]" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="hr_salary_rule_bonus" model="hr.salary.rule">
|
<record id="hr_salary_rule_bonus" model="hr.salary.rule">
|
||||||
|
|||||||
@@ -13,11 +13,6 @@
|
|||||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Partner -->
|
|
||||||
<record id="res_partner_essalud" model="res.partner">
|
|
||||||
<field name="name">Essalud</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- ER Rules -->
|
<!-- ER Rules -->
|
||||||
<record id="hr_payroll_rule_er_essalud" model="hr.salary.rule">
|
<record id="hr_payroll_rule_er_essalud" model="hr.salary.rule">
|
||||||
<field name="sequence" eval="220"/>
|
<field name="sequence" eval="220"/>
|
||||||
@@ -29,7 +24,6 @@
|
|||||||
<field name="condition_python">result = categories.BASIC</field>
|
<field name="condition_python">result = categories.BASIC</field>
|
||||||
<field name="amount_select">code</field>
|
<field name="amount_select">code</field>
|
||||||
<field name="amount_python_compute">result, result_rate = categories.BASIC, -payslip.rule_parameter('er_essalud')</field>
|
<field name="amount_python_compute">result, result_rate = categories.BASIC, -payslip.rule_parameter('er_essalud')</field>
|
||||||
<field name="partner_id" ref="res_partner_afp"/>
|
|
||||||
<field name="appears_on_payslip" eval="True"/>
|
<field name="appears_on_payslip" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,6 @@
|
|||||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Partner -->
|
|
||||||
<record id="res_partner_ir_5ta_cat" model="res.partner">
|
|
||||||
<field name="name">IR 5ta Cat.</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- EE Rules -->
|
<!-- EE Rules -->
|
||||||
<record id="hr_payroll_rule_ee_ir_5ta_cat" model="hr.salary.rule">
|
<record id="hr_payroll_rule_ee_ir_5ta_cat" model="hr.salary.rule">
|
||||||
<field name="sequence" eval="196"/>
|
<field name="sequence" eval="196"/>
|
||||||
@@ -55,7 +50,9 @@ wage_period = categories.GROSS
|
|||||||
period_additional_wage = max(wage_period - basic_wage, 0.0)
|
period_additional_wage = max(wage_period - basic_wage, 0.0)
|
||||||
wage_year = basic_wage * pay_periods_in_year
|
wage_year = basic_wage * pay_periods_in_year
|
||||||
# additional 2 months (July and December)
|
# additional 2 months (July and December)
|
||||||
wage_year += wage_year * (1/6) # 2 months 2/12
|
wage_2 = wage_year * (1/6)
|
||||||
|
wage_3 = wage_2 * 0.09 # TODO paramatarize 9% # 2 months 2/12
|
||||||
|
wage_year += wage_2 + wage_3
|
||||||
wage_year += period_additional_wage
|
wage_year += period_additional_wage
|
||||||
|
|
||||||
over_7uit = wage_year - (7.0 * uit)
|
over_7uit = wage_year - (7.0 * uit)
|
||||||
@@ -76,9 +73,8 @@ else:
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
last_uit = _uit
|
last_uit = _uit
|
||||||
tax = -total_tax / 12.0
|
tax = -total_tax / pay_periods_in_year
|
||||||
result, result_rate = wage_period, (tax / wage_period * 100.0)</field>
|
result, result_rate = wage_period, (tax / wage_period * 100.0)</field>
|
||||||
<field name="partner_id" ref="res_partner_ir_5ta_cat"/>
|
|
||||||
<field name="appears_on_payslip" eval="True"/>
|
<field name="appears_on_payslip" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,6 @@
|
|||||||
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
<field name="date_from" eval="datetime(2020, 1, 1).date()"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Partner -->
|
|
||||||
<record id="res_partner_onp" model="res.partner">
|
|
||||||
<field name="name">ONP</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- EE Rules -->
|
<!-- EE Rules -->
|
||||||
<record id="hr_payroll_rule_ee_onp" model="hr.salary.rule">
|
<record id="hr_payroll_rule_ee_onp" model="hr.salary.rule">
|
||||||
<field name="sequence" eval="190"/>
|
<field name="sequence" eval="190"/>
|
||||||
@@ -26,10 +21,9 @@
|
|||||||
<field name="name">EE: PE ONP/SNP</field>
|
<field name="name">EE: PE ONP/SNP</field>
|
||||||
<field name="code">EE_PE_ONP</field>
|
<field name="code">EE_PE_ONP</field>
|
||||||
<field name="condition_select">python</field>
|
<field name="condition_select">python</field>
|
||||||
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'onp' and rule == contract.pe_payroll_config_value('onp_rule_id')</field>
|
<field name="condition_python">result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'onp'</field>
|
||||||
<field name="amount_select">code</field>
|
<field name="amount_select">code</field>
|
||||||
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_onp')</field>
|
<field name="amount_python_compute">result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_onp')</field>
|
||||||
<field name="partner_id" ref="res_partner_onp"/>
|
|
||||||
<field name="appears_on_payslip" eval="True"/>
|
<field name="appears_on_payslip" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|||||||
@@ -3,5 +3,4 @@
|
|||||||
from . import hr_contract
|
from . import hr_contract
|
||||||
from . import hr_payslip
|
from . import hr_payslip
|
||||||
from . import pe_payroll_config
|
from . import pe_payroll_config
|
||||||
from . import res_config_settings
|
|
||||||
from . import update
|
from . import update
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ class HRContractPEPayrollConfig(models.Model):
|
|||||||
('retired', 'Retired'),
|
('retired', 'Retired'),
|
||||||
], string='Retirement Type', required=True, default='afp')
|
], string='Retirement Type', required=True, default='afp')
|
||||||
|
|
||||||
onp_rule_id = fields.Many2one('hr.salary.rule', string='ONP Rule', domain=[('code', '=like', 'EE_PE_ONP%')])
|
|
||||||
|
|
||||||
# AFP Type may actually be company specific....
|
# AFP Type may actually be company specific....
|
||||||
afp_type = fields.Selection([
|
afp_type = fields.Selection([
|
||||||
('habitat', 'Habitat'),
|
('habitat', 'Habitat'),
|
||||||
@@ -34,6 +32,6 @@ class HRContractPEPayrollConfig(models.Model):
|
|||||||
('essalud', 'Essalud'),
|
('essalud', 'Essalud'),
|
||||||
('eps', 'EPS'),
|
('eps', 'EPS'),
|
||||||
], string='Company Social Services', default='essalud')
|
], string='Company Social Services', default='essalud')
|
||||||
comp_ss_eps_rule_id = fields.Many2one('hr.salary.rule', string='Company Social Security EPS Rule')
|
comp_ss_eps_rule_id = fields.Many2one('hr.salary.rule', string='Company Social Security EPS Rule',
|
||||||
comp_life_insurance_rule_id = fields.Many2one('hr.salary.rule', string='Company Life Insurance Rule')
|
domain=[('code', '=like', 'ER_PE_EPS%')],
|
||||||
comp_risk_insurance_rule_id = fields.Many2one('hr.salary.rule', string='Company Risk Insurance Rule')
|
help="Rule code prefix 'ER_PE_EPS' to select here.")
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class ResConfigSettings(models.TransientModel):
|
|
||||||
_inherit = 'res.config.settings'
|
|
||||||
|
|
||||||
payslip_sum_type = fields.Selection([
|
|
||||||
('date_from', 'Date From'),
|
|
||||||
('date_to', 'Date To'),
|
|
||||||
('date', 'Accounting Date'),
|
|
||||||
], 'Payslip Sum Behavior', help="Behavior for what payslips are considered "
|
|
||||||
"during rule execution. Stock Odoo behavior "
|
|
||||||
"would not consider a payslip starting on 2019-12-30 "
|
|
||||||
"ending on 2020-01-07 when summing a 2020 payslip category.\n\n"
|
|
||||||
"Accounting Date requires Payroll Accounting and will "
|
|
||||||
"fall back to date_to as the 'closest behavior'.",
|
|
||||||
config_parameter='hr_payroll.payslip.sum_behavior')
|
|
||||||
|
|
||||||
def set_values(self):
|
|
||||||
super(ResConfigSettings, self).set_values()
|
|
||||||
self.env['ir.config_parameter'].set_param('hr_payroll.payslip.sum_behavior',
|
|
||||||
self.payslip_sum_type or 'date_from')
|
|
||||||
@@ -27,15 +27,13 @@
|
|||||||
<group>
|
<group>
|
||||||
<group name="employee" string="Employee">
|
<group name="employee" string="Employee">
|
||||||
<field name="retirement_type"/>
|
<field name="retirement_type"/>
|
||||||
<field name="onp_rule_id" attrs="{'invisible': [('retirement_type', '!=', 'onp')]}"/>
|
|
||||||
<field name="afp_type" attrs="{'invisible': [('retirement_type', '!=', 'afp')]}"/>
|
<field name="afp_type" attrs="{'invisible': [('retirement_type', '!=', 'afp')]}"/>
|
||||||
<field name="afp_comision_type" attrs="{'invisible': [('retirement_type', '!=', 'afp')]}"/>
|
<field name="afp_comision_type" attrs="{'invisible': [('retirement_type', '!=', 'afp')]}"/>
|
||||||
</group>
|
</group>
|
||||||
<group name="employer" string="Employer">
|
<group name="employer" string="Employer">
|
||||||
<field name="comp_ss_type" />
|
<field name="comp_ss_type" />
|
||||||
<field name="comp_ss_eps_rule_id" attrs="{'invisible': [('comp_ss_type', '!=', 'eps')]}"/>
|
<p attrs="{'invisible': [('comp_ss_type', '!=', 'eps')]}">Not supported. Specify rule.</p>
|
||||||
<field name="comp_life_insurance_rule_id" />
|
<field name="comp_ss_eps_rule_id" attrs="{'invisible': [('comp_ss_type', '!=', 'eps')]}" />
|
||||||
<field name="comp_risk_insurance_rule_id" />
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<record id="res_config_settings_view_form_inherit" model="ir.ui.view">
|
|
||||||
<field name="name">res.config.settings.view.form.inherit</field>
|
|
||||||
<field name="model">res.config.settings</field>
|
|
||||||
<field name="inherit_id" ref="hr_payroll.res_config_settings_view_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//div[@data-key='hr_payroll']" position="inside">
|
|
||||||
<div class="row mt16 o_settings_container" id="hr_payroll_accountant">
|
|
||||||
<div class="col-lg-6 col-12 o_setting_box">
|
|
||||||
<div class="o_setting_right_pane">
|
|
||||||
<span class="o_form_label">Payslip Sum Behavior</span>
|
|
||||||
<div class="text-muted">
|
|
||||||
Customize the behavior of what payslips are eligible when summing over date ranges in rules.
|
|
||||||
Generally, "Date To" or "Accounting Date" would be preferred in the United States and anywhere
|
|
||||||
else where the ending date on the payslip is used to calculate wage bases.
|
|
||||||
</div>
|
|
||||||
<div class="content-group">
|
|
||||||
<div class="row mt16" id="mail_alias_domain">
|
|
||||||
<label for="payslip_sum_type" class="col-lg-3 o_light_label"/>
|
|
||||||
<field name="payslip_sum_type"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
Reference in New Issue
Block a user