From 2ac8473abf1ca3f6c66262e6617ad0fcb21e6e44 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Fri, 17 Jan 2020 22:46:26 +0530 Subject: [PATCH 1/2] fix: calculate remaining leave balance --- erpnext/hr/doctype/leave_application/leave_application.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 7594cb72ae..42ebab499a 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -529,7 +529,6 @@ def get_pending_leaves_for_period(employee, leave_type, from_date, to_date): def get_remaining_leaves(allocation, leaves_taken, date, expiry): ''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry ''' def _get_remaining_leaves(allocated_leaves, end_date): - remaining_leaves = flt(allocated_leaves) + flt(leaves_taken) if remaining_leaves > 0: remaining_days = date_diff(end_date, date) + 1 @@ -537,10 +536,11 @@ def get_remaining_leaves(allocation, leaves_taken, date, expiry): return remaining_leaves - total_leaves = allocation.total_leaves_allocated + total_leaves = allocation.total_leaves_allocated + flt(leaves_taken) if expiry and allocation.unused_leaves: - remaining_leaves = _get_remaining_leaves(allocation.unused_leaves, expiry) + remaining_leaves = flt(allocation.unused_leaves) + flt(leaves_taken) + remaining_leaves = _get_remaining_leaves(remaining_leaves, expiry) total_leaves = flt(allocation.new_leaves_allocated) + flt(remaining_leaves) From 2892a3b0671ecdab2b4fd431033d5840a332b594 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Mon, 20 Jan 2020 18:00:17 +0530 Subject: [PATCH 2/2] fix: nonetype issue in the total leaves calculation --- erpnext/hr/doctype/leave_application/leave_application.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 42ebab499a..96e4cb5bb3 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -528,7 +528,7 @@ def get_pending_leaves_for_period(employee, leave_type, from_date, to_date): def get_remaining_leaves(allocation, leaves_taken, date, expiry): ''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry ''' - def _get_remaining_leaves(allocated_leaves, end_date): + def _get_remaining_leaves(remaining_leaves, end_date): if remaining_leaves > 0: remaining_days = date_diff(end_date, date) + 1 @@ -536,7 +536,7 @@ def get_remaining_leaves(allocation, leaves_taken, date, expiry): return remaining_leaves - total_leaves = allocation.total_leaves_allocated + flt(leaves_taken) + total_leaves = flt(allocation.total_leaves_allocated) + flt(leaves_taken) if expiry and allocation.unused_leaves: remaining_leaves = flt(allocation.unused_leaves) + flt(leaves_taken)