From f21b998b5759450c360facd692c49c8bcc8e25ab Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Tue, 10 May 2022 20:56:12 +0000 Subject: [PATCH] [IMP] hr_payroll_hibou: pay periods out of l10n_us_hr_payroll --- hr_payroll_hibou/models/browsable_object.py | 5 +++++ hr_payroll_hibou/models/hr_payslip.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/hr_payroll_hibou/models/browsable_object.py b/hr_payroll_hibou/models/browsable_object.py index 60543eb8..d93e0eee 100644 --- a/hr_payroll_hibou/models/browsable_object.py +++ b/hr_payroll_hibou/models/browsable_object.py @@ -138,6 +138,10 @@ class Payslips(BrowsableObject): def paid_amount(self): return self.dict._get_paid_amount() + # Hibou helper + @property + def pay_periods_in_year(self): + return self.dict.get_pay_periods_in_year() # Patch over Core browsable_object.BrowsableObject.__init__ = BrowsableObject.__init__ @@ -149,3 +153,4 @@ browsable_object.WorkedDays.sum = WorkedDays.sum browsable_object.Payslips._compile_browsable_query = Payslips._compile_browsable_query browsable_object.Payslips.sum = Payslips.sum browsable_object.Payslips.sum_category = Payslips.sum_category +browsable_object.Payslips.pay_periods_in_year = Payslips.pay_periods_in_year diff --git a/hr_payroll_hibou/models/hr_payslip.py b/hr_payroll_hibou/models/hr_payslip.py index 06f1031f..c6737e57 100644 --- a/hr_payroll_hibou/models/hr_payslip.py +++ b/hr_payroll_hibou/models/hr_payslip.py @@ -6,6 +6,19 @@ from odoo import api, fields, models class HrPayslip(models.Model): _inherit = 'hr.payslip' + # From IRS Publication 15-T or logically (annually, bi-monthly) + PAY_PERIODS_IN_YEAR = { + 'annually': 1, + 'semi-annually': 2, + 'quarterly': 4, + 'bi-monthly': 6, + 'monthly': 12, + 'semi-monthly': 24, + 'bi-weekly': 26, + 'weekly': 52, + 'daily': 260, + } + # normal_wage is an integer field, but that lacks precision. normal_wage = fields.Float(compute='_compute_normal_wage', store=True) # We need to be able to support more complexity, @@ -35,3 +48,6 @@ class HrPayslip(models.Model): # This would be a good place to override though with a 'work type' # based mechanism, like a minimum rate or 'rate card' implementation return self.contract_id._get_contract_wage(work_type=work_type) + + def get_pay_periods_in_year(self): + return self.PAY_PERIODS_IN_YEAR.get(self.contract_id.schedule_pay, 0)