@@ -, +, @@ limiting items --- Koha/Holds.pm | 2 +- t/db_dependent/Koha/Holds.t | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) --- a/Koha/Holds.pm +++ a/Koha/Holds.pm @@ -116,7 +116,7 @@ sub get_items_that_can_fill { my @biblionumbers = $self->search({ 'me.itemnumber' => undef })->get_column('biblionumber'); my @bibs_or_items; push @bibs_or_items, 'me.itemnumber' => { in => \@itemnumbers } if @itemnumbers; - push @bibs_or_items, 'biblionumber' => { in => \@biblionumbers } if @biblionumbers; + push @bibs_or_items, 'me.biblionumber' => { in => \@biblionumbers } if @biblionumbers; my @branchtransfers = map { $_->itemnumber } Koha::Item::Transfers->search( --- a/t/db_dependent/Koha/Holds.t +++ a/t/db_dependent/Koha/Holds.t @@ -410,7 +410,7 @@ subtest 'Desks' => sub { }; subtest 'get_items_that_can_fill' => sub { - plan tests => 3; + plan tests => 4; my $biblio = $builder->build_sample_biblio; my $itype_1 = $builder->build_object({ class => 'Koha::ItemTypes' }); # For 1, 2, 3, 4 @@ -502,6 +502,19 @@ subtest 'get_items_that_can_fill' => sub { is_deeply( [ map { $_->itemnumber } $items->as_list ], [ $item_2->itemnumber ], 'Only item 2 is available for filling the hold' ); + + my $noloan_itype = $builder->build_object( { class => 'Koha::ItemTypes', value => { notforloan => 1 } } ); + t::lib::Mocks::mock_preference( 'item-level_itypes', 0 ); + Koha::Holds->find( $waiting_reserve_id )->delete; + $holds = Koha::Holds->search( + { + reserve_id => [ $reserve_id_1, $reserve_id_2 ] + } + ); + $items = $holds->get_items_that_can_fill; + is_deeply( [ sort map { $_->itemnumber } $items->as_list ], + [ $item_1->itemnumber, $item_2->itemnumber, $item_5->itemnumber ], 'Items 1, 2, and 5 are available for filling the holds' ); + }; $schema->storage->txn_rollback; --