Skip to content

Commit

Permalink
feat: add validation for dates
Browse files Browse the repository at this point in the history
(cherry picked from commit e0ea520)
  • Loading branch information
krantheman authored and mergify[bot] committed Dec 12, 2023
1 parent 7b9ed80 commit 59c1a8f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hrms/hr/doctype/job_opening/job_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import frappe
from frappe import _
from frappe.utils import get_link_to_form, getdate
from frappe.model.naming import set_name_from_naming_options
from frappe.utils import get_link_to_form, getdate
from frappe.website.website_generator import WebsiteGenerator

from hrms.hr.doctype.staffing_plan.staffing_plan import (
Expand All @@ -29,9 +29,17 @@ def autoname(self):
def validate(self):
if not self.route:
self.route = frappe.scrub(self.job_title).replace("_", "-")
self.validate_closes_on()
self.validate_current_vacancies()
self.update_job_requisition_status()

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

def validate_current_vacancies(self):
if not self.staffing_plan:
staffing_plan = get_active_staffing_plan_details(self.company, self.designation)
Expand Down

0 comments on commit 59c1a8f

Please sign in to comment.