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

fix: Attendance Request as a draft for a future date #2060

Closed
Closed
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
1 change: 0 additions & 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,6 @@ class OverlappingAttendanceRequestError(frappe.ValidationError):
class AttendanceRequest(Document):
def validate(self):
validate_active_employee(self.employee)
validate_dates(self, self.from_date, self.to_date)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This validation checks if to_date is less than from_date
Attendance Request does not have an explicit validation for future dates, I think. It's only in the Attendance doctype

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, you want to say that we have to add a new custom validation to the attendance request and simply remove the "future dates are not valid" validation. right?

new validation like

def validate_dates_for_ar(doc, from_date, to_date):
    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 cannot be less than from date"))
    elif date_of_joining and getdate(from_date) < getdate(date_of_joining):
        frappe.throw(_("From date cannot be less than employee's joining date"))
    elif relieving_date and getdate(to_date) > getdate(relieving_date):
        frappe.throw(_("To date cannot be greater than employee's relieving date"))

self.validate_half_day()
self.validate_request_overlap()

Expand Down
Loading