fix: calculate pending leaves (#19411)
This commit is contained in:
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):
|
||||
''' Returns leaves that are pending approval '''
|
||||
return frappe.db.get_value("Leave Application",
|
||||
leaves = frappe.get_all("Leave Application",
|
||||
filters={
|
||||
"employee": employee,
|
||||
"leave_type": leave_type,
|
||||
"from_date": ("<=", from_date),
|
||||
"to_date": (">=", to_date),
|
||||
"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):
|
||||
''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry '''
|
||||
|
Loading…
x
Reference in New Issue
Block a user