test: fix salary component not found; other optimisation (#24920)

This commit is contained in:
Sagar Vora 2021-03-17 19:54:08 +05:30 committed by GitHub
parent cbd67e662f
commit cf3fc99b12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -15,9 +15,12 @@ from frappe.utils import getdate, add_days, get_datetime, flt
test_dependencies = ["Salary Component", "Salary Slip", "Account"]
class TestGratuity(unittest.TestCase):
def setUp(self):
@classmethod
def setUpClass(cls):
make_earning_salary_component(setup=True, test_tax=True, company_list=['_Test Company'])
make_deduction_salary_component(setup=True, test_tax=True, company_list=['_Test Company'])
def setUp(self):
frappe.db.sql("DELETE FROM `tabGratuity`")
frappe.db.sql("DELETE FROM `tabAdditional Salary` WHERE ref_doctype = 'Gratuity'")

View File

@ -361,7 +361,6 @@ class TestSalarySlip(unittest.TestCase):
# as per assigned salary structure 40500 in monthly salary so 236000*5/100/12
frappe.db.sql("""delete from `tabPayroll Period`""")
frappe.db.sql("""delete from `tabSalary Component`""")
frappe.db.sql("""delete from `tabAdditional Salary`""")
payroll_period = create_payroll_period()

View File

@ -13,9 +13,18 @@ from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.payroll.doctype.salary_structure.test_salary_structure \
import make_salary_structure, create_salary_structure_assignment
from erpnext.payroll.doctype.salary_slip.test_salary_slip import (
make_earning_salary_component,
make_deduction_salary_component
)
from erpnext.hr.doctype.employee.test_employee import make_employee
class TestTimesheet(unittest.TestCase):
@classmethod
def setUpClass(cls):
make_earning_salary_component(setup=True, company_list=['_Test Company'])
make_deduction_salary_component(setup=True, company_list=['_Test Company'])
def setUp(self):
for dt in ["Salary Slip", "Salary Structure", "Salary Structure Assignment", "Timesheet"]:
frappe.db.sql("delete from `tab%s`" % dt)