[fix] Validate leave application period with salary slip only if leave type is LWP

This commit is contained in:
Nabin Hait 2016-09-29 10:59:46 +05:30
parent f1ad32059f
commit 2e31d7c7bf

View File

@ -97,12 +97,19 @@ class LeaveApplication(Document):
.format(formatdate(future_allocation[0].from_date), future_allocation[0].name)) .format(formatdate(future_allocation[0].from_date), future_allocation[0].name))
def validate_salary_processed_days(self): def validate_salary_processed_days(self):
last_processed_pay_slip = frappe.db.sql("""select start_date, end_date from `tabSalary Slip` if not frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
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)) 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: 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."). 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]),
format(formatdate(last_processed_pay_slip[0][0]), formatdate(last_processed_pay_slip[0][1]))) formatdate(last_processed_pay_slip[0][1])))
def show_block_day_warning(self): def show_block_day_warning(self):