Skip to content

Commit

Permalink
fix: get_previous_allocation return value
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed Nov 17, 2023
1 parent 9139c14 commit 6cb8a40
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion erpnext/hr/doctype/leave_allocation/leave_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def create_leave_ledger_entry(self, submit=True):
def get_previous_allocation(from_date, leave_type, employee):
"""Returns document properties of previous allocation"""
Allocation = frappe.qb.DocType("Leave Allocation")
return (
allocations = (
frappe.qb.from_(Allocation)
.select(
Allocation.name,
Expand All @@ -313,8 +313,11 @@ def get_previous_allocation(from_date, leave_type, employee):
& (Allocation.docstatus == 1)
)
.orderby(Allocation.to_date, order=frappe.qb.desc)
.limit(1)
).run(as_dict=True)

return allocations[0] if allocations else None


def get_leave_allocation_for_period(
employee, leave_type, from_date, to_date, exclude_allocation=None
Expand Down

0 comments on commit 6cb8a40

Please sign in to comment.