[fix] Validate leave application period with salary slip only if leave type is LWP
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 838d8f7..42edc9f 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -97,12 +97,19 @@
.format(formatdate(future_allocation[0].from_date), future_allocation[0].name))
def validate_salary_processed_days(self):
- last_processed_pay_slip = frappe.db.sql("""select start_date, end_date from `tabSalary Slip`
- where docstatus != 2 and employee = %s and ((%s between start_date and end_date) or (%s between start_date and end_date)) order by modified desc limit 1""",(self.employee, self.to_date, self.from_date))
+ if not frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
+ return
+
+ last_processed_pay_slip = frappe.db.sql("""
+ select start_date, end_date from `tabSalary Slip`
+ where docstatus != 2 and employee = %s
+ and ((%s between start_date and end_date) or (%s between start_date and end_date))
+ order by modified desc limit 1
+ """,(self.employee, self.to_date, self.from_date))
if last_processed_pay_slip:
- frappe.throw(_("Salary already processed for period between {0} and {1}, Leave application period cannot be between this date range.").
- format(formatdate(last_processed_pay_slip[0][0]), formatdate(last_processed_pay_slip[0][1])))
+ frappe.throw(_("Salary already processed for period between {0} and {1}, Leave application period cannot be between this date range.").format(formatdate(last_processed_pay_slip[0][0]),
+ formatdate(last_processed_pay_slip[0][1])))
def show_block_day_warning(self):