mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
Cancel attendance if leave application is cancelled (#14372)
* Cancel attendance if leave application is cancelled * Fix as per review
This commit is contained in:
@@ -60,6 +60,7 @@ class LeaveApplication(Document):
|
|||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
# notify leave applier about cancellation
|
# notify leave applier about cancellation
|
||||||
self.notify_employee("cancelled")
|
self.notify_employee("cancelled")
|
||||||
|
self.cancel_attendance()
|
||||||
|
|
||||||
def validate_dates(self):
|
def validate_dates(self):
|
||||||
if self.from_date and self.to_date and (getdate(self.to_date) < getdate(self.from_date)):
|
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.insert(ignore_permissions=True)
|
||||||
doc.submit()
|
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):
|
def validate_salary_processed_days(self):
|
||||||
if not frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
|
if not frappe.db.get_value("Leave Type", self.leave_type, "is_lwp"):
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user