fix(payroll): Fixed issue with accessing last salary slip for new employee (#27247)
This commit is contained in:
parent
52dd326f22
commit
88d849320f
@ -242,7 +242,11 @@ def get_salary_structure(employee):
|
|||||||
order_by = "from_date desc")[0].salary_structure
|
order_by = "from_date desc")[0].salary_structure
|
||||||
|
|
||||||
def get_last_salary_slip(employee):
|
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
|
"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
|
||||||
|
|||||||
@ -24,6 +24,11 @@ class TestGratuity(unittest.TestCase):
|
|||||||
frappe.db.sql("DELETE FROM `tabGratuity`")
|
frappe.db.sql("DELETE FROM `tabGratuity`")
|
||||||
frappe.db.sql("DELETE FROM `tabAdditional Salary` WHERE ref_doctype = 'Gratuity'")
|
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):
|
def test_check_gratuity_amount_based_on_current_slab_and_additional_salary_creation(self):
|
||||||
employee, sal_slip = create_employee_and_get_last_salary_slip()
|
employee, sal_slip = create_employee_and_get_last_salary_slip()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user