RP_AllocationHandler_TDTM
Booking trigger handler/TDTM
Custom Permission | REDU - Admin |
Event | BeforeInsert, BeforeUpdate, AfterInsert, AfterUpdate |
Object |
Booking |
Related RIO Education Settings | None |
Description
Whenever an existing Booking record has its Booking Alert field updated to Revalidate, this class sets the Booking Alert field to Allocated and sets the Booking Alert Reason field accordingly. The only exception is if the previous Booking Alert value was Allocated, then it sets the Booking Alert field to Revalidated and clears the Booking Alert Reason field.
If an inserted or updated Booking record has a Booking Alert of '=== WARNING MID UPDATE ===', then the Booking Alert is set to Warning, unless the Ignore Alert checkbox is checked, in which case it is set to Allocated. Any Bookings meeting this condition must be checked for double bookings.
If the Resource field is blank then the Booking Alert is is set to Unallocated and the Booking Alert Reason is set accordingly.
If none of these conditions are met, then the Booking must be checked for warnings. First the existing Booking Alert and Booking Alert Reason fields are cleared. If the Resource Type and Plan Line Type fields are not equal, then the Booking Alert field is set to Warning and the Booking Alert Reason field is set accordingly. If the Booking Alert is not set to Warning, or if the Ignore Alert field is true, then the Booking Alert is set to Allocated.
This class will then perform the double booking check on any applicable records, creating Resource Validation, Booking Resource Validation and Plan Resource Validation records as necessary.
After the records have been inserted or updated, this class will check the Booking Alert Reason to see if it is a double booked warning. If it is then it will check the existing related Resource Validations to see if their Bookings still clash. If not, the Resource Validation is deleted. If the Booking has changed, the Start, End or Resource fields are updated accordingly.
If the Booking has been inserted (and the Resource field is set), or if any of the Start, End, Resource or Booking Alert fields have been updated, or if the Booking Alert field is '=== WARNING MID UPDATE ===' or Revalidate, and the Booking Alert Reason is not a double booked warning, then this class will check all Bookings with the same Resource to see if a clash exists, and updates the Booking Alert accordingly.