From 2e31d7c7bf23f4b6248f1ed434c58499cf7ceccc Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 29 Sep 2016 10:59:46 +0530 Subject: [PATCH] [fix] Validate leave application period with salary slip only if leave type is LWP --- .../leave_application/leave_application.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 838d8f7513..42edc9ff13 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -97,12 +97,19 @@ class LeaveApplication(Document): .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):