https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40134

--- Comment #1 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 183211
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183211&action=edit
Bug 40134: Implement dynamic item assignment with smart window maximization

This patch implements smart window maximization for "any item of itemtype X"
bookings using dynamic item pool reduction. The core principle is "never re-add
items to pool" - once an item is removed from the available pool because it
becomes unavailable, it's never re-added even if it becomes available again
later. This ensures optimal resource allocation and maximum booking windows.

Key features:
- Dynamic item pool reduction algorithm in isDateInMaximumWindow()
- Smart itemtype availability calculation in isDateDisabledForItemtype()
- Optimal item selection for booking submission in selectOptimalItem()
- Future availability calculation to choose best items
- Comprehensive JSDoc documentation with detailed examples

The algorithm works by:
1. Starting with items available on the selected start date
2. Walking through each day from start to target end date
3. Removing items from pool when they become unavailable
4. Never re-adding items even if they become available again later
5. Disabling dates when no items remain in pool

This maximizes booking windows while preventing conflicts by being conservative
about item availability.

Test plan:
1. Apply patch and restart services
2. Navigate to a biblio detail page with bookable items of multiple types
3. Click "Place booking" and select a patron and pickup location
4. Select an itemtype (not a specific item) to enable "any item" mode
5. Select a start date - verify end date options are maximized based on
   available items across the booking period
6. Test with complex booking scenarios where items have overlapping bookings
7. Verify that the algorithm correctly reduces the item pool as items become
   unavailable and extends booking windows as far as possible
8. Confirm that items which become available again later in the period are
   not re-added to the pool (key algorithm principle)
9. Submit booking and verify optimal item is selected automatically

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to