fix(payroll): Fixed issue with accessing last salary slip for new employee (#27247)

This commit is contained in:
Chillar Anand 2021-08-31 14:42:21 +05:30 committed by GitHub
parent 52dd326f22
commit 88d849320f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -242,7 +242,11 @@ def get_salary_structure(employee):
order_by = "from_date desc")[0].salary_structure
def get_last_salary_slip(employee):
return frappe.get_list("Salary Slip", filters = {
salary_slips = frappe.get_list("Salary Slip", filters = {
"employee": employee, 'docstatus': 1
},
order_by = "start_date desc")[0].name
order_by = "start_date desc"
)
if not salary_slips:
return
return salary_slips[0].name

View File

@ -24,6 +24,11 @@ class TestGratuity(unittest.TestCase):
frappe.db.sql("DELETE FROM `tabGratuity`")
frappe.db.sql("DELETE FROM `tabAdditional Salary` WHERE ref_doctype = 'Gratuity'")
def test_get_last_salary_slip_should_return_none_for_new_employee(self):
new_employee = make_employee("new_employee@salary.com", company='_Test Company')
salary_slip = get_last_salary_slip(new_employee)
assert salary_slip is None
def test_check_gratuity_amount_based_on_current_slab_and_additional_salary_creation(self):
employee, sal_slip = create_employee_and_get_last_salary_slip()