Bug 31086: Throw an exception when a hold is stored with no branchcode

To test:
1 - Apply first 2 patches
2 - On staff client, find a biblio, place hold, select a patron
3 - Before creating hold, right click on 'Pickup location'
4 - Inspect the element
5 - In the console find the top <li> for pickup, and right click
6 - Select 'Delete node'
7 - Save hold
8 - You get an exception/error

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e7d886d388)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2022-07-01 14:44:09 +00:00 committed by Lucas Gass
parent 4c2928f8f0
commit e03b542a18
2 changed files with 6 additions and 0 deletions

View File

@ -31,6 +31,10 @@ use Exception::Class (
'Koha::Exceptions::Hold::InvalidPickupLocation' => {
isa => 'Koha::Exceptions::Hold',
description => 'The supplied pickup location is not valid'
},
'Koha::Exceptions::Hold::MissingPickupLocation' => {
isa => 'Koha::Exceptions::Hold',
description => 'You must supply a pickup location when placing a hold'
}
);

View File

@ -713,6 +713,8 @@ expirationdate for holds.
sub store {
my ($self) = @_;
Koha::Exceptions::Hold::MissingPickupLocation->throw() unless $self->branchcode;
if ( !$self->in_storage ) {
if ( ! $self->expirationdate && $self->patron_expiration_date ) {
$self->expirationdate($self->patron_expiration_date);