Skip to content

Commit

Permalink
fix: Gratuity status not updated on salary slip submission
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed May 27, 2022
1 parent e3c0d01 commit 385e22a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions erpnext/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ def on_submit(self):
self.update_payment_status_for_gratuity()

def update_payment_status_for_gratuity(self):
add_salary = frappe.db.get_all(
additional_salary = frappe.db.get_all(
"Additional Salary",
filters={
"payroll_date": ("BETWEEN", [self.start_date, self.end_date]),
"payroll_date": ("between", [self.start_date, self.end_date]),
"employee": self.employee,
"ref_doctype": "Gratuity",
"docstatus": 1,
Expand All @@ -128,10 +128,10 @@ def update_payment_status_for_gratuity(self):
limit=1,
)

if len(add_salary):
if additional_salary:
status = "Paid" if self.docstatus == 1 else "Unpaid"
if add_salary[0].name in [data.additional_salary for data in self.earnings]:
frappe.db.set_value("Gratuity", add_salary.ref_docname, "status", status)
if additional_salary[0].name in [entry.additional_salary for entry in self.earnings]:
frappe.db.set_value("Gratuity", additional_salary[0].ref_docname, "status", status)

def on_cancel(self):
self.set_status()
Expand Down

0 comments on commit 385e22a

Please sign in to comment.