|
@@ -415,28 +415,6 @@ class HrEfficiency(models.Model):
|
|
|
for slot in planning_slots:
|
|
for slot in planning_slots:
|
|
|
hours = slot.allocated_hours or 0.0
|
|
hours = slot.allocated_hours or 0.0
|
|
|
|
|
|
|
|
- # Only count hours for working days according to employee's calendar
|
|
|
|
|
- if employee.resource_calendar_id:
|
|
|
|
|
- # Get working hours for the slot's date range
|
|
|
|
|
- slot_start = slot.start_datetime.date()
|
|
|
|
|
- slot_end = slot.end_datetime.date()
|
|
|
|
|
-
|
|
|
|
|
- # Calculate working hours for this slot period
|
|
|
|
|
- slot_start_dt = datetime.combine(slot_start, datetime.min.time())
|
|
|
|
|
- slot_end_dt = datetime.combine(slot_end, datetime.max.time())
|
|
|
|
|
- work_hours_data = employee._list_work_time_per_day(slot_start_dt, slot_end_dt)
|
|
|
|
|
-
|
|
|
|
|
- # Sum working hours for the slot period
|
|
|
|
|
- slot_working_hours = sum(hours for _, hours in work_hours_data[employee.id])
|
|
|
|
|
-
|
|
|
|
|
- # Only count the portion that falls on working days
|
|
|
|
|
- if slot_working_hours > 0:
|
|
|
|
|
- # Calculate the ratio of working hours to total slot hours
|
|
|
|
|
- slot_duration = (slot.end_datetime - slot.start_datetime).total_seconds() / 3600
|
|
|
|
|
- if slot_duration > 0:
|
|
|
|
|
- working_ratio = min(1.0, slot_working_hours / slot_duration)
|
|
|
|
|
- hours = hours * working_ratio
|
|
|
|
|
-
|
|
|
|
|
# Check if the slot is linked to a billable project
|
|
# Check if the slot is linked to a billable project
|
|
|
if slot.project_id and slot.project_id.allow_billable:
|
|
if slot.project_id and slot.project_id.allow_billable:
|
|
|
total_billable += hours
|
|
total_billable += hours
|