mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
fix: calculate pending leaves (#19411)
This commit is contained in:
committed by
Nabin Hait
parent
5c9d92eabf
commit
7638788c2f
@@ -503,14 +503,17 @@ def get_leave_allocation_records(employee, date, leave_type=None):
|
|||||||
|
|
||||||
def get_pending_leaves_for_period(employee, leave_type, from_date, to_date):
|
def get_pending_leaves_for_period(employee, leave_type, from_date, to_date):
|
||||||
''' Returns leaves that are pending approval '''
|
''' Returns leaves that are pending approval '''
|
||||||
return frappe.db.get_value("Leave Application",
|
leaves = frappe.get_all("Leave Application",
|
||||||
filters={
|
filters={
|
||||||
"employee": employee,
|
"employee": employee,
|
||||||
"leave_type": leave_type,
|
"leave_type": leave_type,
|
||||||
"from_date": ("<=", from_date),
|
|
||||||
"to_date": (">=", to_date),
|
|
||||||
"status": "Open"
|
"status": "Open"
|
||||||
}, fieldname=['SUM(total_leave_days)']) or flt(0)
|
},
|
||||||
|
or_filters={
|
||||||
|
"from_date": ["between", (from_date, to_date)],
|
||||||
|
"to_date": ["between", (from_date, to_date)]
|
||||||
|
}, fields=['SUM(total_leave_days) as leaves'])[0]
|
||||||
|
return leaves['leaves'] if leaves['leaves'] else 0.0
|
||||||
|
|
||||||
def get_remaining_leaves(allocation, leaves_taken, date, expiry):
|
def get_remaining_leaves(allocation, leaves_taken, date, expiry):
|
||||||
''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry '''
|
''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry '''
|
||||||
|
|||||||
Reference in New Issue
Block a user