Bug 40644 - Bookings biblio checks erroneously if multiple check-outs and bookings exist
Summary: Bookings biblio checks erroneously if multiple check-outs and bookings exist
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Pedro Amorim
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-13 11:25 UTC by Pedro Amorim
Modified: 2025-08-14 18:09 UTC (History)
4 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40644: Only count checkouts that have not yet been counted as bookings (1.68 KB, patch)
2025-08-13 11:32 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 40644: Only count checkouts that have not yet been counted as bookings (1.85 KB, patch)
2025-08-13 11:43 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 40644: Only count checkouts that have not yet been counted as bookings (1.85 KB, patch)
2025-08-13 11:43 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 40644: Only count checkouts that have not yet been counted as bookings (1.92 KB, patch)
2025-08-14 18:09 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Amorim 2025-08-13 11:25:45 UTC

    
Comment 1 Pedro Amorim 2025-08-13 11:32:21 UTC Comment hidden (obsolete)
Comment 2 Pedro Amorim 2025-08-13 11:43:00 UTC Comment hidden (obsolete)
Comment 3 Pedro Amorim 2025-08-13 11:43:50 UTC
Created attachment 185360 [details] [review]
Bug 40644: Only count checkouts that have not yet been counted as bookings

Test plan:
1) Have a record with 8 items.
2) Place a booking on 6 of the items (6 bookings total) for a full month
   (e.g. August)
3) Check-out all 6 of those bookings
4) Attempt to place a new booking for one of the 2 free items for end of month, e.g. (Aug 26 -> Aug 28).
5) It will fail with error "Booking conflicts". This is because the code
   is adding 6 checkouts with 6 bookings = 12 which is higher than 8
bookable items.
6) With this patch, check-outs that refer to an existing booking are
   excluded, so the check becomes if 8 - 6 > 0 (which passes the check) rather than 8 - 12 > 0 (which fails the check)

Run existing tests:
prove t/db_dependent/Koha/Item.t
prove t/db_dependent/Koha/Biblio.t
prove t/db_dependent/Koha/Booking.t
Comment 4 Pedro Amorim 2025-08-13 11:44:31 UTC
Adding Martin as QA here for when he's available.
Comment 5 Andrew Fuerste-Henry 2025-08-14 18:09:32 UTC
Created attachment 185417 [details] [review]
Bug 40644: Only count checkouts that have not yet been counted as bookings

Test plan:
1) Have a record with 8 items.
2) Place a booking on 6 of the items (6 bookings total) for a full month
   (e.g. August)
3) Check-out all 6 of those bookings
4) Attempt to place a new booking for one of the 2 free items for end of month, e.g. (Aug 26 -> Aug 28).
5) It will fail with error "Booking conflicts". This is because the code
   is adding 6 checkouts with 6 bookings = 12 which is higher than 8
bookable items.
6) With this patch, check-outs that refer to an existing booking are
   excluded, so the check becomes if 8 - 6 > 0 (which passes the check) rather than 8 - 12 > 0 (which fails the check)

Run existing tests:
prove t/db_dependent/Koha/Item.t
prove t/db_dependent/Koha/Biblio.t
prove t/db_dependent/Koha/Booking.t

Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>