From d5beec085c5a940dd679c608bc06b01d5433aaa5 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 6 May 2025 21:22:20 +0000 Subject: [PATCH] Bug 39820: Cancel holds with cancellation requests via SIP To test: 1. In circ rules set a Default waiting hold cancellation policy to allow hold cancellation requests. 2. Add a hold for a patron and create a hold cancellation request. 3. Check the item in via SIP, I used the SIP emulator: kohadevbox/koha/misc/sip_cli_emulator.pl -a localhost -p 6001 -l MPL -su term1 -sp term1 -m checkin --patron 23529000035676 --item 39999000001310 4. The hold remains. 5. APPLY PATCH, restart_all 6. Try 2 - 4 again, the hold should be cancelled --- C4/SIP/ILS/Transaction/Checkin.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm index f222401e4e7..516e141d576 100644 --- a/C4/SIP/ILS/Transaction/Checkin.pm +++ b/C4/SIP/ILS/Transaction/Checkin.pm @@ -91,6 +91,12 @@ sub do_checkin { my ( $return, $messages, $issue, $borrower ); my $item = Koha::Items->find( { barcode => $barcode } ); + if ($item) { + my $waiting_holds_to_be_cancelled = $item->holds->waiting->filter_by_has_cancellation_requests; + while ( my $hold = $waiting_holds_to_be_cancelled->next ) { + $hold->cancel; + } + } my $human_required = 0; if ( C4::Context->preference("CircConfirmItemParts") -- 2.39.5