fix: Rename utilisation to utilization
This commit is contained in:
parent
ccb15de1c9
commit
bb32f5a92a
@ -2,7 +2,7 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
frappe.query_reports["Employee Hours Utilisation Based On Timesheet"] = {
|
frappe.query_reports["Employee Hours Utilization Based On Timesheet"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
fieldname: "company",
|
fieldname: "company",
|
||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"add_total_row": 0,
|
"add_total_row": 0,
|
||||||
"columns": [],
|
"columns": [],
|
||||||
"creation": "2021-03-30 12:18:02.090630",
|
"creation": "2021-04-05 19:23:43.838623",
|
||||||
"disable_prepared_report": 0,
|
"disable_prepared_report": 0,
|
||||||
"disabled": 0,
|
"disabled": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
@ -9,14 +9,14 @@
|
|||||||
"filters": [],
|
"filters": [],
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"modified": "2021-03-30 12:18:02.090630",
|
"modified": "2021-04-05 19:23:43.838623",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Projects",
|
"module": "Projects",
|
||||||
"name": "Employee Hours Utilisation Based On Timesheet",
|
"name": "Employee Hours Utilization Based On Timesheet",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"prepared_report": 0,
|
"prepared_report": 0,
|
||||||
"ref_doctype": "Timesheet",
|
"ref_doctype": "Timesheet",
|
||||||
"report_name": "Employee Hours Utilisation Based On Timesheet",
|
"report_name": "Employee Hours Utilization Based On Timesheet",
|
||||||
"report_type": "Script Report",
|
"report_type": "Script Report",
|
||||||
"roles": []
|
"roles": []
|
||||||
}
|
}
|
||||||
@ -11,7 +11,7 @@ def execute(filters=None):
|
|||||||
return EmployeeHoursReport(filters).run()
|
return EmployeeHoursReport(filters).run()
|
||||||
|
|
||||||
class EmployeeHoursReport:
|
class EmployeeHoursReport:
|
||||||
'''Employee Hours Utilisation Report Based On Timesheet'''
|
'''Employee Hours Utilization Report Based On Timesheet'''
|
||||||
def __init__(self, filters=None):
|
def __init__(self, filters=None):
|
||||||
self.filters = frappe._dict(filters or {})
|
self.filters = frappe._dict(filters or {})
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class EmployeeHoursReport:
|
|||||||
def generate_data(self):
|
def generate_data(self):
|
||||||
self.generate_filtered_time_logs()
|
self.generate_filtered_time_logs()
|
||||||
self.generate_stats_by_employee()
|
self.generate_stats_by_employee()
|
||||||
self.calculate_utilisations()
|
self.calculate_utilizations()
|
||||||
|
|
||||||
self.data = []
|
self.data = []
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class EmployeeHoursReport:
|
|||||||
row.update(data)
|
row.update(data)
|
||||||
self.data.append(row)
|
self.data.append(row)
|
||||||
|
|
||||||
# Sort by descending order of percentage utilisation
|
# Sort by descending order of percentage utilization
|
||||||
self.data.sort(key=lambda x: x['per_util'], reverse=True)
|
self.data.sort(key=lambda x: x['per_util'], reverse=True)
|
||||||
|
|
||||||
def generate_filtered_time_logs(self):
|
def generate_filtered_time_logs(self):
|
||||||
@ -128,7 +128,7 @@ class EmployeeHoursReport:
|
|||||||
else:
|
else:
|
||||||
self.stats_by_employee[emp]['non_billed_hours'] += flt(hours, 2)
|
self.stats_by_employee[emp]['non_billed_hours'] += flt(hours, 2)
|
||||||
|
|
||||||
def calculate_utilisations(self):
|
def calculate_utilizations(self):
|
||||||
# (9.0) Will be fetched from HR settings
|
# (9.0) Will be fetched from HR settings
|
||||||
TOTAL_HOURS = flt(9.0 * self.day_span, 2)
|
TOTAL_HOURS = flt(9.0 * self.day_span, 2)
|
||||||
for emp, data in iteritems(self.stats_by_employee):
|
for emp, data in iteritems(self.stats_by_employee):
|
||||||
@ -147,25 +147,25 @@ class EmployeeHoursReport:
|
|||||||
if not self.data:
|
if not self.data:
|
||||||
return
|
return
|
||||||
|
|
||||||
avg_utilisation = 0.0
|
avg_utilization = 0.0
|
||||||
total_billed, total_non_billed = 0.0, 0.0
|
total_billed, total_non_billed = 0.0, 0.0
|
||||||
total_untracked = 0.0
|
total_untracked = 0.0
|
||||||
|
|
||||||
for row in self.data:
|
for row in self.data:
|
||||||
avg_utilisation += row['per_util']
|
avg_utilization += row['per_util']
|
||||||
total_billed += row['billed_hours']
|
total_billed += row['billed_hours']
|
||||||
total_non_billed += row['non_billed_hours']
|
total_non_billed += row['non_billed_hours']
|
||||||
total_untracked += row['untracked_hours']
|
total_untracked += row['untracked_hours']
|
||||||
|
|
||||||
avg_utilisation /= len(self.data)
|
avg_utilization /= len(self.data)
|
||||||
avg_utilisation = flt(avg_utilisation, 2)
|
avg_utilization = flt(avg_utilization, 2)
|
||||||
|
|
||||||
THRESHOLD_PERCENTAGE = 70.0
|
THRESHOLD_PERCENTAGE = 70.0
|
||||||
self.report_summary = [
|
self.report_summary = [
|
||||||
{
|
{
|
||||||
'value': f'{avg_utilisation}%',
|
'value': f'{avg_utilization}%',
|
||||||
'indicator': 'Red' if avg_utilisation < THRESHOLD_PERCENTAGE else 'Green',
|
'indicator': 'Red' if avg_utilization < THRESHOLD_PERCENTAGE else 'Green',
|
||||||
'label': _('Average Utilisation'),
|
'label': _('Average Utilization'),
|
||||||
'datatype': 'Percentage'
|
'datatype': 'Percentage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -4,11 +4,11 @@ import frappe
|
|||||||
|
|
||||||
from frappe.utils.make_random import get_random
|
from frappe.utils.make_random import get_random
|
||||||
from frappe.utils import get_timestamp
|
from frappe.utils import get_timestamp
|
||||||
from erpnext.projects.report.employee_hours_utilisation_based_on_timesheet.employee_hours_utilisation_based_on_timesheet import execute
|
from erpnext.projects.report.employee_hours_utilization_based_on_timesheet.employee_hours_utilization_based_on_timesheet import execute
|
||||||
from erpnext.hr.doctype.employee.test_employee import make_employee
|
from erpnext.hr.doctype.employee.test_employee import make_employee
|
||||||
from erpnext.projects.doctype.project.test_project import make_project
|
from erpnext.projects.doctype.project.test_project import make_project
|
||||||
|
|
||||||
class TestEmployeeUtilisation(unittest.TestCase):
|
class TestEmployeeUtilization(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
# Create test employee
|
# Create test employee
|
||||||
@ -69,7 +69,7 @@ class TestEmployeeUtilisation(unittest.TestCase):
|
|||||||
frappe.db.sql("DELETE FROM `tabTimesheet` WHERE company='_Test Company'")
|
frappe.db.sql("DELETE FROM `tabTimesheet` WHERE company='_Test Company'")
|
||||||
frappe.db.sql(f"DELETE FROM `tabProject` WHERE name='{cls.test_project.name}'")
|
frappe.db.sql(f"DELETE FROM `tabProject` WHERE name='{cls.test_project.name}'")
|
||||||
|
|
||||||
def test_utilisation_report_with_required_filters_only(self):
|
def test_utilization_report_with_required_filters_only(self):
|
||||||
filters = {
|
filters = {
|
||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"from_date": "2021-04-01",
|
"from_date": "2021-04-01",
|
||||||
@ -99,7 +99,7 @@ class TestEmployeeUtilisation(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(report[1], expected_data)
|
self.assertEqual(report[1], expected_data)
|
||||||
|
|
||||||
def test_utilisation_report_for_single_employee(self):
|
def test_utilization_report_for_single_employee(self):
|
||||||
filters = {
|
filters = {
|
||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"from_date": "2021-04-01",
|
"from_date": "2021-04-01",
|
||||||
@ -122,7 +122,7 @@ class TestEmployeeUtilisation(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(report[1], expected_data)
|
self.assertEqual(report[1], expected_data)
|
||||||
|
|
||||||
def test_utilisation_report_for_project(self):
|
def test_utilization_report_for_project(self):
|
||||||
filters = {
|
filters = {
|
||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"from_date": "2021-04-01",
|
"from_date": "2021-04-01",
|
||||||
Loading…
x
Reference in New Issue
Block a user