Bug 21478: Make Koha::Hold->suspend reject found holds

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 1d5934cae5)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 81c6172ee2)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2019-01-25 13:49:37 -03:00 committed by Lucas Gass
parent a4bca9e77c
commit a2bb202071
1 changed files with 19 additions and 5 deletions

View File

@ -34,6 +34,8 @@ use Koha::Libraries;
use Koha::Old::Holds;
use Koha::Calendar;
use Koha::Exceptions::Hold;
use base qw(Koha::Object);
=head1 NAME
@ -85,16 +87,28 @@ sub suspend_hold {
my $date = $dt ? $dt->clone()->truncate( to => 'day' )->datetime : undef;
if ( $self->is_waiting ) { # We can't suspend waiting holds
carp "Unable to suspend waiting hold!";
return $self;
if ( $self->is_found ) { # We can't suspend found holds
if ( $self->is_waiting ) {
Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'W' );
}
elsif ( $self->is_in_transit ) {
Koha::Exceptions::Hold::CannotSuspendFound->throw( status => 'T' );
}
else {
Koha::Exceptions::Hold::CannotSuspendFound->throw(
'Unhandled data exception on found hold (id='
. $self->id
. ', found='
. $self->found
. ')' );
}
}
$self->suspend(1);
$self->suspend_until( $date );
$self->suspend_until($date);
$self->store();
logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, Dumper($self->unblessed) )
logaction( 'HOLDS', 'SUSPEND', $self->reserve_id, Dumper( $self->unblessed ) )
if C4::Context->preference('HoldsLog');
return $self;