From c1cd9cb74d14f5c3b8ad202b21e39f7ccab85de9 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Tue, 4 Aug 2020 14:54:11 +0200 Subject: [PATCH] Bug 22806: (QA follow-up) --- C4/Reserves.pm | 4 ++-- opac/opac-reserve.pl | 5 ----- reserve/request.pl | 14 ++++---------- t/db_dependent/ILSDI_Services.t | 2 +- t/db_dependent/Reserves.t | 4 ++-- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 8ed7bafd82..53112d5b2f 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -314,7 +314,7 @@ sub CanBookBeReserved{ # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') && C4::Circulation::CheckIfIssuedToPatron( $borrowernumber, $biblionumber ) ) { - return { status =>'itemAlreadyOnLoan' }; + return { status =>'alreadypossession' }; } my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); @@ -384,7 +384,7 @@ sub CanItemBeReserved { # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') && C4::Circulation::CheckIfIssuedToPatron( $patron->borrowernumber, $biblio->biblionumber ) ) { - return { status =>'itemAlreadyOnLoan' }; + return { status =>'alreadypossession' }; } my $controlbranch = C4::Context->preference('ReservesControlBranch'); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 2a11ad48e5..f58684fefe 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -602,11 +602,6 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{holdable} = undef; $biblioLoopIter{itemholdable} = undef; } - if(not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowernumber,$biblioNum)) { - $biblioLoopIter{holdable} = undef; - $biblioLoopIter{already_patron_possession} = 1; - } - if ( $biblioLoopIter{holdable} ) { @not_available_at = uniq @not_available_at; $biblioLoopIter{not_available_at} = \@not_available_at ; diff --git a/reserve/request.pl b/reserve/request.pl index 26e40dd685..6e36856726 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -314,6 +314,10 @@ foreach my $biblionumber (@biblionumbers) { $template->param( $canReserve->{status} => 1 ); $biblioloopiter{ $canReserve->{status} } = 1; } + elsif ( $canReserve->{status} eq 'alreadypossession' ) { + $template->param( $canReserve->{status} => 1); + $biblioloopiter{ $canReserve->{status} } = 1; + } else { $biblioloopiter{ $canReserve->{status} } = 1; } @@ -342,16 +346,6 @@ foreach my $biblionumber (@biblionumbers) { $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record; $template->param( max_holds_for_record => $max_holds_for_record ); $template->param( remaining_holds_for_record => $remaining_holds_for_record ); - - { # alreadypossession - # Check to see if patron is allowed to place holds on records where the - # patron already has an item from that record checked out - if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') - && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) ) - { - $template->param( alreadypossession => 1, ); - } - } } diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index 090701ee44..e958caef00 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -462,7 +462,7 @@ subtest 'Holds test' => sub { $query->param( 'item_id', $item3->{itemnumber}); $reply = C4::ILSDI::Services::HoldItem( $query ); - is( $reply->{code}, 'itemAlreadyOnLoan', "Patron has issued same book" ); + is( $reply->{code}, 'alreadypossession', "Patron has issued same book" ); is( $reply->{pickup_location}, undef, "No reserve placed"); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 2059ba9ea9..11ae8cb499 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -1052,12 +1052,12 @@ subtest 'AllowHoldOnPatronPossession test' => sub { is(C4::Reserves::CanBookBeReserved($patron->borrowernumber, $item->biblionumber)->{status}, - 'itemAlreadyOnLoan', + 'alreadypossession', 'Patron cannot place hold on a book loaned to itself'); is(C4::Reserves::CanItemBeReserved($patron->borrowernumber, $item->itemnumber)->{status}, - 'itemAlreadyOnLoan', + 'alreadypossession', 'Patron cannot place hold on an item loaned to itself'); t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 1); -- 2.20.1