fix: dynamic values for tests
This commit is contained in:
parent
cbdcfb4873
commit
039a5a829d
@ -29,21 +29,26 @@ class TestProjectProfitability(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
report = execute(filters)
|
report = execute(filters)
|
||||||
expected_data = [
|
|
||||||
{
|
row = report[1][0]
|
||||||
'customer_name': '_Test Customer',
|
timesheet = frappe.get_doc("Timesheet", self.timesheet.name)
|
||||||
'employee_name': 'test_employee_9@salary.com',
|
|
||||||
'base_grand_total': 100.0,
|
self.assertEqual(self.sales_invoice.customer, row.customer_name)
|
||||||
'base_gross_pay': 78100.0,
|
self.assertEqual(timesheet.title, row.employee_name)
|
||||||
'profit': -19425.0,
|
self.assertEqual(self.sales_invoice.base_grand_total, row.base_grand_total)
|
||||||
'total_billed_hours': 2.0,
|
self.assertEqual(self.salary_slip.base_gross_pay, row.base_gross_pay)
|
||||||
'utilization': 0.25,
|
self.assertEqual(timesheet.total_billed_hours, row.total_billed_hours)
|
||||||
'fractional_cost': 19525.0,
|
self.assertEqual(self.salary_slip.total_working_days, row.total_working_days)
|
||||||
'total_working_days': 1.0
|
|
||||||
}
|
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)
|
||||||
for key in ['customer_name','employee_name','base_grand_total','base_gross_pay','profit','total_billed_hours','utilization','fractional_cost','total_working_days']:
|
self.assertEqual(utilization, row.utilization)
|
||||||
self.assertEqual(expected_data[0].get(key), report[1][0].get(key))
|
|
||||||
|
profit = self.sales_invoice.base_grand_total - self.salary_slip.base_gross_pay * utilization
|
||||||
|
self.assertEqual(profit, row.profit)
|
||||||
|
|
||||||
|
fractional_cost = self.salary_slip.base_gross_pay * utilization
|
||||||
|
self.assertEqual(fractional_cost, row.fractional_cost)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
frappe.get_doc("Sales Invoice", self.sales_invoice.name).cancel()
|
frappe.get_doc("Sales Invoice", self.sales_invoice.name).cancel()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user