How to identify insert or update in BG_ABSENCE_DURATION
In our BG_ABSENCE_DURATION we are throwing an error if the employee is trying to apply for more than the employee's leave balance.
Lets say employee's entitlement is 20 days.
Employee has already applied for 2 + 5 + 10 + 3= 20 days.
The last leave record of 3 days is a future dated leave.
Employee now tries to change the dates of the last leave record.
Now in BG_ABSENCE_DURATION, leave balance is getting calculated as 0 [ 20 (entitlement) - 20 (already applied and approved) = 0]
The leave which the employee is trying to change is of 3 days. Now absence duration (3) is greater than balance (0)
Here our validation is failing saying that the employee's leave balance is 0 and employee is trying to apply for more leave than his/her remaining balance.