fix: expired leaves not calculated properly because of newly created expiry ledger entries
diff --git a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py
index 6280ef3..5172fb8 100644
--- a/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py
+++ b/erpnext/hr/report/employee_leave_balance/employee_leave_balance.py
@@ -230,14 +230,14 @@
records = get_leave_ledger_entries(from_date, to_date, employee, leave_type)
for record in records:
- if record.to_date < getdate(to_date):
- expired_leaves += record.leaves
-
# new allocation records with `is_expired=1` are created when leave expires
# these new records should not be considered, else it leads to negative leave balance
if record.is_expired:
continue
+ if record.to_date < getdate(to_date):
+ expired_leaves += record.leaves
+
if record.from_date >= getdate(from_date):
if record.is_carry_forward:
carry_forwarded_leaves += record.leaves