Skip to content

Commit

Permalink
feat: add validation for Posted On date
Browse files Browse the repository at this point in the history
(cherry picked from commit 3d5a95f)
  • Loading branch information
krantheman authored and mergify[bot] committed Dec 12, 2023
1 parent 59c1a8f commit 88f6422
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hrms/hr/doctype/job_opening/job_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ def autoname(self):
def validate(self):
if not self.route:
self.route = frappe.scrub(self.job_title).replace("_", "-")
self.validate_closes_on()
self.validate_dates()
self.validate_current_vacancies()
self.update_job_requisition_status()

def validate_closes_on(self):
def validate_dates(self):
self.validate_from_to_dates("posted_on", "closes_on")
today = getdate()
posted_on = getdate(self.posted_on)
if posted_on > today:
frappe.throw(_(f"{frappe.bold('Posted On')} cannot be a future date"))
closes_on = getdate(self.closes_on)
if closes_on < today:
frappe.throw(_(f"{frappe.bold('Closes On')} cannot be a past date"))
Expand Down

0 comments on commit 88f6422

Please sign in to comment.