Reservation System

Reservation System

Here is my basic code to start with.

// Step 1: Capture user input for Check-In and Check-Out dates
check_in_date = toDate(check_in,"MM-dd-yyyy");
check_out_date = toDate(check_in,"MM-dd-yyyy");
//info "Check in date " + check_in_date + " - Check out date " + check_out_date;
// Step 2: Get a list of all nightly rentals I only have 68 rentals
all_rentals = Sites[Campsites == true];
//info "All Rentals " + Sites[Campsites == true].count();
// Step 3: Filter rentals that are not booked for the requested date range
available_rentals = Collection();
// Create an empty collection to store available rentals
for each  rental in all_rentals
{
// Check for existing reservations in the "Reservations" table
reservations = CG_Reservation[Sites == rental && Active_Reservation == true && Check_In != null && Last_Night != null && Check_In <= check_out_date && Last_Night >= check_in_date];
// If no reservations conflict with the requested dates, add the rental to available_rentals
if(reservations.ID == null)
{
available_rentals.insert(rental.ID);
}
}

When I execute the code with these dates, 09-25-2024 Check-in and 10-01-2024 Check-out. It's returning 37 available. The correct answer would be 14
How do I remove the 23 that's incorrect
It's returning Rental 2B  Which is already rented 09-27-2024 to 09-29-2024 

Any suggestions
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方