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:
Anurag Mishra 2020-02-26 14:50:57 +05:30 committed by GitHub
parent 9f4b46050f
commit 773e7debb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,6 +64,9 @@ class LeaveEncashment(Document):
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\
- get_unused_leaves(self.employee, self.leave_type, allocation.from_date, self.encashment_date)