@@ -, +, @@ maxreserves $ kshell k$ prove t/db_dependent/api/v1/holds.t --- Koha/REST/V1/Holds.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/Koha/REST/V1/Holds.pm +++ a/Koha/REST/V1/Holds.pm @@ -138,11 +138,23 @@ sub add { ); } + my $patron = Koha::Patrons->find( $patron_id ); + unless ($patron) { + return $c->render( + status => 400, + openapi => { error => 'patron_id not found' } + ); + } + my $can_place_hold = $item_id ? C4::Reserves::CanItemBeReserved( $patron_id, $item_id ) : C4::Reserves::CanBookBeReserved( $patron_id, $biblio_id ); + if ( $patron->holds->count + 1 > C4::Context->preference('maxreserves') ) { + $can_place_hold->{status} = 'tooManyReserves'; + } + my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); unless ($can_override || $can_place_hold->{status} eq 'OK' ) { --