Merge pull request #33194 from barredterra/validate-employee-dates
refactor: validate dates in Employee
This commit is contained in:
commit
01b84a9751
@ -145,33 +145,10 @@ class Employee(NestedSet):
|
||||
if self.date_of_birth and getdate(self.date_of_birth) > getdate(today()):
|
||||
throw(_("Date of Birth cannot be greater than today."))
|
||||
|
||||
if (
|
||||
self.date_of_birth
|
||||
and self.date_of_joining
|
||||
and getdate(self.date_of_birth) >= getdate(self.date_of_joining)
|
||||
):
|
||||
throw(_("Date of Joining must be greater than Date of Birth"))
|
||||
|
||||
elif (
|
||||
self.date_of_retirement
|
||||
and self.date_of_joining
|
||||
and (getdate(self.date_of_retirement) <= getdate(self.date_of_joining))
|
||||
):
|
||||
throw(_("Date Of Retirement must be greater than Date of Joining"))
|
||||
|
||||
elif (
|
||||
self.relieving_date
|
||||
and self.date_of_joining
|
||||
and (getdate(self.relieving_date) < getdate(self.date_of_joining))
|
||||
):
|
||||
throw(_("Relieving Date must be greater than or equal to Date of Joining"))
|
||||
|
||||
elif (
|
||||
self.contract_end_date
|
||||
and self.date_of_joining
|
||||
and (getdate(self.contract_end_date) <= getdate(self.date_of_joining))
|
||||
):
|
||||
throw(_("Contract End Date must be greater than Date of Joining"))
|
||||
self.validate_from_to_dates("date_of_birth", "date_of_joining")
|
||||
self.validate_from_to_dates("date_of_joining", "date_of_retirement")
|
||||
self.validate_from_to_dates("date_of_joining", "relieving_date")
|
||||
self.validate_from_to_dates("date_of_joining", "contract_end_date")
|
||||
|
||||
def validate_email(self):
|
||||
if self.company_email:
|
||||
|
Loading…
x
Reference in New Issue
Block a user