Bug 38650: Only fill title level holds, or holds on the exact item

We change the conditions for filling holds to require that either:
- the hold is title level
- the hold is on the exact item

To test:
 1 - Place a hold for patron A on item #1 of a record
 2 - Place a hold for patron B on item #2 of a record
 3 - Issue item #2 to patron A - their hold on item #1 is filled incorrectly, check the item in
 4 - Apply patch, restart all
 5 - Place hold for patron A on item #1
 6 - Issue item #2 to patron A - their hold on item #1 is not filled, check the item in
 7 - Cancel that hold
 8 - Place a title level hold for the record for patron A
 9 - Check item #1 in at a different branch and confirm transfer
 9 - Issue item #2 to patron A
10 - The hold is filled as title level, even though item #1 was selected for the hold, check the item in
11 - Place an item level hold for item #2 for patron A
12 - Issue item #2 to patron A, hold is filled

Signed-off-by: Stephanie Petruso <spetruso@aacpl.net>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2024-12-09 20:23:11 +00:00 committed by Katrin Fischer
parent 5cdfea2d5f
commit 1df229719c
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 10 additions and 6 deletions

View File

@ -2021,23 +2021,27 @@ sub MoveReserve {
my $lookahead = C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds
my $item = Koha::Items->find($itemnumber);
my ( $restype, $res, undef ) = CheckReserves( $item, $lookahead );
return unless $res;
my $biblionumber = $res->{biblionumber};
if ( $res->{borrowernumber} == $borrowernumber ) {
if ( $res && $res->{borrowernumber} == $borrowernumber ) {
my $hold = Koha::Holds->find( $res->{reserve_id} );
$hold->fill( { item_id => $itemnumber } );
} else {
# warn "Reserved";
# The item is reserved by someone else.
# Find this item in the reserves
my $lookahead_date = output_pref(
{
dt => dt_from_string->add_duration( DateTime::Duration->new( days => $lookahead ) ),
dateformat => 'iso', dateonly => 1
}
);
my $borr_res = Koha::Holds->search(
{
borrowernumber => $borrowernumber,
biblionumber => $biblionumber,
biblionumber => $item->biblionumber,
reservedate => { '<=' => $lookahead_date },
-or => [ item_level_hold => 0, itemnumber => $itemnumber ],
},
{ order_by => 'priority' }
)->next();