Photo by freestocks on Unsplash

Coda and room reservations

Can we use Coda for resource planning?

Christiaan Huizer
6 min readFeb 14, 2024

--

The answer depends on your Coda experience and the specific question. This blog contains some directions you may want to follow when you want to check the availability of a room. This blog is not about finding an available room that fits your budget and the required beds in a certain time span. That is a different question and a puzzle harder to solve in Coda.

This blog assumes you have selected a room and next you want to if it is available.

My suggestions work well for smaller settings. When you run a serious room renting service like a hotel, you may consider a different and dedicated solution. Coda can become expensive in terms of work required when you stretch her boundaries just that little bit too far. More often than not, you cannot tell when this happens, but you always can observe it when looking back. On the other hand, the higher your Coda proficiency the less boundaries you come across.

My main point is that tweaking Coda should remain intuitive and simple. Your doc should feel as a friend, not as something you have to fight. That said, let’s have a look at the business rules we have to put in place to check the availability for a selected room.

What are the business rules?

We have 4 rooms. Some rooms are available, others not (repair, etc). We only show available rooms. That is rule number one. A valid room booking requires two different dates since you pass the night. The business for renting out day rooms is a different business with different business rules and applies for example to the bus drivers who drive night lines and sleep during the day. This blog is about standard rooms, thus for the night. This is rule number two. Guests leave the room at 11h (in the morning) and new guests can enter as of 16h. In between we clean the rooms. That means that if a room is booked for the night of Feb 14, you still can have Feb 14 as end date for a previous booking. That is rule number three. You can not select booked dates. Thus when a room is booked for Feb 14 — Feb 17, you cannot book the same room for Feb 12 — Feb 19, even if both the arrival and the departure date itself are available. This is maybe the hardest nut to crack. You can however book Feb 12 — Feb 14 and Feb 17 — Feb 19. This is rule number four.

Rule number one

It starts with a simple select item, although you can complicate this with a separate table in which you define per date range when a room is available for rent or not. I kept it simple with a manuel to adapt option.

Via options in your relation, you filter on Show online rooms.

Rule number two

This one is about two related sub rules. First, the arrival date cannot be the same as the departure date and the departure date cannot take place before the arrival date. The solution is simple, the departure date should be greater than the arrival date. Always. We sell nights, not days.

CurrentValue.Name > thisRow.startDate.Name

The reason you see Name is to force the number we get via a relation to behave like a date. The table feeding this column contains dates written as Wed, Feb 7, 2024 and when you want the value of an object, you have to chain the object (currentvalue) to its column name — Name in this example.

Rule number three

Give access to dates that are partly reserved (morning or evening) or not reserved for the selected room. This requires access to a table that has rows with dates and rooms. We call this table DB Reservations and when data comes in via a form we have a button transposing data before adding it to this table. DB Reservations permits to filter on dates and on rooms. By adding checks, we made it possible to filter on ‘in’ and ‘out’ as well.

DB Reservations

Alternatively you can apply the Max method to solve this puzzle. I took a different route a bit simpler and based on filtering only. The wonderful Max method relies on looping and that is an expensive operation, filters perform better, are more efficient. I tell the filter to ignore the check-in or check-out dates, depending on the arrival or departure date.

arrival date filter

There is a third alternative to deal with rule number three. It requires a separate start & end date in the table you reference. The details of this approach you find here.


Room.Bookings.Filter(
CurrentValue.End > Search.Start
AND CurrentValue.Start < Search.End
).IsBlank()

Rule number four

Maybe the hardest nut to crack. You don’t want to allow dates when “in-between” dates are booked, but you want a list of dates when possible, including after the latest booking date for a room. Again logical operators are our friends in your filter.

Dashboard logics

As I wrote in other blogs, for most users it is better not to see tables. Instead we created a few pages with controllers and canvas formulas showing essentials. This would have been simple may modals not have leaked to the source table, a table the user should not see. Since Coda believes that tables should be at the center of the Coda experience and we don’t believe this is the path to follow, we work with controllers and canvas formulas.

possible styling dashboard

The doc I made and contains the booking logic you find here.

Can you make it?

On purpose I did not spell out all the code required to make it work. Building a functional Coda doc is a reward, not a gift, a reward for a continued effort to gain and maintain a deep understanding of how to Coda.

You can make it when you take the time to train yourself in setting up smart filters, they are the corner stone of the main solution.

My name is Christiaan and blog about Coda. Since the summer of 2023 often (but not only) about how to Coda with AI to support organisations dealing with texts and templates. The latest Coda AI update was on Dec 7, 2023.

Why I focus on Coda AI you can read here: ⤵️

I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. You find my (for free) contributions to the Coda Community and on Twitter.

Coda comes with a set of building blocks ー like pages for infinite depth, tables that talk to each other, and buttons that take action inside or outside your doc ーso anyone can make a doc as powerful as an app (source).

Not to forget: the Coda Community provides great insights for free once you add a sample doc.

--

--

Christiaan Huizer
Christiaan Huizer

Written by Christiaan Huizer

I write about how to Coda . You find blogs for beginners and experienced makers. I publish about 1 / week. Welcome!