test: optimise test_component_amount_dependent_on_another_payment_days_based_component (#27836)

This commit is contained in:
Sagar Vora 2021-10-06 17:13:34 +05:30 committed by GitHub
parent ff7506d4a6
commit d36849e4f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,7 +141,6 @@ class TestSalarySlip(unittest.TestCase):
create_salary_structure_assignment,
)
no_of_days = self.get_no_of_days()
# Payroll based on attendance
frappe.db.set_value("Payroll Settings", None, "payroll_based_on", "Attendance")
@ -168,9 +167,6 @@ class TestSalarySlip(unittest.TestCase):
ss = make_salary_slip_for_payment_days_dependency_test("test_payment_days_based_component@salary.com", salary_structure.name)
self.assertEqual(ss.absent_days, 1)
days_in_month = no_of_days[0]
no_of_holidays = no_of_days[1]
ss.reload()
payment_days_based_comp_amount = 0
for component in ss.earnings:
@ -992,13 +988,14 @@ def make_salary_structure_for_payment_days_based_component_dependency():
return salary_structure_doc
def make_salary_slip_for_payment_days_dependency_test(employee, salary_structure):
employee = frappe.db.get_value("Employee", {
"user_id": employee
},
employee = frappe.db.get_value(
"Employee",
{"user_id": employee},
["name", "company", "employee_name"],
as_dict=True)
as_dict=True
)
salary_slip_name = frappe.db.get_value("Salary Slip", {"employee": frappe.db.get_value("Employee", {"user_id": employee})})
salary_slip_name = frappe.db.get_value("Salary Slip", {"employee": employee.name})
if not salary_slip_name:
salary_slip = make_salary_slip(salary_structure, employee=employee.name)
@ -1009,4 +1006,4 @@ def make_salary_slip_for_payment_days_dependency_test(employee, salary_structure
else:
salary_slip = frappe.get_doc("Salary Slip", salary_slip_name)
return salary_slip
return salary_slip