Bug 24175: Take advantage of Koha::Item->holds

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2019-12-17 14:23:16 +01:00 committed by Martin Renvoize
parent 09aa99391f
commit d2bdccdb64
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 3 additions and 7 deletions

View File

@ -86,14 +86,10 @@ sub drop_hold {
$self->ok(0);
return $self;
}
my $item = Koha::Items->find({ barcode => $self->{item}->id });
my $holds = Koha::Holds->search(
{
biblionumber => $item->biblionumber,
itemnumber => $item->itemnumber,
borrowernumber => $patron->borrowernumber
}
);
my $holds = $item->holds->search({ borrowernumber => $patron->borrowernumber });
return $self unless $holds->count;
$holds->next->cancel;