Calendar : Configure the Calendar Business Rules for Public API Bookings
  

Configure the Calendar Business Rules for Public API Bookings

The Orchestra Calendar Administration allows users to set up booking rules, which will determine which dates and time slots that are shown as bookable for a given Service on a Branch. The business logic driving the booking process is backed by a number of participating entities - Branch, Services, a Week Schedule, Resources and properties such as expected service length and existing Appointments for a given Resource.
The Appointment Profile is what links a Branch and one or more Services together, specifying which set of Resources that should be bookable on the Branch through a Resource Group, which Week Schedule these Resources are made bookable on and the Appointment Profile also specifies the bookable period in days from now, the starting interval of a new Appointment (every Nth minutes) and the booking threshold percentage.
Due to the relative complexity of these business rules, we will try to divide it into smaller pieces in the context of a Booking workflow through the Public API:
1. Select Branch.
a All Branches having an Appointment Profile with at least one linked Service, a Week Schedule and a Resource Group with at least one member are listed.
2. Select Service for Branch.
a All Services marked as public bookable and enabled that are linked to an Appointment Profile on the selected Branch are listed.
3. Select date.
a Return a list of bookable dates where the selected Service on the selected Branch can be served according to a number of rules:
i There must be at least one bookable duration of time for each returned date
ii The "duration" is read from the Service, for example 10 minutes.
iii The Week Schedule is taken into account, for example 09:00 - 10:00
1 The day of week must be marked as working day and bookable in the Week Schedule.
2 A Week Schedule day may have one or more 'blocks' during the day. For example, a block could exist between 09:15 - 09:30 due to the daily coffee break.
iv The "interval" is read from the Appointment Profile, for example 10 minutes giving possible starting times at 09:00, 09:10, 09:20, 09:30, 09:40 and 09:50.
v There must be at least one Resource associated to a Resource Group on one Appointment Profile linked to the Branch that serves the selected Service. For example, we could have a single Resource named 'R1' fulfilling these criteria.
1 Any existing Appointments associated to a Resource may NOT overlap a possible time slot during the bookable period. For example, our 'R1' could have an existing Appointment 09:40 - 09:50.
vi In the example above, we would have bookable time 09:00 - 09:15, 09:30 - 09:40 and 09:50 - 10:00 given that the time slot may not overlap 09:15 - 09:30 or 09:40 - 09:50
1 Since we have an "interval" of 10 minutes and a Service duration of 10 minutes, the existing blocks and Appointment for 'R1' will result in the following bookable time slots:
a 09:00 - 09:10, 09:30 - 09:40, 09:50 - 10:00
2 If we would change the "interval" to every 5 minutes, we would instead have the following possible bookable time slots:
a 09:00 - 09:10, 09:05 - 09:15, 09:30 - 09:40, 09:50 - 10:00.
3 If we would change both the "duration" and "interval" to 5 minutes, the following slots would be available
a 09:00 - 09:05, 09:05 - 09:10, 09:10 - 09:15, 09:30 - 09:35, 09:35 - 09:40, 09:50 - 09:55, 09:55 - 10:00
4. Select time slot of date.
a Given that at least one time slot was returned for the "date available" analysis, that date is eligible for booking. In this step we would present all time slots for the selected date, using exactly the same slot resolution logic as in section (vi) above.
5. Book
a After entering customer details, the call to the book method with a specified date and time will create the Appointment for the Resource selected according to the Appointment Profile's booking threshold percentage. (See “Booking logic” .)