Bug 35357: Remove item from holds queue when it is checked out

Test Plan:
1) Place a hold on an item
2) Build the holds queue
3) Check out the item to a different patron than the one
   targeted in the holds queue
4) Verify the holds queue viewer still shows that item and patron
5) Apply this patch
6) Repeat stepts 1 through 3
7) Verify the holds queue viewer no longer shows that patron and item!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Kyle Hall 2024-01-11 09:31:45 -05:00 committed by Katrin Fischer
parent 0e11bc0de5
commit 0eced80866
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 15 additions and 4 deletions

View file

@ -1729,6 +1729,12 @@ sub AddIssue {
%$issue_attributes,
}
)->store;
# Ensure item is no longer listed in the holds queue
$dbh->do(
q{DELETE tmp_holdsqueue, hold_fill_targets FROM tmp_holdsqueue LEFT JOIN hold_fill_targets USING ( itemnumber ) WHERE itemnumber = ?},
undef, $item_object->id
);
}
$issue->discard_changes;
$patron->update_lastseen('check_out');

View file

@ -2114,8 +2114,7 @@ subtest 'Remove item from holds queue on checkout' => sub {
}
);
my $item = $builder->build_sample_item(
{ homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } );
my $item = $builder->build_sample_item( { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } );
t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } );
@ -2131,11 +2130,17 @@ subtest 'Remove item from holds queue on checkout' => sub {
C4::HoldsQueue::CreateQueue();
is( Koha::Hold::HoldsQueueItems->search({ itemnumber => $item->id })->count(), 1, "Item is found in the holds queue" );
is(
Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->count(), 1,
"Item is found in the holds queue"
);
AddIssue( $patron1, $item->barcode, dt_from_string );
is( Koha::Hold::HoldsQueueItems->search({ itemnumber => $item->id })->count(), 0, "Item is no longer found in the holds queue" );
is(
Koha::Hold::HoldsQueueItems->search( { itemnumber => $item->id } )->count(), 0,
"Item is no longer found in the holds queue"
);
$schema->storage->txn_rollback;
};