Hi All
In setting up the HR module in V5, I have being going back through some standard tests to see how things work.
I have been testing and setting up the Leave Allocation tools where I came across a small issue which I think I have resolved. Advice from the team would be appreciated to ensure that I haven’t overlooked anything though.
The scenario happened during the New Year holiday where I have been entering employee’s leave. My company gave 1/2 day complementary leave on 31st Dec and the employees had to take 1/2 day out of their normal allocation. When I entered the 1/2 from the normal allocation everything was fine. However when I then tried to enter the complementary leave the system would not allow it as the person already had a 1/2 booked although it was a different leave type.
To solve the situation I ensured that there were a few days in the complementary leave allocation and then adjusted the SQL in the validate_leave_overlap method of leave_application.py (as shown below)
for d in frappe.db.sql("""select name, leave_type, posting_date,
from_date, to_date
from `tabLeave Application`
where
employee = %(employee)s
and docstatus < 2
and status in ("Open", "Approved")
and (from_date between %(from_date)s and %(to_date)s
or to_date between %(from_date)s and %(to_date)s
or %(from_date)s between from_date and to_date)
and name != %(name)s
and leave_type = %(leave_type)s""", {
"employee": self.employee,
"from_date": self.from_date,
"to_date": self.to_date,
"name": self.name,
"leave_type": self.leave_type
}, as_dict = 1):
The new parts to the query are to add in a condition in the where clause which includes a match against the leave type:
spaces`and leave_type = %(leave_type)s
and the value passed in here:
"leave_type": self.leave_type
There are two leave types set up for this situation, normal Annual Leave @ 23 days and Comlementary Leave @ 5 days.
Does this sound like a reasonable customisation? Could it be included in the core product?
Many thanks