fix: validated leave allocation (#20636)

* fix: validated leave allocation

* fix: changes requested

* Update erpnext/hr/doctype/leave_encashment/leave_encashment.py

Co-Authored-By: Nabin Hait <nabinhait@gmail.com>

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
diff --git a/erpnext/hr/doctype/leave_encashment/leave_encashment.py b/erpnext/hr/doctype/leave_encashment/leave_encashment.py
index 42f0179..ad2cc02 100644
--- a/erpnext/hr/doctype/leave_encashment/leave_encashment.py
+++ b/erpnext/hr/doctype/leave_encashment/leave_encashment.py
@@ -64,6 +64,9 @@
 
 		allocation = self.get_leave_allocation()
 
+		if not allocation:
+			frappe.throw(_("No Leaves Allocated to Employee: {0} for Leave Type: {1}").format(self.employee, self.leave_type))
+
 		self.leave_balance = allocation.total_leaves_allocated - allocation.carry_forwarded_leaves_count\
 			- get_unused_leaves(self.employee, self.leave_type, allocation.from_date, self.encashment_date)
 
@@ -116,4 +119,4 @@
 			leave_type=allocation.leave_type,
 			encashment_date=allocation.to_date
 		))
-		leave_encashment.insert(ignore_permissions=True)
\ No newline at end of file
+		leave_encashment.insert(ignore_permissions=True)