mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
fix: leave application dashboard
- total leaves allocated considering cancelled leaves
- optional plural for leave category labels
- show dashboard only once from date is set, else it fetches all allocations till date and generates incorrect balance
- change pending leaves to 'Leaves Pending Approval' for better context
- update labels in Salary Slip Leave Details table
(cherry picked from commit 942511cfff)
This commit is contained in:
committed by
mergify-bot
parent
73b104aa45
commit
b1d3d8226c
@@ -52,7 +52,7 @@ frappe.ui.form.on("Leave Application", {
|
|||||||
make_dashboard: function(frm) {
|
make_dashboard: function(frm) {
|
||||||
var leave_details;
|
var leave_details;
|
||||||
let lwps;
|
let lwps;
|
||||||
if (frm.doc.employee) {
|
if (frm.doc.employee && frm.doc.from_date) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.hr.doctype.leave_application.leave_application.get_leave_details",
|
method: "erpnext.hr.doctype.leave_application.leave_application.get_leave_details",
|
||||||
async: false,
|
async: false,
|
||||||
@@ -146,6 +146,7 @@ frappe.ui.form.on("Leave Application", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
to_date: function(frm) {
|
to_date: function(frm) {
|
||||||
|
frm.trigger("make_dashboard");
|
||||||
frm.trigger("half_day_datepicker");
|
frm.trigger("half_day_datepicker");
|
||||||
frm.trigger("calculate_total_days");
|
frm.trigger("calculate_total_days");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -522,6 +522,7 @@ def get_leave_details(employee, date):
|
|||||||
'to_date': ('>=', date),
|
'to_date': ('>=', date),
|
||||||
'employee': employee,
|
'employee': employee,
|
||||||
'leave_type': allocation.leave_type,
|
'leave_type': allocation.leave_type,
|
||||||
|
'docstatus': 1
|
||||||
}, 'SUM(total_leaves_allocated)') or 0
|
}, 'SUM(total_leaves_allocated)') or 0
|
||||||
|
|
||||||
remaining_leaves = get_leave_balance_on(employee, d, date, to_date = allocation.to_date,
|
remaining_leaves = get_leave_balance_on(employee, d, date, to_date = allocation.to_date,
|
||||||
@@ -529,13 +530,13 @@ def get_leave_details(employee, date):
|
|||||||
|
|
||||||
end_date = allocation.to_date
|
end_date = allocation.to_date
|
||||||
leaves_taken = get_leaves_for_period(employee, d, allocation.from_date, end_date) * -1
|
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)
|
leaves_pending = get_leaves_pending_approval_for_period(employee, d, allocation.from_date, end_date)
|
||||||
|
|
||||||
leave_allocation[d] = {
|
leave_allocation[d] = {
|
||||||
"total_leaves": total_allocated_leaves,
|
"total_leaves": total_allocated_leaves,
|
||||||
"expired_leaves": total_allocated_leaves - (remaining_leaves + leaves_taken),
|
"expired_leaves": total_allocated_leaves - (remaining_leaves + leaves_taken),
|
||||||
"leaves_taken": leaves_taken,
|
"leaves_taken": leaves_taken,
|
||||||
"pending_leaves": leaves_pending,
|
"leaves_pending_approval": leaves_pending,
|
||||||
"remaining_leaves": remaining_leaves}
|
"remaining_leaves": remaining_leaves}
|
||||||
|
|
||||||
#is used in set query
|
#is used in set query
|
||||||
@@ -633,7 +634,7 @@ def get_leave_allocation_records(employee, date, leave_type=None):
|
|||||||
}))
|
}))
|
||||||
return allocated_leaves
|
return allocated_leaves
|
||||||
|
|
||||||
def get_pending_leaves_for_period(employee, leave_type, from_date, to_date):
|
def get_leaves_pending_approval_for_period(employee, leave_type, from_date, to_date):
|
||||||
''' Returns leaves that are pending approval '''
|
''' Returns leaves that are pending approval '''
|
||||||
leaves = frappe.get_all("Leave Application",
|
leaves = frappe.get_all("Leave Application",
|
||||||
filters={
|
filters={
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 16%">{{ __("Leave Type") }}</th>
|
<th style="width: 16%">{{ __("Leave Type") }}</th>
|
||||||
<th style="width: 16%" class="text-right">{{ __("Total Allocated Leave") }}</th>
|
<th style="width: 16%" class="text-right">{{ __("Total Allocated Leave(s)") }}</th>
|
||||||
<th style="width: 16%" class="text-right">{{ __("Expired Leave") }}</th>
|
<th style="width: 16%" class="text-right">{{ __("Expired Leave(s)") }}</th>
|
||||||
<th style="width: 16%" class="text-right">{{ __("Used Leave") }}</th>
|
<th style="width: 16%" class="text-right">{{ __("Used Leave(s)") }}</th>
|
||||||
<th style="width: 16%" class="text-right">{{ __("Pending Leave") }}</th>
|
<th style="width: 16%" class="text-right">{{ __("Leave(s) Pending Approval") }}</th>
|
||||||
<th style="width: 16%" class="text-right">{{ __("Available Leave") }}</th>
|
<th style="width: 16%" class="text-right">{{ __("Available Leave(s)") }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<td class="text-right"> {%= value["total_leaves"] %} </td>
|
<td class="text-right"> {%= value["total_leaves"] %} </td>
|
||||||
<td class="text-right"> {%= value["expired_leaves"] %} </td>
|
<td class="text-right"> {%= value["expired_leaves"] %} </td>
|
||||||
<td class="text-right"> {%= value["leaves_taken"] %} </td>
|
<td class="text-right"> {%= value["leaves_taken"] %} </td>
|
||||||
<td class="text-right"> {%= value["pending_leaves"] %} </td>
|
<td class="text-right"> {%= value["leaves_pending_approval"] %} </td>
|
||||||
<td class="text-right"> {%= value["remaining_leaves"] %} </td>
|
<td class="text-right"> {%= value["remaining_leaves"] %} </td>
|
||||||
</tr>
|
</tr>
|
||||||
{% } %}
|
{% } %}
|
||||||
|
|||||||
@@ -1390,7 +1390,7 @@ class SalarySlip(TransactionBase):
|
|||||||
'total_allocated_leaves': flt(leave_values.get('total_leaves')),
|
'total_allocated_leaves': flt(leave_values.get('total_leaves')),
|
||||||
'expired_leaves': flt(leave_values.get('expired_leaves')),
|
'expired_leaves': flt(leave_values.get('expired_leaves')),
|
||||||
'used_leaves': flt(leave_values.get('leaves_taken')),
|
'used_leaves': flt(leave_values.get('leaves_taken')),
|
||||||
'pending_leaves': flt(leave_values.get('pending_leaves')),
|
'pending_leaves': flt(leave_values.get('leaves_pending_approval')),
|
||||||
'available_leaves': flt(leave_values.get('remaining_leaves'))
|
'available_leaves': flt(leave_values.get('remaining_leaves'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"fieldname": "total_allocated_leaves",
|
"fieldname": "total_allocated_leaves",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Total Allocated Leave",
|
"label": "Total Allocated Leave(s)",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"fieldname": "expired_leaves",
|
"fieldname": "expired_leaves",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Expired Leave",
|
"label": "Expired Leave(s)",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
"fieldname": "used_leaves",
|
"fieldname": "used_leaves",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Used Leave",
|
"label": "Used Leave(s)",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
"fieldname": "pending_leaves",
|
"fieldname": "pending_leaves",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Pending Leave",
|
"label": "Leave(s) Pending Approval",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
"fieldname": "available_leaves",
|
"fieldname": "available_leaves",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Available Leave",
|
"label": "Available Leave(s)",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-02-19 10:47:48.546724",
|
"modified": "2022-02-28 14:01:32.327204",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Payroll",
|
"module": "Payroll",
|
||||||
"name": "Salary Slip Leave",
|
"name": "Salary Slip Leave",
|
||||||
@@ -74,5 +74,6 @@
|
|||||||
"permissions": [],
|
"permissions": [],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
|
"states": [],
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user