From 5f51f0d2ec50a95f49028dceaff743806697e8e6 Mon Sep 17 00:00:00 2001 From: Ejaaz Khan <67804911+iamejaaz@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:45:08 +0530 Subject: [PATCH] feat: allow creating attendance requests for future dates --- hrms/hr/doctype/attendance_request/attendance_request.py | 2 +- hrms/hr/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hrms/hr/doctype/attendance_request/attendance_request.py b/hrms/hr/doctype/attendance_request/attendance_request.py index 96f399b286..03572b471b 100644 --- a/hrms/hr/doctype/attendance_request/attendance_request.py +++ b/hrms/hr/doctype/attendance_request/attendance_request.py @@ -19,7 +19,7 @@ class OverlappingAttendanceRequestError(frappe.ValidationError): class AttendanceRequest(Document): def validate(self): validate_active_employee(self.employee) - validate_dates(self, self.from_date, self.to_date) + validate_dates(self, self.from_date, self.to_date, False) self.validate_half_day() self.validate_request_overlap() diff --git a/hrms/hr/utils.py b/hrms/hr/utils.py index 6a2d30c445..201a5cdf57 100644 --- a/hrms/hr/utils.py +++ b/hrms/hr/utils.py @@ -174,13 +174,13 @@ def get_employee_field_property(employee, fieldname): } -def validate_dates(doc, from_date, to_date): +def validate_dates(doc, from_date, to_date, restrict_future_dates=True): date_of_joining, relieving_date = frappe.db.get_value( "Employee", doc.employee, ["date_of_joining", "relieving_date"] ) if getdate(from_date) > getdate(to_date): frappe.throw(_("To date can not be less than from date")) - elif getdate(from_date) > getdate(nowdate()): + elif getdate(from_date) > getdate(nowdate()) and restrict_future_dates: frappe.throw(_("Future dates not allowed")) elif date_of_joining and getdate(from_date) < getdate(date_of_joining): frappe.throw(_("From date can not be less than employee's joining date"))