[IMP] hr_payroll_hibou: pay periods out of l10n_us_hr_payroll

This commit is contained in:
Jared Kipe
2022-05-10 20:56:12 +00:00
parent 84efd4024c
commit f21b998b57
2 changed files with 21 additions and 0 deletions

View File

@@ -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

View File

@@ -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)