From a407a7ce7eb90f2940a77c59427152e4b6562336 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Wed, 20 Feb 2019 21:15:44 +0100 Subject: [PATCH] Bug 22379 : Fix checks not made by ILS-DI method CancelHold Disable the possibility for a borrower to cancel a reservation which is either in a Transit or Waiting state. This reproduce the behaviour seen on the OPAC. Also replaces previous checks on the borrowernumber since CanReserveBeCanceledFromOpac already checks this. --- C4/ILSDI/Services.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 1ffdc14419..afe3ca772e 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -25,7 +25,7 @@ use C4::Items; use C4::Circulation; use C4::Accounts; use C4::Biblio; -use C4::Reserves qw(AddReserve CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest); +use C4::Reserves qw(AddReserve CanBookBeReserved CanItemBeReserved IsAvailableForItemLevelRequest CanReserveBeCanceledFromOpac); use C4::Context; use C4::AuthoritiesMarc; use XML::Simple; @@ -806,7 +806,9 @@ sub CancelHold { my $reserve_id = $cgi->param('item_id'); my $hold = Koha::Holds->find( $reserve_id ); return { code => 'RecordNotFound' } unless $hold; - return { code => 'RecordNotFound' } unless ($hold->borrowernumber == $borrowernumber); + + # Check if reserve belongs to the borrower and if it is in a state which allows cancellation + return { code => 'BorrowerCannotCancelHold' } unless CanReserveBeCanceledFromOpac( $reserve_id, $borrowernumber ); $hold->cancel; -- 2.13.7