@@ -, +, @@ one hold priority priority --- C4/Circulation.pm | 9 +++- installer/data/mysql/atomicupdate/bug_22789.perl | 3 ++ .../intranet-tmpl/prog/en/includes/holds_table.inc | 57 ++++++++++++++-------- .../prog/en/modules/reserve/request.tt | 3 +- reserve/request.pl | 1 + t/db_dependent/Holds.t | 26 +++++++++- 6 files changed, 75 insertions(+), 24 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -2761,7 +2761,14 @@ sub CanBookBeRenewed { my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber); - $resfound = 0 if $resrec->{non_priority}; + # If next hold is non priority, then check if any hold with priority (non_priority = 0) exists for the same biblionumber. + if ( $resfound && $resrec->{non_priority} ) { + $resfound = Koha::Holds->search( + { biblionumber => $resrec->{biblionumber}, non_priority => 0 } ) + ->count > 0; + } + + # This item can fill one or more unfilled reserve, can those unfilled reserves # all be filled by other available items? --- a/installer/data/mysql/atomicupdate/bug_22789.perl +++ a/installer/data/mysql/atomicupdate/bug_22789.perl @@ -6,6 +6,9 @@ if( CheckVersion( $DBversion ) ) { # or perform some test and warn if( !column_exists( 'reserves', 'non_priority' ) ) { $dbh->do("ALTER TABLE reserves ADD COLUMN `non_priority` tinyint(1) NOT NULL DEFAULT 0 AFTER `item_level_hold` -- Is this a non priority hold"); + } + + if( !column_exists( 'old_reserves', 'non_priority' ) ) { $dbh->do("ALTER TABLE old_reserves ADD COLUMN `non_priority` tinyint(1) NOT NULL DEFAULT 0 AFTER `item_level_hold` -- Is this a non priority hold"); } --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -140,38 +140,53 @@ + [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -477,9 +477,10 @@ [% END %] [% END # /UNLESS multi_hold %] -
  • +
  • +
    A non priority hold doesn't prevent a current checkout from renewing
  • --- a/reserve/request.pl +++ a/reserve/request.pl @@ -705,6 +705,7 @@ foreach my $biblionumber (@biblionumbers) { $reserve{'reserve_id'} = $res->reserve_id(); $reserve{itemtype} = $res->itemtype(); $reserve{branchcode} = $res->branchcode(); + $reserve{non_priority} = $res->non_priority(); $reserve{object} = $res; push( @reserveloop, \%reserve ); --- a/t/db_dependent/Holds.t +++ a/t/db_dependent/Holds.t @@ -1256,7 +1256,7 @@ subtest 'CanItemBeReserved / pickup_not_in_hold_group' => sub { subtest 'non priority holds' => sub { - plan tests => 4; + plan tests => 6; $schema->storage->txn_begin; @@ -1323,6 +1323,30 @@ subtest 'non priority holds' => sub { ok( $ok, 'Can renew' ); is( $err, undef, 'Item is on non priority hold' ); + my $patron3 = $builder->build_object( + { + class => 'Koha::Patrons', + value => { branchcode => $item->homebranch } + } + ); + + # Add second hold with non_priority = 0 + AddReserve( + { + branchcode => $item->homebranch, + borrowernumber => $patron3->borrowernumber, + biblionumber => $item->biblionumber, + priority => 2, + itemnumber => $item->itemnumber, + } + ); + + ( $ok, $err ) = + CanBookBeRenewed( $patron1->borrowernumber, $item->itemnumber ); + + ok( !$ok, 'Cannot renew' ); + is( $err, 'on_reserve', 'Item is on hold' ); + $schema->storage->txn_rollback; }; --