Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow creating attendance requests for future dates #2292

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hrms/hr/doctype/attendance_request/attendance_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions hrms/hr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Loading