fix: add employee name in report data

This commit is contained in:
Rucha Mahabal 2021-04-26 16:10:06 +05:30
parent 926a9aed58
commit d5ca9474ce
2 changed files with 8 additions and 0 deletions

View File

@ -167,11 +167,15 @@ class EmployeeHoursReport:
def set_employee_department_and_name(self): def set_employee_department_and_name(self):
for emp in self.stats_by_employee: for emp in self.stats_by_employee:
emp_name = frappe.db.get_value(
'Employee', emp, 'employee_name'
)
emp_dept = frappe.db.get_value( emp_dept = frappe.db.get_value(
'Employee', emp, 'department' 'Employee', emp, 'department'
) )
self.stats_by_employee[emp]['department'] = emp_dept self.stats_by_employee[emp]['department'] = emp_dept
self.stats_by_employee[emp]['employee_name'] = emp_name
def calculate_utilizations(self): def calculate_utilizations(self):
TOTAL_HOURS = flt(self.standard_working_hours * self.day_span, 2) TOTAL_HOURS = flt(self.standard_working_hours * self.day_span, 2)

View File

@ -96,6 +96,7 @@ class TestEmployeeUtilization(unittest.TestCase):
expected_data = [ expected_data = [
{ {
'employee': self.test_emp1, 'employee': self.test_emp1,
'employee_name': 'test1@employeeutil.com',
'billed_hours': 5.0, 'billed_hours': 5.0,
'non_billed_hours': 0.0, 'non_billed_hours': 0.0,
'department': emp1_data.department, 'department': emp1_data.department,
@ -122,6 +123,7 @@ class TestEmployeeUtilization(unittest.TestCase):
expected_data = [ expected_data = [
{ {
'employee': self.test_emp2, 'employee': self.test_emp2,
'employee_name': 'test2@employeeutil.com',
'billed_hours': 0.0, 'billed_hours': 0.0,
'non_billed_hours': 10.0, 'non_billed_hours': 10.0,
'department': emp2_data.department, 'department': emp2_data.department,
@ -173,6 +175,7 @@ class TestEmployeeUtilization(unittest.TestCase):
return [ return [
{ {
'employee': self.test_emp2, 'employee': self.test_emp2,
'employee_name': 'test2@employeeutil.com',
'billed_hours': 0.0, 'billed_hours': 0.0,
'non_billed_hours': 10.0, 'non_billed_hours': 10.0,
'department': emp2_data.department, 'department': emp2_data.department,
@ -183,6 +186,7 @@ class TestEmployeeUtilization(unittest.TestCase):
}, },
{ {
'employee': self.test_emp1, 'employee': self.test_emp1,
'employee_name': 'test1@employeeutil.com',
'billed_hours': 5.0, 'billed_hours': 5.0,
'non_billed_hours': 0.0, 'non_billed_hours': 0.0,
'department': emp1_data.department, 'department': emp1_data.department,