Skip to content

Commit 8a3ee23

Browse files
alfredoavanzoscanajuaristi
authored andcommitted
[18.0][FIX] hr_attendance_leave_report: Fix charges for absences taken in hours exceeding half a day.
1 parent 66177a2 commit 8a3ee23

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

hr_attendance_leave_report/models/hr_attendance_leave.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ def _extra_hours_in_non_remurated_day(self):
8989
extra_hours = 0
9090
if self.worked_hours == 0:
9191
extra_hours = self.hours_to_work * -1
92-
elif self.worked_hours <= self.hours_to_work:
93-
extra_hours = self.worked_hours - self.hours_to_work
9492
else:
9593
extra_hours = self.worked_hours - self.hours_to_work
9694
return extra_hours
@@ -99,14 +97,12 @@ def _extra_hours_in_remurated_day(self):
9997
extra_hours = 0
10098
if self.worked_hours == 0:
10199
extra_hours = (self.hours_to_work - self.remunerated_hours) * -1
102-
elif self.worked_hours <= self.remunerated_hours:
103-
extra_hours = (
104-
self.hours_to_work - self.remunerated_hours + self.worked_hours
105-
)
106100
else:
107-
extra_hours = self.worked_hours - (
108-
self.hours_to_work - self.remunerated_hours
109-
)
101+
worked_hours = self.worked_hours + self.remunerated_hours
102+
if worked_hours >= self.hours_to_work:
103+
extra_hours = worked_hours - self.hours_to_work
104+
else:
105+
extra_hours = (self.hours_to_work - worked_hours) * -1
110106
return extra_hours
111107

112108
def _treat_employee_dates(self, employees_dates):
@@ -239,10 +235,7 @@ def _get_leave(self, contract, work_date, vals):
239235
if leave:
240236
hours = vals.get("hours_to_work")
241237
if leave.holiday_status_id.request_unit != "day":
242-
difference = leave.date_to - leave.date_from
243-
hours_difference = difference.total_seconds() / 3600
244-
if hours_difference < hours:
245-
hours = hours_difference
238+
hours = leave.number_of_hours
246239
vals["leave_type_id"] = leave.holiday_status_id.id
247240
vals["day_type"] = leave.holiday_status_id.name
248241
if leave.holiday_status_id.time_type == "other":

0 commit comments

Comments
 (0)