feat: Add Report Summary generation
This commit is contained in:
parent
1a0229eb36
commit
f5576d67dd
@ -29,8 +29,9 @@ class EmployeeHoursReport:
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.generate_columns()
|
self.generate_columns()
|
||||||
self.generate_data()
|
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):
|
def generate_columns(self):
|
||||||
self.columns = [
|
self.columns = [
|
||||||
@ -126,4 +127,25 @@ class EmployeeHoursReport:
|
|||||||
for emp, data in iteritems(self.stats_by_employee):
|
for emp, data in iteritems(self.stats_by_employee):
|
||||||
data['total_hours'] = TOTAL_HOURS
|
data['total_hours'] = TOTAL_HOURS
|
||||||
data['untracked_hours'] = flt(TOTAL_HOURS - data['billed_hours'] - data['non_billed_hours'], 2)
|
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)
|
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'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user