From ab1de1606e4f3754d75c82c2f98193e5c7287ecd Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 10 Jan 2017 13:20:02 +0100 Subject: [PATCH] Bug 11999: Remove 'alreadyReserved' check in CanBookBeReserved Since bug 14695 it is possible to reserve more than one item per biblio Also fix bad use of $item --- C4/Reserves.pm | 11 ++--------- t/db_dependent/Holds.t | 4 ++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 0ed7882..963a7a9 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -428,15 +428,8 @@ See CanItemBeReserved() for possible return values. sub CanBookBeReserved{ my ($borrowernumber, $biblionumber) = @_; - # Check if borrower already has reserved the same biblio. - my @reserves = GetReservesFromBorrowernumber($borrowernumber); - foreach my $reserve (@reserves) { - if ($reserve->{biblionumber} == $biblionumber) { - return 'alreadyReserved'; - } - } - # Check if borrower has reached the maximum number of holds allowed + my @reserves = GetReservesFromBorrowernumber($borrowernumber); my $maxreserves = C4::Context->preference('maxreserves'); if ($maxreserves && scalar(@reserves) >= $maxreserves) { return 'tooManyReserves'; @@ -619,7 +612,7 @@ sub CanItemBeReserved { if ( C4::Context->preference('IndependentBranches') and !C4::Context->preference('canreservefromotherbranches') ) { - my $itembranch = $item->{homebranch}; + my $itembranch = $item->homebranch; if ( $itembranch ne $borrower->{branchcode} ) { return 'cannotReserveFromOtherBranches'; } diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index fe38f19..438bd8e 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -386,10 +386,10 @@ ok( "cannot request item if policy that matches on bib-level item type forbids it (bug 9532)" ); -is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'alreadyReserved'); +is(CanBookBeReserved($borrowernumbers[0], $bibnum), 'none_available'); C4::Context->set_preference('maxreserves', 1); -ok(CanBookBeReserved($borrowernumbers[0], $biblionumber) eq 'tooManyReserves'); +is(CanBookBeReserved($borrowernumbers[0], $biblionumber), 'tooManyReserves'); C4::Context->set_preference('maxreserves', 0); t::lib::Mocks::mock_preference('IndependentBranches', 1); -- 2.1.4