From 8099224a4090e9df15154e8760ee663b2e109606 Mon Sep 17 00:00:00 2001 From: Corentin Forler Date: Fri, 5 Sep 2025 14:02:47 +0200 Subject: [PATCH] fix(venue): Exclude micro overlap when counting remaining slots --- erpnext/venue/doctype/item_booking/item_booking.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/venue/doctype/item_booking/item_booking.py b/erpnext/venue/doctype/item_booking/item_booking.py index 58c209f187..eb0f551941 100644 --- a/erpnext/venue/doctype/item_booking/item_booking.py +++ b/erpnext/venue/doctype/item_booking/item_booking.py @@ -2038,6 +2038,7 @@ def get_booking_count(item=None, starts_on=None, ends_on=None): ends_on = starts_on starts_on, ends_on = get_datetime(starts_on), get_datetime(ends_on) + assert starts_on and ends_on simultaneous_bookings_enabled = frappe.db.get_single_value( "Venue Settings", "enable_simultaneous_booking" @@ -2049,7 +2050,11 @@ def get_booking_count(item=None, starts_on=None, ends_on=None): else: capacity = 1 - events = _get_events(starts_on, ends_on, item=item_doc) + # Because the query is datetime-inclusive, exclude every result that: + # - ends on the start of the range + # - starts on the end of the range + one_sec = timedelta(seconds=1) + events = _get_events(starts_on + one_sec, ends_on - one_sec, item=item_doc) current = len(events) return {"capacity": capacity, "current": current, "remaining": capacity - current} -- GitLab