From 03c3dac4ebea3e6f41816fe2f9d51a103a6f482e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 2 Dec 2021 14:27:21 +0000 Subject: [PATCH] Bug 29161: POC This is messy - our listing of holds only grabs the first, so we cannot tell whether we have both itemnumber and biblionumber holds. This patch removes the limit on priority one, then checks in get_items_that_can_fill for both item level and title level holds. I don't know how this affects the grouping for display We also only deal with one hold at a time on this report - if there are several title level holds, we only see it once, I guess fine, you fill that, run the report, fill the second Test plan below fails To test: 1 - Place an item level hold on a biblio with multiple items 2 - Run Holds to pull 3 - The hold shgows - okay 4 - Checkout the item with the hold to another patron 5 - The holds shows - not okay 6 - Apply patch 7 - The hold no longer shows 8 - Place a title level hold 9 - That hold shows --- Koha/Holds.pm | 5 +++-- circ/pendingreserves.pl | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Koha/Holds.pm b/Koha/Holds.pm index 6885b4d6bf..5918c1aead 100644 --- a/Koha/Holds.pm +++ b/Koha/Holds.pm @@ -111,7 +111,8 @@ Items that are not: sub get_items_that_can_fill { my ( $self ) = @_; - my @biblionumbers = $self->get_column('biblionumber'); + my @biblionumbers = $self->search({'reserve.itemnumber' => undef})->get_column('biblionumber'); + my @itemnumbers = $self->search({ -not => { 'reserve.itemnumber' => undef } })->get_column('itemnumber'); my @branchtransfers = map { $_->itemnumber } Koha::Item::Transfers->search( @@ -132,7 +133,7 @@ sub get_items_that_can_fill { return Koha::Items->search( { - biblionumber => { in => \@biblionumbers }, + -or => [ biblionumber => { in => \@biblionumbers }, 'me.itemnumber' => { in => \@itemnumbers } ], itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] }, onloan => undef, } diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 0b2fea2195..2ce882351e 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -156,7 +156,6 @@ unless ( $enddate ) { # building query parameters my %where = ( 'reserve.found' => undef, - 'reserve.priority' => 1, 'reserve.suspend' => 0, 'itembib.itemlost' => 0, 'itembib.withdrawn' => 0, @@ -188,8 +187,9 @@ if ( C4::Context->preference('IndependentBranches') ){ # get all distinct unfulfilled reserves my $holds = Koha::Holds->search( { %where }, - { join => 'itembib', alias => 'reserve', distinct => 1, columns => qw[me.biblionumber] } + { join => 'itembib', alias => 'reserve', distinct => 1, columns => [qw/ reserve.biblionumber reserve.itemnumber /] } ); + my @biblionumbers = $holds->get_column('biblionumber'); my $all_items; -- 2.20.1