feat: Add Report Summary generation
diff --git a/erpnext/projects/report/employee_hours_utilisation_based_on_timesheet/employee_hours_utilisation_based_on_timesheet.py b/erpnext/projects/report/employee_hours_utilisation_based_on_timesheet/employee_hours_utilisation_based_on_timesheet.py
index 71ed2e7..702c85a 100644
--- a/erpnext/projects/report/employee_hours_utilisation_based_on_timesheet/employee_hours_utilisation_based_on_timesheet.py
+++ b/erpnext/projects/report/employee_hours_utilisation_based_on_timesheet/employee_hours_utilisation_based_on_timesheet.py
@@ -29,8 +29,9 @@
def run(self):
self.generate_columns()
self.generate_data()
+ self.generate_report_summary()
- return self.columns, self.data
+ return self.columns, self.data, None, None, self.report_summary
def generate_columns(self):
self.columns = [
@@ -126,4 +127,25 @@
for emp, data in iteritems(self.stats_by_employee):
data['total_hours'] = TOTAL_HOURS
data['untracked_hours'] = flt(TOTAL_HOURS - data['billed_hours'] - data['non_billed_hours'], 2)
- data['per_util'] = flt(((data['billed_hours'] + data['non_billed_hours']) / TOTAL_HOURS) * 100, 2)
\ No newline at end of file
+ data['per_util'] = flt(((data['billed_hours'] + data['non_billed_hours']) / TOTAL_HOURS) * 100, 2)
+
+ def generate_report_summary(self):
+ if not self.data:
+ return
+
+ avg_utilisation = 0.0
+ for row in self.data:
+ avg_utilisation += row['per_util']
+
+ avg_utilisation /= len(self.data)
+ avg_utilisation = flt(avg_utilisation, 2)
+
+ THRESHOLD_PERCENTAGE = 70.0
+ self.report_summary = [
+ {
+ 'value': f'{avg_utilisation}%',
+ 'indicator': 'Red' if avg_utilisation < THRESHOLD_PERCENTAGE else 'Green',
+ 'label': _('Average Utilisation'),
+ 'datatype': 'Percentage'
+ }
+ ]