https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42383 --- Comment #102 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 209762 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209762&action=edit Bug 42383: Do not set a hold aside for an item checked out in the meantime Bug 43803 made ModReserveAffect return 0 and leave the hold untouched when the item has been checked out again while the hold confirmation was pending (e.g. from another workstation). The legacy returns.pl displayed a warning and skipped the transfer in that case, but Koha::Checkin->confirm_hold ignored the return value: it created and sent a transfer to the pickup library for an item that is on loan, and the hold_confirmation endpoint reported success. This patch makes Koha::Checkin->confirm_hold throw the new Koha::Exceptions::Checkin::ItemCheckedOut exception (before any transfer is created) when ModReserveAffect refuses the hold, and makes POST /checkins/{checkin_id}/hold_confirmation return 409 with the 'item_checked_out' error code. The check-in page shows the error and keeps the hold pending. Test plan: 1. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Checkin.t \ t/db_dependent/api/v1/checkins.t => SUCCESS: Tests pass! 2. Make sure HoldsAutoFill is disabled 3. Place an item-level hold on an item checked out to patron A (hold for patron B, pickup at a different library) 4. Go to Circulation > Check in, check in the item => SUCCESS: The "Hold found" modal appears. Leave it open 5. From another tab, check out the item to patron C, confirming the checkout without cancelling the hold 6. Back on the first tab, click "Confirm hold" => SUCCESS: An error is displayed: "The item has been checked out in the meantime: the hold has not been set aside and remains pending" => SUCCESS: The hold is still pending and no transfer was created 7. Check the item in again and confirm the hold => SUCCESS: The hold is set in transit to the pickup library 8. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.