From 2581fc0afd011900aa97845664786e577680186d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Fri, 5 Mar 2021 13:08:03 +0200 Subject: [PATCH] Bug 27879: Don't allow set holds to be waiting if not at pickup location If the item is not at pickup location when setting the hold to be waiting it would be clearly error because then the status should be in transit instead. --- Koha/Exceptions/Hold.pm | 4 ++++ Koha/Hold.pm | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Koha/Exceptions/Hold.pm b/Koha/Exceptions/Hold.pm index 65d7b9d9a9..4ba3beedc3 100644 --- a/Koha/Exceptions/Hold.pm +++ b/Koha/Exceptions/Hold.pm @@ -32,6 +32,10 @@ use Exception::Class ( isa => 'Koha::Exceptions::Hold', description => 'The supplied pickup location is not valid' } + 'Koha::Exceptions::Hold::NotAtPickupLocation' => { + isa => 'Koha::Exceptions::Hold', + description => "Hold can't be set waiting for an item that is not at pickup location" + } ); sub full_message { diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 892fb20cd5..3d14f2b2a6 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -178,6 +178,10 @@ sub set_transfer { sub set_waiting { my ( $self, $desk_id ) = @_; + if ($self->item->holdingbranch ne $self->branchcode) { + Koha::Exceptions::Hold::NotAtPickupLocation->throw; + } + $self->priority(0); my $today = dt_from_string(); -- 2.17.1