- Biblio::check_booking uses $self->current_checkouts to count checked-out items overlapping with a booking period - This counts checkouts on ALL items for the biblio, including non-bookable ones (e.g. items with an excluded item type) - When only a subset of items are bookable, checkouts on non-bookable siblings incorrectly reduce the available pool, producing false clashes - The integer-based counting ($booked_count) can also double-count an item that has both an active booking and an active checkout, further inflating the unavailable count Steps to reproduce: - Have a biblio with multiple items where only some are bookable - Check out one or more of the non-bookable items - Create a booking on one of the bookable items - Clash is incorrectly detected even though all bookable items are available
Created attachment 193375 [details] [review] Bug 41886: Filter checkouts to bookable items in check_booking - Biblio::check_booking counts current checkouts toward the unavailable pool to detect booking clashes - It counts checkouts on ALL items for the biblio, including non-bookable ones (e.g. items with an excluded item type) - When only a subset of items are bookable, checkouts on non-bookable siblings incorrectly reduce the available pool, producing false clashes - Restrict the checkout query to only count items whose itemnumber is in the bookable items set To test: 1. Have a biblio with at least two items, where one item is bookable and the other is not (bookable = 0). 2. Check out the non-bookable item to a patron. 3. Attempt to create a booking for the bookable item. 4. Without the patch: a clash is detected even though the bookable item is available. 5. Apply the patch. 6. Repeat steps 2-3. 7. Verify the booking succeeds without a false clash. 8. Run: prove t/db_dependent/Koha/Biblio.t and confirm the new subtest "checkouts on non-bookable items do not cause false clashes" passes.
Created attachment 193533 [details] [review] Bug 41886: Filter checkouts to bookable items in check_booking - Biblio::check_booking counts current checkouts toward the unavailable pool to detect booking clashes - It counts checkouts on ALL items for the biblio, including non-bookable ones (e.g. items with an excluded item type) - When only a subset of items are bookable, checkouts on non-bookable siblings incorrectly reduce the available pool, producing false clashes - Restrict the checkout query to only count items whose itemnumber is in the bookable items set To test: 1. Have a biblio with at least two items, where one item is bookable and the other is not (bookable = 0). 2. Check out the non-bookable item to a patron. 3. Attempt to create a booking for the bookable item. 4. Without the patch: a clash is detected even though the bookable item is available. 5. Apply the patch. 6. Repeat steps 2-3. 7. Verify the booking succeeds without a false clash. 8. Run: prove t/db_dependent/Koha/Biblio.t and confirm the new subtest "checkouts on non-bookable items do not cause false clashes" passes. Signed-off-by: David Nind <david@davidnind.com>