fix: handle carry forwarded leaves while checking for duplicate allocation
diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py
index 2a07e56..7fd3a98 100644
--- a/erpnext/hr/utils.py
+++ b/erpnext/hr/utils.py
@@ -312,7 +312,12 @@
leaves_for_passed_months = assignment.get_leaves_for_passed_months(allocation.leave_type,
annual_allocation, leave_type_details, date_of_joining)
- if allocation.total_leaves_allocated >= leaves_for_passed_months:
+ # exclude carry-forwarded leaves while checking for leave allocation for passed months
+ num_allocations = allocation.total_leaves_allocated
+ if allocation.unused_leaves:
+ num_allocations -= allocation.unused_leaves
+
+ if num_allocations >= leaves_for_passed_months:
return True
return False