fix: Added column Expired Leave (#21857)
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 84f2c83..f2968bc 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -438,14 +438,23 @@
leave_allocation = {}
for d in allocation_records:
allocation = allocation_records.get(d, frappe._dict())
+
+ total_allocated_leaves = frappe.db.get_value('Leave Allocation', {
+ 'from_date': ('<=', date),
+ 'to_date': ('>=', date),
+ 'leave_type': allocation.leave_type,
+ }, 'SUM(total_leaves_allocated)') or 0
+
remaining_leaves = get_leave_balance_on(employee, d, date, to_date = allocation.to_date,
consider_all_leaves_in_the_allocation_period=True)
+
end_date = allocation.to_date
leaves_taken = get_leaves_for_period(employee, d, allocation.from_date, end_date) * -1
leaves_pending = get_pending_leaves_for_period(employee, d, allocation.from_date, end_date)
leave_allocation[d] = {
- "total_leaves": allocation.total_leaves_allocated,
+ "total_leaves": total_allocated_leaves,
+ "expired_leaves": total_allocated_leaves - (remaining_leaves + leaves_taken),
"leaves_taken": leaves_taken,
"pending_leaves": leaves_pending,
"remaining_leaves": remaining_leaves}
diff --git a/erpnext/hr/doctype/leave_application/leave_application_dashboard.html b/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
index 2385b6a..295f3b4 100644
--- a/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
+++ b/erpnext/hr/doctype/leave_application/leave_application_dashboard.html
@@ -4,11 +4,12 @@
<table class="table table-bordered small">
<thead>
<tr>
- <th style="width: 20%">{{ __("Leave Type") }}</th>
- <th style="width: 20%" class="text-right">{{ __("Total Allocated Leaves") }}</th>
- <th style="width: 20%" class="text-right">{{ __("Used Leaves") }}</th>
- <th style="width: 20%" class="text-right">{{ __("Pending Leaves") }}</th>
- <th style="width: 20%" class="text-right">{{ __("Available Leaves") }}</th>
+ <th style="width: 16%">{{ __("Leave Type") }}</th>
+ <th style="width: 16%" class="text-right">{{ __("Total Allocated Leaves") }}</th>
+ <th style="width: 16%" class="text-right">{{ __("Expired Leaves") }}</th>
+ <th style="width: 16%" class="text-right">{{ __("Used Leaves") }}</th>
+ <th style="width: 16%" class="text-right">{{ __("Pending Leaves") }}</th>
+ <th style="width: 16%" class="text-right">{{ __("Available Leaves") }}</th>
</tr>
</thead>
@@ -17,6 +18,7 @@
<tr>
<td> {%= key %} </td>
<td class="text-right"> {%= value["total_leaves"] %} </td>
+ <td class="text-right"> {%= value["expired_leaves"] %} </td>
<td class="text-right"> {%= value["leaves_taken"] %} </td>
<td class="text-right"> {%= value["pending_leaves"] %} </td>
<td class="text-right"> {%= value["remaining_leaves"] %} </td>