fix(test): use frappe.db.rollback to revert deletion of fixture data (#16192)

* debug(test): test_payroll_entry

* debug(test): test_payroll_entry

* debug(test): use frappe.db.rollback to undelete fixture data
This commit is contained in:
Rushabh Mehta 2018-12-11 22:37:29 +05:30 committed by GitHub
parent 4f3fd030ae
commit eeab3ee5d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -78,12 +78,17 @@ def get_benefit_pro_rata_ratio_amount(employee, on_date, sal_struct):
total_pro_rata_max = 0
benefit_amount_total = 0
for sal_struct_row in sal_struct.get("earnings"):
pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"])
try:
pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"])
except TypeError:
# show the error in tests?
frappe.throw("Unable to find Salary Component {0}".format(sal_struct_row.salary_component))
if sal_struct_row.is_flexible_benefit == 1 and pay_against_benefit_claim != 1:
total_pro_rata_max += max_benefit_amount
if total_pro_rata_max > 0:
for sal_struct_row in sal_struct.get("earnings"):
pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"])
if sal_struct_row.is_flexible_benefit == 1 and pay_against_benefit_claim != 1:
component_max = max_benefit_amount
benefit_amount = component_max * sal_struct.max_benefits / total_pro_rata_max

View File

@ -256,6 +256,9 @@ class TestSalarySlip(unittest.TestCase):
raise
frappe.db.sql("""delete from `tabAdditional Salary` where employee=%s""", (employee))
# undelete fixture data
frappe.db.rollback()
def make_holiday_list(self):
fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company())
if not frappe.db.get_value("Holiday List", "Salary Slip Test Holiday List"):