Need your help with a requirement for a reservation system. I have created the entity 'Reservation', which contains the attributes 'Arrival date' and 'Period of stay'. When the user confirms the reservation, a microflow is triggered that should check the availability for all selected days. Obviously, the period of stay can be any number of days. I have already created a loop to check the current reservation, based on arrival date and period of stay, against the existing reservations. However, I have my doubts on what would be the most effective way to model this. Please note that the 'Period of stay' attribute is an integer (e.g. 3), meaning that some type of conversion should take place to determine the actual dates (8-5 and 9-5) after the arrival date (7-5). [Edit] Please see the part of the microflow where the availability check is performed below. Explanation: Firstly, I am creating a list to add existing reservations on the same date (checked in the loop). Secondly, I am retrieving the list of roomtypes (+number, e.g. a hotel does offer 10 standard rooms) and reservations to filter the number of existing reservations for the roomtype of the current reservation. Thirdly, I am iterating over this list to determine the overlap between the current reservation date(s) and existing reservation date(s). This is where I am stuck, as I cannot find a way to compare the period of stay of the current reservation with the period of stay of the existing reservations. How can this be modeled in an efficient way? Or am I overcomplicating the model for what I am trying to achieve?
Arjan van den Top
I would place a entity between Room and Reservation, called Booking (or something like that). It holds a date and associations between Room (1-n) and Reservation (1-n). A Room can have only one Booking per date, a Reservation can consist of one or more Bookings. When someone places a Reservation, you need to find a Room without a Booking for the arrival date. So you could do a retrieval(list) on Room without a Booking for that day. Then iterate over that list of Rooms and check for availibility on the rest of the days for the reservation because I suspect you do not want a Customer to switch Rooms in between their stay (but is possible with this domain).
Hope this is of some help!
I once had a problem similar to yours. I believe one of the most elegant way to do this is to mathematically check if your new date overlaps an existing range.
In your case this means that you should convert your dates to integers in order to use them in a formula.