feat: Add % Utilization (Billed Only)
- Added billed utilization metric in report summary
diff --git a/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py b/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py
index b38da14..842fd4d 100644
--- a/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py
+++ b/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py
@@ -88,6 +88,12 @@
'fieldname': 'per_util',
'fieldtype': 'Percentage',
'width': 200
+ },
+ {
+ 'label': _('% Utilization (B / T)'),
+ 'fieldname': 'per_util_billed_only',
+ 'fieldtype': 'Percentage',
+ 'width': 200
}
]
@@ -182,6 +188,7 @@
data['untracked_hours'] = 0.0
data['per_util'] = flt(((data['billed_hours'] + data['non_billed_hours']) / TOTAL_HOURS) * 100, 2)
+ data['per_util_billed_only'] = flt((data['billed_hours'] / TOTAL_HOURS) * 100, 2)
def generate_report_summary(self):
self.report_summary = []
@@ -190,11 +197,13 @@
return
avg_utilization = 0.0
+ avg_utilization_billed_only = 0.0
total_billed, total_non_billed = 0.0, 0.0
total_untracked = 0.0
for row in self.data:
avg_utilization += row['per_util']
+ avg_utilization_billed_only += row['per_util_billed_only']
total_billed += row['billed_hours']
total_non_billed += row['non_billed_hours']
total_untracked += row['untracked_hours']
@@ -202,12 +211,21 @@
avg_utilization /= len(self.data)
avg_utilization = flt(avg_utilization, 2)
+ avg_utilization_billed_only /= len(self.data)
+ avg_utilization_billed_only = flt(avg_utilization_billed_only, 2)
+
THRESHOLD_PERCENTAGE = 70.0
self.report_summary = [
{
'value': f'{avg_utilization}%',
'indicator': 'Red' if avg_utilization < THRESHOLD_PERCENTAGE else 'Green',
- 'label': _('Average Utilization'),
+ 'label': _('Avg Utilization'),
+ 'datatype': 'Percentage'
+ },
+ {
+ 'value': f'{avg_utilization_billed_only}%',
+ 'indicator': 'Red' if avg_utilization_billed_only < THRESHOLD_PERCENTAGE else 'Green',
+ 'label': _('Avg Utilization (Billed Only)'),
'datatype': 'Percentage'
},
{
@@ -219,11 +237,6 @@
'value': total_non_billed,
'label': _('Total Non-Billed Hours'),
'datatype': 'Float'
- },
- {
- 'value': total_untracked,
- 'label': _('Total Untracked Hours'),
- 'datatype': 'Float'
}
]