Bug 40435: Module changes

CanBookBeRenewed will by default pass the skip_future_holds flag
to item->current_holds so that renewals are not blocked by future
holds.
The new pref FutureHoldsBlockRenewals allows you to change that
historical behavior.

Test plan:
[1] Set pref ConfirmFutureHolds=3, FutureHoldsBlockRenewals=Allow,
    OPACAllowHoldDateInFuture=Allow
[2] Checkout some item to patron A.
[3] Place hold on same item for patron B, reserve date tomorrow.
[4] Try to renew item with patron A on account page. Should be
    marked as Not renewable.
[5] Set pref FutureHoldsBlockRenewals=Dont
[6] Repeat step 4. Renew should be allowed.
[7] prove t/db_dependent/Holds.t t/db_dependent/Reserves.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2025-12-11 14:08:00 +01:00 committed by Lucas Gass
parent 87c143b4c2
commit 71b439d855
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 8 additions and 3 deletions

View File

@ -3269,9 +3269,11 @@ sub CanBookBeRenewed {
}
# There is an item level hold on this item, no other item can fill the hold
# The flag skip_future_holds may be removed in the future. See bug 40435.
# The flag skip_future_holds is set when preference FutureHoldsBlockRenewals is not set (default).
# (Historically, Koha does not block renewals for future holds. Could be argued.)
my $skip = C4::Context->preference('FutureHoldsBlockRenewals') ? 0 : 1;
return ( 0, "on_reserve" )
if ( $item->current_holds( { skip_future_holds => 1 } )->search( { non_priority => 0 } )->count );
if ( $item->current_holds( { skip_future_holds => $skip } )->search( { non_priority => 0 } )->count );
my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
my @fillable_holds = ();

View File

@ -1181,7 +1181,10 @@ sub article_request_type {
my $holds = $item->current_holds
Return the holds placed on this item.
Respects the lookahead days in ConfirmFutureHolds pref.
Respects the lookahead days in preference ConfirmFutureHolds when the
param skip_future_holds is not set.
Note that the preference FutureHoldsBlockRenewals controls that setting
for renewals; see also C4::Circulation::CanBookBeRenewed.
=cut