Bug 22456: (follow-up) Cancel holds at checkin

This patch makes checkin process the cancellation requested holds
actually cancel them before moving forward.

To test:
1. Have a waiting hold with a patron generated cancellation request
2. At circulation, check the item in
=> SUCCESS: The workflow follows as if the cancellation requested hold
was already cancelled
=> SUCCESS: The hold is actually cancelled
=> SUCCESS: Not shown in the OPAC anymore

Sponsored-by: Montgomery County Public Libraries

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomás Cohen Arazi 2022-05-27 10:38:29 -03:00
parent b3cdbb557d
commit 0e6f152077
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -346,6 +346,15 @@ if ($barcode) {
$template->param( 'confirm_items_bundle_returned' => 1 )
if $query->param('confirm_items_bundle_return');
# is there a waiting hold for the item, for which cancellation
# has been requested?
my $waiting_holds_to_be_cancelled =
Koha::Holds->waiting->search( { itemnumber => $item->id } )
->filter_by_has_cancellation_requests;
while ( my $hold = $waiting_holds_to_be_cancelled->next ) {
$hold->cancel;
}
# do the return
( $returned, $messages, $issue, $borrower ) =
AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date )