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>
diff --git a/erpnext/setup/doctype/holiday_list/holiday_list.py b/erpnext/setup/doctype/holiday_list/holiday_list.py
index 526bc2b..df5b407 100644
--- a/erpnext/setup/doctype/holiday_list/holiday_list.py
+++ b/erpnext/setup/doctype/holiday_list/holiday_list.py
@@ -19,6 +19,7 @@
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 @@
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):