Skip to content

Commit

Permalink
fix(payroll): Fixed issue with accessing last salary slip for new emp…
Browse files Browse the repository at this point in the history
…loyee (frappe#27247)
  • Loading branch information
ChillarAnand authored Aug 31, 2021
1 parent 62f88da commit b803480
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions erpnext/payroll/doctype/gratuity/gratuity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions erpnext/payroll/doctype/gratuity/test_gratuity.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def setUp(self):
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()

Expand Down

0 comments on commit b803480

Please sign in to comment.