Bug 30085: Move IndependentBranches check sooner

This doesn't rely on the other statuses, and requires only cached
preference check, so lets allow the possibiliy of an early exit

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Nick Clemens 2022-02-11 19:56:42 +00:00 committed by Fridolin Somers
parent f44e797c76
commit e221bc52a0

View file

@ -385,6 +385,16 @@ sub CanItemBeReserved {
my $ruleitemtype; # itemtype of the matching issuing rule
my $allowedreserves = 0; # Total number of holds allowed across all records, default to none
# We check item branch if IndependentBranches is ON
# and canreservefromotherbranches is OFF
if ( C4::Context->preference('IndependentBranches')
and !C4::Context->preference('canreservefromotherbranches') )
{
if ( $item->homebranch ne $patron->branchcode ) {
return { status => 'cannotReserveFromOtherBranches' };
}
}
# we retrieve borrowers and items informations #
# item->{itype} will come for biblioitems if necessery
my $biblio = $item->biblio;
@ -554,16 +564,6 @@ sub CanItemBeReserved {
}
}
# If reservecount is ok, we check item branch if IndependentBranches is ON
# and canreservefromotherbranches is OFF
if ( C4::Context->preference('IndependentBranches')
and !C4::Context->preference('canreservefromotherbranches') )
{
if ( $item->homebranch ne $patron->branchcode ) {
return { status => 'cannotReserveFromOtherBranches' };
}
}
if ($pickup_branchcode) {
my $destination = Koha::Libraries->find({
branchcode => $pickup_branchcode,