fix: validated leave allocation (#20636)
* fix: validated leave allocation * fix: changes requested * Update erpnext/hr/doctype/leave_encashment/leave_encashment.py Co-Authored-By: Nabin Hait <nabinhait@gmail.com> Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
parent
9f4b46050f
commit
773e7debb9
@ -64,6 +64,9 @@ class LeaveEncashment(Document):
|
|||||||
|
|
||||||
allocation = self.get_leave_allocation()
|
allocation = self.get_leave_allocation()
|
||||||
|
|
||||||
|
if not allocation:
|
||||||
|
frappe.throw(_("No Leaves Allocated to Employee: {0} for Leave Type: {1}").format(self.employee, self.leave_type))
|
||||||
|
|
||||||
self.leave_balance = allocation.total_leaves_allocated - allocation.carry_forwarded_leaves_count\
|
self.leave_balance = allocation.total_leaves_allocated - allocation.carry_forwarded_leaves_count\
|
||||||
- get_unused_leaves(self.employee, self.leave_type, allocation.from_date, self.encashment_date)
|
- get_unused_leaves(self.employee, self.leave_type, allocation.from_date, self.encashment_date)
|
||||||
|
|
||||||
@ -116,4 +119,4 @@ def create_leave_encashment(leave_allocation):
|
|||||||
leave_type=allocation.leave_type,
|
leave_type=allocation.leave_type,
|
||||||
encashment_date=allocation.to_date
|
encashment_date=allocation.to_date
|
||||||
))
|
))
|
||||||
leave_encashment.insert(ignore_permissions=True)
|
leave_encashment.insert(ignore_permissions=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user