Leave Encashment - submit, cancel Additional Salary Component
This commit is contained in:
parent
6119b7337c
commit
4c721cbe0f
@ -26,15 +26,25 @@ class LeaveEncashment(Document):
|
||||
def on_submit(self):
|
||||
if not self.leave_allocation:
|
||||
self.leave_allocation = self.get_leave_allocation()
|
||||
|
||||
#ToDo: Create Additional Salary Component
|
||||
additional_component = frappe.new_doc({"doctype": "Additional Salary Component",
|
||||
"company": frappe.get_value("Employee", self.employee, "company"),
|
||||
"employee": self.employee,
|
||||
"salary_component": frappe.get_value("Leave Type", self.leave_type, "earning_component"),
|
||||
"from_date": self.encashment_date,
|
||||
"to_date": self.encashment_date,
|
||||
"amount": self.encashment_amount,
|
||||
"docstatus": 1
|
||||
}).insert()
|
||||
self.set_value("additional_component", additional_component.name)
|
||||
|
||||
# Set encashed leaves in Allocation
|
||||
frappe.db.set_value("Leave Allocation", self.leave_allocation, "total_leaves_encashed",
|
||||
frappe.db.get_value('Leave Allocation', self.leave_allocation, 'total_leaves_encashed') + self.encashable_days)
|
||||
|
||||
def on_cancel(self):
|
||||
# ToDo: Cancel Additional Salary Component
|
||||
if self.additional_component:
|
||||
frappe.get_doc("Additional Salary Component", self.additional_component).cancel()
|
||||
|
||||
if self.leave_allocation:
|
||||
frappe.db.set_value("Leave Allocation", self.leave_allocation, "total_leaves_encashed",
|
||||
frappe.db.get_value('Leave Allocation', self.leave_allocation, 'total_leaves_encashed') - self.encashable_days)
|
||||
|
Loading…
x
Reference in New Issue
Block a user