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:
NIYAZ RAZAK 2023-09-19 16:20:47 +03:00 committed by GitHub
parent e19e04b050
commit 141ba255e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):