calcom / cal.com

Scheduling infrastructure for absolutely everyone.
https://cal.com
Other
30.04k stars 7.09k forks source link

[CAL-3692] "Could not book the meeting. Booking Limit for this event type has been reached" - #15005

Open milospuac opened 2 months ago

milospuac commented 2 months ago

This error is showing when booking the event type that has 5 bookings per week limit, instead of just blocking that week

https://cal.com/team/chronius-health/comprehensivecare-kickoff

From SyncLinear.com | CAL-3692

dosubot[bot] commented 2 months ago

The error message you're encountering, "Could not book the meeting. Booking Limit for this event type has been reached," is likely due to how the booking system calculates weekly limits, especially when bookings span across the end of one month and the beginning of another. This calculation does not align perfectly with a standard calendar week but rather with the system's definition of a week in relation to booking limits.

A recent change in the booking logic, specifically the addition of a "metadata" column to the "Booking" table, could also impact how bookings are processed. This change might affect the application's interaction with the database, potentially leading to errors if not properly accounted for.

Moreover, the system has a known limitation in counting bookings within a specified period. It does not count bookings that partially overlap the start or end of the period, which could lead to premature or incorrect triggering of the booking limit reached error. This is due to the database query conditions that require a booking's start and end times to be strictly within the specified period.

The system's handling of bookings and calculation of weekly limits involves parsing booking limits, time zone adjustments, and counting bookings within a defined period while handling the transition between months. This complex logic ensures accurate calculation of weekly limits but may contribute to discrepancies when the expectation is based on a standard calendar week.

If you're experiencing this error under specific circumstances not covered by these explanations, providing more details about those circumstances could help in identifying a more precise cause and solution.

#### Details **Sources** - [[CAL-2237] "Limit booking frequency" setting doesn't work](https://github.com/calcom/cal.com/issues/10361) - [[CAL-1608] When certain limits in place - "Could not book a meeting" error](https://github.com/calcom/cal.com/issues/8594) - [Even when Weekly Limit is reached, week is still shown as available](https://github.com/calcom/cal.com/issues/5268) - [packages/features/bookings/lib/handleNewBooking/test/booking-limits.test.ts](https://github.com/calcom/cal.com/blob/main/packages/features/bookings/lib/handleNewBooking/test/booking-limits.test.ts) - [apps/web/playwright/booking-limits.e2e.ts](https://github.com/calcom/cal.com/blob/main/apps/web/playwright/booking-limits.e2e.ts) - [packages/prisma/migrations/20221129125935_add_metadata_to_booking/migration.sql](https://github.com/calcom/cal.com/blob/main/packages/prisma/migrations/20221129125935_add_metadata_to_booking/migration.sql) - [packages/features/bookings/lib/handleNewBooking.ts](https://github.com/calcom/cal.com/blob/main/packages/features/bookings/lib/handleNewBooking.ts) - [packages/lib/server/checkBookingLimits.ts](https://github.com/calcom/cal.com/blob/main/packages/lib/server/checkBookingLimits.ts) - [packages/features/bookings/lib/handleSeats/test/handleSeats.test.ts](https://github.com/calcom/cal.com/blob/main/packages/features/bookings/lib/handleSeats/test/handleSeats.test.ts) - [packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts](https://github.com/calcom/cal.com/blob/main/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts) - [packages/features/bookings/lib/handleSeats/reschedule/rescheduleSeatedBooking.ts](https://github.com/calcom/cal.com/blob/main/packages/features/bookings/lib/handleSeats/reschedule/rescheduleSeatedBooking.ts) - [packages/app-store/vital/lib/reschedule.ts](https://github.com/calcom/cal.com/blob/main/packages/app-store/vital/lib/reschedule.ts) - [packages/trpc/server/routers/viewer/slots/util.ts](https://github.com/calcom/cal.com/blob/main/packages/trpc/server/routers/viewer/slots/util.ts)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.