feat: validate duplicate date in holiday list (#37022)
* feat: validate duplicate date in table * chore: cleanup * chore: linting issues * chore: linting issues --------- Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
parent
e19e04b050
commit
141ba255e0
@ -19,6 +19,7 @@ class HolidayList(Document):
|
||||
def validate(self):
|
||||
self.validate_days()
|
||||
self.total_holidays = len(self.holidays)
|
||||
self.validate_dupliacte_date()
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_weekly_off_dates(self):
|
||||
@ -124,6 +125,14 @@ class HolidayList(Document):
|
||||
def clear_table(self):
|
||||
self.set("holidays", [])
|
||||
|
||||
def validate_dupliacte_date(self):
|
||||
unique_dates = []
|
||||
for row in self.holidays:
|
||||
if row.holiday_date in unique_dates:
|
||||
frappe.throw(_("Holiday Date {0} added multiple times").format(frappe.bold(row.holiday_date)))
|
||||
|
||||
unique_dates.append(row.holiday_date)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_events(start, end, filters=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user