fix: date validation on student form, instructor duplicate fix on student grp, instructor with same employee id fix (#20072)

* fix: date validation on inpatient record, else condition removing on clinical prcd templ which is not req

* fix:Pricing Rule error AttributeError: 'str' object has no attribute 'get' #19770

* fix:Pricing Rule error AttributeError: 'str' object has no attribute 'get' #19770

* fix: joining and relieving Date can be on same date as valid use case

* fix-education: date of birth validation

* fix:Sibling child table filtering for duplacacy on student form

* fix:Sibling child table filtering for duplacacy on student form

* fix:Sibling child table filtering for duplacacy on student form

* fix: date validation on student form, instructor duplicacy fix on student grp, instructor with same employee id fix

* fix: date validation on student form, instructor duplicacy fix on student grp, instructor with same employee id fix

* fix: Exclude current record while validating duplicate employee

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
diff --git a/erpnext/education/doctype/instructor/instructor.py b/erpnext/education/doctype/instructor/instructor.py
index 0756b5f..28df2fc 100644
--- a/erpnext/education/doctype/instructor/instructor.py
+++ b/erpnext/education/doctype/instructor/instructor.py
@@ -22,3 +22,12 @@
 				self.name = self.employee
 			elif naming_method == 'Full Name':
 				self.name = self.instructor_name
+
+	def validate(self):
+		self.validate_duplicate_employee()
+
+	def validate_duplicate_employee(self):
+		if self.employee and frappe.db.get_value("Instructor", {'employee': self.employee, 'name': ['!=', self.name]}, 'name'):
+			frappe.throw(_("Employee ID is linked with another instructor"))
+
+
diff --git a/erpnext/education/doctype/student/student.py b/erpnext/education/doctype/student/student.py
index 8e4b4e1..99c4c0e 100644
--- a/erpnext/education/doctype/student/student.py
+++ b/erpnext/education/doctype/student/student.py
@@ -25,6 +25,9 @@
 		if self.date_of_birth and getdate(self.date_of_birth) >= getdate(today()):
 			frappe.throw(_("Date of Birth cannot be greater than today."))
 
+		if self.joining_date and self.date_of_leaving and getdate(self.joining_date) > getdate(self.date_of_leaving):
+			frappe.throw(_("Joining Date can not be greater than Leaving Date"))
+
 	def update_student_name_in_linked_doctype(self):
 		linked_doctypes = get_linked_doctypes("Student")
 		for d in linked_doctypes:
diff --git a/erpnext/education/doctype/student_group/student_group.js b/erpnext/education/doctype/student_group/student_group.js
index c29c134..4165ce0 100644
--- a/erpnext/education/doctype/student_group/student_group.js
+++ b/erpnext/education/doctype/student_group/student_group.js
@@ -122,3 +122,15 @@
 		}
 	}
 });
+
+frappe.ui.form.on('Student Group Instructor', {
+	instructors_add: function(frm){
+		frm.fields_dict['instructors'].grid.get_field('instructor').get_query = function(doc){
+			let instructor_list = [];
+			$.each(doc.instructors, function(idx, val){
+				instructor_list.push(val.instructor);
+			});
+			return { filters: [['Instructor', 'name', 'not in', instructor_list]] };
+		};
+	}
+});
\ No newline at end of file