diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 84f2c836cc..f2968bcd88 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -438,14 +438,23 @@ def get_leave_details(employee, date): 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 2385b6ac1c..295f3b4341 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 @@
{{ __("Leave Type") }} | -{{ __("Total Allocated Leaves") }} | -{{ __("Used Leaves") }} | -{{ __("Pending Leaves") }} | -{{ __("Available Leaves") }} | +{{ __("Leave Type") }} | +{{ __("Total Allocated Leaves") }} | +{{ __("Expired Leaves") }} | +{{ __("Used Leaves") }} | +{{ __("Pending Leaves") }} | +{{ __("Available Leaves") }} |
---|---|---|---|---|---|---|---|---|---|---|
{%= key %} | {%= value["total_leaves"] %} | +{%= value["expired_leaves"] %} | {%= value["leaves_taken"] %} | {%= value["pending_leaves"] %} | {%= value["remaining_leaves"] %} |