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

--- Comment #5 from Paul Derscheid <[email protected]> ---
Created attachment 204927
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=204927&action=edit
Bug 41514: (QA follow-up) Enforce lead/trail periods in item auto-assignment

The "any item" path in Koha::Booking::store() excluded only items whose
bookings overlapped the core date range, so a biblio-level booking could
be stored on an item whose trail period it violates, while the same
booking with an explicit item_id was rejected. _select_optimal_item()
made this worse by preferring the just-vacated item.

- Fetch bookings_trail_period alongside bookings_lead_period in
  _assign_item_for_booking()
- Expand the existing bookings query by lead + trail on both sides,
  matching the check_booking() overlap condition

This makes three copies of the rule lookup and expanded overlap query;
the next follow-up consolidates them.

Test plan:
1. Set bookings_lead_period=3 and bookings_trail_period=2 for a branch
   and itemtype
2. Create a biblio with two bookable items X and Y of that itemtype;
   book X for today+5..today+10 and Y for today+40..today+45
3. Via the REST API, POST a booking for that biblio without item_id for
   today+12..today+14
=> Without this patch it is stored and assigned to X, inside X's trail
   period
=> With this patch it is assigned to Y; a second identical request is
   rejected with a clash
4. prove t/db_dependent/Koha/Booking.t

Assisted-by: Fable 5.1 (Anthropic)
Signed-off-by: Paul Derscheid <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to