From 6a49c8a1b0fa18d5941d7786a1fadb25581c00d7 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Tue, 22 Mar 2022 14:14:52 -0400 Subject: [PATCH] Bug 30337: Holds to Pull ( pendingreserves.pl ) ignores holds if priority 1 hold is suspended Holds to Pull ( pendingreserves.pl ) ignores holds if priority 1 hold is suspended, and shows the wrong number of "patrons with holds" which presumably tells the librarian how many copies to pull from the shelves. Test Plan: 1) Create a record with one or more holdable items 2) Place two holds on the record 3) Note they show in the holds to pull report 4) Suspend the priority 2 hold 5) Note the report continues showing that 2 patrons have holds 6) Resume the priority 2 hold 7) Suspend the priority 1 hold 8) Note the hold disappears from the holds to pull report 9) Apply this patch 10) Restart all the things! 11) Reload the holds to pull report 12) The report should show one hold that needs an item pulled to fill it! Signed-off-by: David Nind Signed-off-by: Caroline Cyr La Rose Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit e536229292617e2f6e5bade47e3fbad1a0101ea4) Signed-off-by: Lucas Gass --- circ/pendingreserves.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 85bcffeb2d..1f853554b5 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -156,7 +156,7 @@ unless ( $enddate ) { # building query parameters my %where = ( 'me.found' => undef, - 'me.priority' => 1, + 'me.priority' => { '!=' => 0 }, 'me.suspend' => 0, 'itembib.itemlost' => 0, 'itembib.withdrawn' => 0, @@ -188,7 +188,7 @@ if ( C4::Context->preference('IndependentBranches') ){ # get all distinct unfulfilled reserves my $holds = Koha::Holds->search( { %where }, - { join => 'itembib', distinct => 1, columns => qw[me.biblionumber] } + { join => 'itembib', distinct => 1, columns => qw[me.biblionumber] } ); my @biblionumbers = $holds->get_column('biblionumber'); @@ -202,7 +202,7 @@ if ( $holds->count ) { # patrons count per biblio my $patrons_count = { map { $_->{biblionumber} => $_->{patrons_count} } @{ Koha::Holds->search( - {}, + { 'suspend' => 0 }, { select => [ 'biblionumber', { count => { distinct => 'borrowernumber' } } ], as => [qw( biblionumber patrons_count )], @@ -235,7 +235,11 @@ my $all_holds = { # make final holds_info array and fill with info my @holds_info; +my $seen = {}; foreach my $bibnum ( @biblionumbers ){ + # Skip this record if it's already been handled + next if $seen->{$bibnum}; + $seen->{$bibnum} = 1; my $hold_info; my $items = $all_items->{$bibnum}; -- 2.39.5