Cancel attendance if leave application is cancelled (#14372)
* Cancel attendance if leave application is cancelled * Fix as per review
This commit is contained in:
parent
8cd0f67b25
commit
b9399d8781
@ -60,6 +60,7 @@ class LeaveApplication(Document):
|
||||
def on_cancel(self):
|
||||
# notify leave applier about cancellation
|
||||
self.notify_employee("cancelled")
|
||||
self.cancel_attendance()
|
||||
|
||||
def validate_dates(self):
|
||||
if self.from_date and self.to_date and (getdate(self.to_date) < getdate(self.from_date)):
|
||||
@ -138,6 +139,13 @@ class LeaveApplication(Document):
|
||||
doc.insert(ignore_permissions=True)
|
||||
doc.submit()
|
||||
|
||||
def cancel_attendance(self):
|
||||
if self.docstatus == 2:
|
||||
attendance = frappe.db.sql("""select name from `tabAttendance` where employee = %s\
|
||||
and (attendance_date between %s and %s) and docstatus < 2 and status in ('On Leave', 'Half Day')""",(self.employee, self.from_date, self.to_date), as_dict=1)
|
||||
for name in attendance:
|
||||
frappe.db.set_value("Attendance", name, "docstatus", 2)
|
||||
|
||||
def validate_salary_processed_days(self):
|
||||
if not frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user