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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Nihantra-Patel
Copy link
Contributor

version 15

fixes: #1957

Before:

  • They can't save the Attendance Request for a future date.

After:

  • They can now save the Attendance Request as a draft for a future date, but they cannot submit it. Submitting the Attendance Request creates an Attendance record, which has a validation that prevents submissions for future dates.

@Nihantra-Patel Nihantra-Patel changed the title fix: Attendance Request for future date fix: Attendance Request as a draft for a future date Aug 9, 2024
@@ -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"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attendance Request for Future date
2 participants