fix: tests
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 842fd4d..87bac02 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
@@ -167,15 +167,11 @@
def set_employee_department_and_name(self):
for emp in self.stats_by_employee:
- emp_name = frappe.db.get_value(
- 'Employee', emp, 'employee_name'
- )
emp_dept = frappe.db.get_value(
'Employee', emp, 'department'
)
self.stats_by_employee[emp]['department'] = emp_dept
- self.stats_by_employee[emp]['employee_name'] = emp_name
def calculate_utilizations(self):
TOTAL_HOURS = flt(self.standard_working_hours * self.day_span, 2)
diff --git a/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/test_employee_util.py b/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/test_employee_util.py
index 977a10d..6d95545 100644
--- a/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/test_employee_util.py
+++ b/erpnext/projects/report/employee_hours_utilization_based_on_timesheet/test_employee_util.py
@@ -20,6 +20,8 @@
# Create test timesheets
cls.create_test_timesheets()
+ frappe.db.set_value("HR Settings", "HR Settings", "standard_working_hours", 9)
+
@classmethod
def create_test_timesheets(cls):
timesheet1 = frappe.new_doc("Timesheet")
@@ -51,7 +53,7 @@
})
timesheet2.save()
- timesheet2.submit()
+ timesheet2.submit()
@classmethod
def tearDownClass(cls):
@@ -59,8 +61,8 @@
frappe.db.sql("""
DELETE FROM `tabTimesheet Detail`
WHERE parent IN (
- SELECT name
- FROM `tabTimesheet`
+ SELECT name
+ FROM `tabTimesheet`
WHERE company = '_Test Company'
)
""")
@@ -72,14 +74,14 @@
filters = {
"company": "_Test Company",
"from_date": "2021-04-01",
- "to_date": "2021-04-03"
+ "to_date": "2021-04-03"
}
report = execute(filters)
expected_data = self.get_expected_data_for_test_employees()
self.assertEqual(report[1], expected_data)
-
+
def test_utilization_report_for_single_employee(self):
filters = {
"company": "_Test Company",
@@ -93,14 +95,14 @@
emp1_data = frappe.get_doc('Employee', self.test_emp1)
expected_data = [
{
- 'employee': self.test_emp1,
- 'employee_name': emp1_data.employee_name,
+ 'employee': self.test_emp1,
+ 'billed_hours': 5.0,
+ 'non_billed_hours': 0.0,
'department': emp1_data.department,
- 'billed_hours': 5.0,
- 'non_billed_hours': 0.0,
- 'total_hours': 18.0,
- 'untracked_hours': 13.0,
- 'per_util': 27.78
+ 'total_hours': 18.0,
+ 'untracked_hours': 13.0,
+ 'per_util': 27.78,
+ 'per_util_billed_only': 27.78
}
]
@@ -115,18 +117,18 @@
}
report = execute(filters)
-
+
emp2_data = frappe.get_doc('Employee', self.test_emp2)
expected_data = [
{
'employee': self.test_emp2,
- 'employee_name': emp2_data.employee_name,
+ 'billed_hours': 0.0,
+ 'non_billed_hours': 10.0,
'department': emp2_data.department,
- 'billed_hours': 0.0,
- 'non_billed_hours': 10.0,
- 'total_hours': 18.0,
- 'untracked_hours': 8.0,
- 'per_util': 55.56
+ 'total_hours': 18.0,
+ 'untracked_hours': 8.0,
+ 'per_util': 55.56,
+ 'per_util_billed_only': 0.0
}
]
@@ -155,7 +157,7 @@
report = execute(filters)
summary = report[4]
- expected_summary_values = ['41.67%', 5.0, 10.0, 21.0]
+ expected_summary_values = ['41.67%', '13.89%', 5.0, 10.0]
self.assertEqual(len(summary), 4)
@@ -167,26 +169,26 @@
def get_expected_data_for_test_employees(self):
emp1_data = frappe.get_doc('Employee', self.test_emp1)
emp2_data = frappe.get_doc('Employee', self.test_emp2)
-
+
return [
{
- 'employee': self.test_emp2,
- 'employee_name': emp2_data.employee_name,
- 'department': emp2_data.department,
- 'billed_hours': 0.0,
- 'non_billed_hours': 10.0,
- 'total_hours': 18.0,
- 'untracked_hours': 8.0,
- 'per_util': 55.56
- },
+ 'employee': self.test_emp2,
+ 'billed_hours': 0.0,
+ 'non_billed_hours': 10.0,
+ 'department': emp2_data.department,
+ 'total_hours': 18.0,
+ 'untracked_hours': 8.0,
+ 'per_util': 55.56,
+ 'per_util_billed_only': 0.0
+ },
{
- 'employee': self.test_emp1,
- 'employee_name': emp1_data.employee_name,
- 'department': emp1_data.department,
- 'billed_hours': 5.0,
- 'non_billed_hours': 0.0,
- 'total_hours': 18.0,
- 'untracked_hours': 13.0,
- 'per_util': 27.78
+ 'employee': self.test_emp1,
+ 'billed_hours': 5.0,
+ 'non_billed_hours': 0.0,
+ 'department': emp1_data.department,
+ 'total_hours': 18.0,
+ 'untracked_hours': 13.0,
+ 'per_util': 27.78,
+ 'per_util_billed_only': 27.78
}
]
\ No newline at end of file
diff --git a/erpnext/projects/report/project_profitability/test_project_profitability.py b/erpnext/projects/report/project_profitability/test_project_profitability.py
index 251b71d..7fe28b1 100644
--- a/erpnext/projects/report/project_profitability/test_project_profitability.py
+++ b/erpnext/projects/report/project_profitability/test_project_profitability.py
@@ -3,7 +3,7 @@
import frappe
from frappe.utils import getdate, nowdate
from erpnext.hr.doctype.employee.test_employee import make_employee
-from erpnext.projects.doctype.timesheet.test_timesheet import make_salary_structure_for_timesheet, make_timesheet
+from erpnext.projects.doctype.timesheet.test_timesheet import make_salary_structure_for_timesheet, make_timesheet
from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice
from erpnext.projects.report.project_profitability.project_profitability import execute
@@ -21,6 +21,8 @@
self.sales_invoice.due_date = nowdate()
self.sales_invoice.submit()
+ frappe.db.set_value("HR Settings", "HR Settings", "standard_working_hours", 8)
+
def test_project_profitability(self):
filters = {
'company': '_Test Company',
@@ -43,7 +45,7 @@
standard_working_hours = frappe.db.get_single_value("HR Settings", "standard_working_hours")
utilization = timesheet.total_billed_hours/(self.salary_slip.total_working_days * standard_working_hours)
self.assertEqual(utilization, row.utilization)
-
+
profit = self.sales_invoice.base_grand_total - self.salary_slip.base_gross_pay * utilization
self.assertEqual(profit, row.profit)