fix: handle carry forwarded leaves while checking for duplicate allocation

(cherry picked from commit bd1555bd23)
This commit is contained in:
Rucha Mahabal
2022-02-08 14:36:31 +05:30
committed by mergify-bot
parent aa04e02710
commit a5f016a7cd
2 changed files with 60 additions and 2 deletions

View File

@@ -428,7 +428,12 @@ def is_earned_leave_already_allocated(allocation, annual_allocation):
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