fix(HR): skip earned leaves check for max leaves set to zero or less (#20535)
* fix: skip earned leaves check for max leaves set to zero or less * test: earned leaves creation
This commit is contained in:
parent
a871d30a7d
commit
5d5f5b4f8e
@ -409,7 +409,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(get_leave_balance_on(employee.name, leave_type.name, nowdate(), add_days(nowdate(), 8)), 21)
|
self.assertEqual(get_leave_balance_on(employee.name, leave_type.name, nowdate(), add_days(nowdate(), 8)), 21)
|
||||||
|
|
||||||
def test_earned_leave(self):
|
def test_earned_leaves_creation(self):
|
||||||
leave_period = get_leave_period()
|
leave_period = get_leave_period()
|
||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
leave_type = 'Test Earned Leave Type'
|
leave_type = 'Test Earned Leave Type'
|
||||||
@ -437,6 +437,14 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
i += 1
|
i += 1
|
||||||
self.assertEqual(get_leave_balance_on(employee.name, leave_type, nowdate()), 6)
|
self.assertEqual(get_leave_balance_on(employee.name, leave_type, nowdate()), 6)
|
||||||
|
|
||||||
|
# validate earned leaves creation without maximum leaves
|
||||||
|
frappe.db.set_value('Leave Type', leave_type, 'max_leaves_allowed', 0)
|
||||||
|
i = 0
|
||||||
|
while(i<6):
|
||||||
|
allocate_earned_leaves()
|
||||||
|
i += 1
|
||||||
|
self.assertEqual(get_leave_balance_on(employee.name, leave_type, nowdate()), 9)
|
||||||
|
|
||||||
# test to not consider current leave in leave balance while submitting
|
# test to not consider current leave in leave balance while submitting
|
||||||
def test_current_leave_on_submit(self):
|
def test_current_leave_on_submit(self):
|
||||||
employee = get_employee()
|
employee = get_employee()
|
||||||
|
@ -316,7 +316,9 @@ def allocate_earned_leaves():
|
|||||||
|
|
||||||
allocation = frappe.get_doc('Leave Allocation', allocation.name)
|
allocation = frappe.get_doc('Leave Allocation', allocation.name)
|
||||||
new_allocation = flt(allocation.total_leaves_allocated) + flt(earned_leaves)
|
new_allocation = flt(allocation.total_leaves_allocated) + flt(earned_leaves)
|
||||||
new_allocation = new_allocation if new_allocation <= e_leave_type.max_leaves_allowed else e_leave_type.max_leaves_allowed
|
|
||||||
|
if new_allocation > e_leave_type.max_leaves_allowed and e_leave_type.max_leaves_allowed > 0:
|
||||||
|
new_allocation = e_leave_type.max_leaves_allowed
|
||||||
|
|
||||||
if new_allocation == allocation.total_leaves_allocated:
|
if new_allocation == allocation.total_leaves_allocated:
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user