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 <david@davidnind.com>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d5f130da5a)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
Pedro Amorim 2026-05-07 12:15:09 +00:00 committed by Jacob O'Mara
parent acab81737a
commit 108f7d56d2
No known key found for this signature in database
1 changed files with 3 additions and 2 deletions

View File

@ -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)