fix: Added column Expired Leave (#21857)

This commit is contained in:
Anurag Mishra 2020-05-26 18:08:22 +05:30 committed by GitHub
parent 5fa207f020
commit 56357fafeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -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}

View File

@ -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>