From 108f7d56d2e431e25f2699c135aa87f3cbd69778 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 7 May 2026 12:15:09 +0000 Subject: [PATCH] Bug 42255: Holds allowed (total) Make 'Holds allowed (total)' (aka reservesallowed) consider each hold group as an individual hold Test plan: 1) Enable DisplayAddHoldGroups sys pref 2) Set Holds allowed (total) to 2, visit: http://localhost:8081/cgi-bin/koha/admin/smart-rules.pl 3) Scroll to the right, click the 'Edit' button under 'Actions' column. 4) On the 'Holds allowed (total)' column cell, enter '2' and click 'Save' under the 'Actions' column to the right. 5) Search for 'test': http://localhost:8081/cgi-bin/koha/catalogue/search.pl?q=test 6) Tick the checkbox next the first and second results, click 'Place hold' button at the top toolbar 7) Search for 'koha' user and pick Koha (42) 8) Set a pickup location for each hold and tick the 'Treat as hold group' checkbox. Click 'Place holds'. 9) Try to place another single hold for the same patron. Should succeed, because the 2 grouped holds count as 1. Patron now should have 1 group + 1 ungrouped hold = effective count of 2. 10) Try to place yet another hold, should be blocked with a tooManyHolds error. 11) Prior to this patch, step 9 would've failed because the 2 grouped holds counted as 2. Signed-off-by: David Nind Signed-off-by: Andrew Fuerste Henry Signed-off-by: Lucas Gass (cherry picked from commit d5f130da5a9881e36dc6004811fa1e897c613e4f) Signed-off-by: Jacob O'Mara --- C4/Reserves.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 0ea42559c9..d04005a871 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -631,9 +631,10 @@ sub CanItemBeReserved { } if ( !$params->{ignore_hold_counts} ) { - # we retrieve count + # we retrieve count, treating each hold group as a single unit my $querycount = q{ - SELECT count(*) AS count + SELECT COUNT( CASE WHEN reserves . hold_group_id IS NULL THEN 1 END ) + + COUNT( DISTINCT reserves.hold_group_id ) AS count FROM reserves LEFT JOIN items USING (itemnumber) LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber)