Adapt method get employee prices.

This commit refs #27907
This commit is contained in:
Jorge Saura 2023-08-10 10:09:50 +02:00 committed by jm.pardo
parent d249fdab7d
commit 9869ed4bf5

View file

@ -64,7 +64,7 @@ class Employee(metaclass=PoolMeta):
payroll_date = Transaction().context.get('date', None)
return self.compute_payroll_price(payroll_date)
def get_employee_prices(self):
def get_employee_prices(self, date=None):
pool = Pool()
if not self.profile:
return 0
@ -73,6 +73,9 @@ class Employee(metaclass=PoolMeta):
('profile', '=', self.profile),
], order=[('date', 'ASC')])
return self.get_payroll_employee_costs(payroll_prices, date)
def get_payroll_employee_costs(self, payroll_prices, date=None):
employee_costs = []
for payroll_price in payroll_prices:
employee_costs.append(
@ -91,7 +94,7 @@ class Employee(metaclass=PoolMeta):
date = Date.today()
if self.profile:
employee_prices = self.get_employee_prices()
employee_prices = self.get_employee_prices(date)
if employee_prices and date >= employee_prices[0][0]:
for profile_edate, eprice, _ in employee_prices:
@ -121,7 +124,7 @@ class Employee(metaclass=PoolMeta):
date = Date.today()
if self.profile:
employee_prices = self.get_employee_prices()
employee_prices = self.get_employee_prices(date)
# compute the cost price for the given date
if employee_prices and date >= employee_prices[0][0]: