From 31ae433778ac451d6a0a54bd68fc8f8b0e492392 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Thu, 28 Apr 2022 23:37:10 +0000 Subject: [PATCH] [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 --- l10n_pe_hr_payroll/__manifest__.py | 1 - l10n_pe_hr_payroll/data/afp_rules.xml | 22 +++++-------- l10n_pe_hr_payroll/data/base.xml | 4 +++ l10n_pe_hr_payroll/data/er_rules.xml | 6 ---- l10n_pe_hr_payroll/data/ir_5ta_cat_rules.xml | 12 +++---- l10n_pe_hr_payroll/data/onp_rules.xml | 8 +---- l10n_pe_hr_payroll/models/__init__.py | 1 - .../models/pe_payroll_config.py | 8 ++--- .../models/res_config_settings.py | 24 -------------- .../views/pe_payroll_config_views.xml | 6 ++-- .../views/res_config_settings_views.xml | 32 ------------------- 11 files changed, 22 insertions(+), 102 deletions(-) delete mode 100644 l10n_pe_hr_payroll/models/res_config_settings.py delete mode 100644 l10n_pe_hr_payroll/views/res_config_settings_views.xml diff --git a/l10n_pe_hr_payroll/__manifest__.py b/l10n_pe_hr_payroll/__manifest__.py index 0ae186ac..ee6cb479 100644 --- a/l10n_pe_hr_payroll/__manifest__.py +++ b/l10n_pe_hr_payroll/__manifest__.py @@ -26,7 +26,6 @@ Peru - Payroll Rules. 'data/er_rules.xml', 'views/hr_contract_views.xml', 'views/pe_payroll_config_views.xml', - 'views/res_config_settings_views.xml', ], 'demo': [ ], diff --git a/l10n_pe_hr_payroll/data/afp_rules.xml b/l10n_pe_hr_payroll/data/afp_rules.xml index 9b5fc102..2f08b5e7 100644 --- a/l10n_pe_hr_payroll/data/afp_rules.xml +++ b/l10n_pe_hr_payroll/data/afp_rules.xml @@ -19,11 +19,6 @@ - - - AFP - - @@ -35,7 +30,6 @@ result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' code result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][4] - @@ -49,14 +43,16 @@ result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' code -year = payslip.dict.get_year() -ytd_wage = payslip.sum_category('GROSS', str(year) + '-01-01', str(year+1) + '-01-01') wage = categories.GROSS -wage_base = payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][5] -rate = payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][3] -result, result_rate = general_rate(payslip, wage, ytd_wage, wage_base=wage_base, rate=rate) +# wage_max is monthly +wage_max = payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][5] +# 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 - @@ -70,7 +66,6 @@ result, result_rate = general_rate(payslip, wage, ytd_wage, wage_base=wage_base, result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' and contract.pe_payroll_config_value('afp_comision_type') == 'mixta' code result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][1] - @@ -84,7 +79,6 @@ result, result_rate = general_rate(payslip, wage, ytd_wage, wage_base=wage_base, result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'afp' and contract.pe_payroll_config_value('afp_comision_type') == 'non_mixta' code result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_afp')[contract.pe_payroll_config_value('afp_type')][0] - diff --git a/l10n_pe_hr_payroll/data/base.xml b/l10n_pe_hr_payroll/data/base.xml index bdb5a271..ced1315b 100644 --- a/l10n_pe_hr_payroll/data/base.xml +++ b/l10n_pe_hr_payroll/data/base.xml @@ -69,6 +69,10 @@ Bono BONO + + diff --git a/l10n_pe_hr_payroll/data/er_rules.xml b/l10n_pe_hr_payroll/data/er_rules.xml index 169a025f..a5d97b44 100644 --- a/l10n_pe_hr_payroll/data/er_rules.xml +++ b/l10n_pe_hr_payroll/data/er_rules.xml @@ -13,11 +13,6 @@ - - - Essalud - - @@ -29,7 +24,6 @@ result = categories.BASIC code result, result_rate = categories.BASIC, -payslip.rule_parameter('er_essalud') - diff --git a/l10n_pe_hr_payroll/data/ir_5ta_cat_rules.xml b/l10n_pe_hr_payroll/data/ir_5ta_cat_rules.xml index ea3c3486..b0a11869 100644 --- a/l10n_pe_hr_payroll/data/ir_5ta_cat_rules.xml +++ b/l10n_pe_hr_payroll/data/ir_5ta_cat_rules.xml @@ -31,11 +31,6 @@ - - - IR 5ta Cat. - - @@ -55,7 +50,9 @@ wage_period = categories.GROSS period_additional_wage = max(wage_period - basic_wage, 0.0) wage_year = basic_wage * pay_periods_in_year # 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 over_7uit = wage_year - (7.0 * uit) @@ -76,9 +73,8 @@ else: else: break 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) - diff --git a/l10n_pe_hr_payroll/data/onp_rules.xml b/l10n_pe_hr_payroll/data/onp_rules.xml index b1d9df0c..b2f81e34 100644 --- a/l10n_pe_hr_payroll/data/onp_rules.xml +++ b/l10n_pe_hr_payroll/data/onp_rules.xml @@ -13,11 +13,6 @@ - - - ONP - - @@ -26,10 +21,9 @@ EE: PE ONP/SNP EE_PE_ONP python - result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'onp' and rule == contract.pe_payroll_config_value('onp_rule_id') + result = categories.GROSS and contract.pe_payroll_config_value('retirement_type') == 'onp' code result, result_rate = categories.GROSS, -payslip.rule_parameter('ee_onp') - diff --git a/l10n_pe_hr_payroll/models/__init__.py b/l10n_pe_hr_payroll/models/__init__.py index ce62c910..30e1b8cc 100644 --- a/l10n_pe_hr_payroll/models/__init__.py +++ b/l10n_pe_hr_payroll/models/__init__.py @@ -3,5 +3,4 @@ from . import hr_contract from . import hr_payslip from . import pe_payroll_config -from . import res_config_settings from . import update diff --git a/l10n_pe_hr_payroll/models/pe_payroll_config.py b/l10n_pe_hr_payroll/models/pe_payroll_config.py index ec7da289..93adf0f0 100644 --- a/l10n_pe_hr_payroll/models/pe_payroll_config.py +++ b/l10n_pe_hr_payroll/models/pe_payroll_config.py @@ -16,8 +16,6 @@ class HRContractPEPayrollConfig(models.Model): ('retired', 'Retired'), ], 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 = fields.Selection([ ('habitat', 'Habitat'), @@ -34,6 +32,6 @@ class HRContractPEPayrollConfig(models.Model): ('essalud', 'Essalud'), ('eps', 'EPS'), ], string='Company Social Services', default='essalud') - 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') - comp_risk_insurance_rule_id = fields.Many2one('hr.salary.rule', string='Company Risk Insurance Rule') + comp_ss_eps_rule_id = fields.Many2one('hr.salary.rule', string='Company Social Security EPS Rule', + domain=[('code', '=like', 'ER_PE_EPS%')], + help="Rule code prefix 'ER_PE_EPS' to select here.") diff --git a/l10n_pe_hr_payroll/models/res_config_settings.py b/l10n_pe_hr_payroll/models/res_config_settings.py deleted file mode 100644 index 05af9430..00000000 --- a/l10n_pe_hr_payroll/models/res_config_settings.py +++ /dev/null @@ -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') diff --git a/l10n_pe_hr_payroll/views/pe_payroll_config_views.xml b/l10n_pe_hr_payroll/views/pe_payroll_config_views.xml index c2e86f30..4ac41567 100644 --- a/l10n_pe_hr_payroll/views/pe_payroll_config_views.xml +++ b/l10n_pe_hr_payroll/views/pe_payroll_config_views.xml @@ -27,15 +27,13 @@ - - - - +

Not supported. Specify rule.

+
diff --git a/l10n_pe_hr_payroll/views/res_config_settings_views.xml b/l10n_pe_hr_payroll/views/res_config_settings_views.xml deleted file mode 100644 index 3c69b42f..00000000 --- a/l10n_pe_hr_payroll/views/res_config_settings_views.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - res.config.settings.view.form.inherit - res.config.settings - - - -
-
-
- Payslip Sum Behavior -
- 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. -
-
-
-
-
-
-
-
-
-
-
- -