From 6412b90bf9fd2c8b38ad1352f1722dd18ba66430 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 2 Jul 2025 20:17:39 +0000 Subject: [PATCH] Bug 40296: Mark booking as completed when issuing to booking patron This patch adds logic to automatically mark a patron's booking as 'completed' when they check out the item they have booked. When AddIssue is called, the system now: - Checks if there's a conflicting booking for the checkout period - Marks the booking status as 'completed' if found This ensures booking status accurately reflects when items are actually checked out to fulfill bookings. Test plan: 1. Enable bookings system preference 2. Create a bookable item (set bookable = 1 in items table or via item editor) 3. Create a booking for a patron for that item with start date = today, end date = 7 days from now 4. Go to circulation and check out the item to the same patron who made the booking 5. Check the booking status in the database or via the bookings interface 6. Verify the booking status has changed from 'new' to 'completed' 7. Confirm the checkout was successful and shows normally in patron's checkouts list Signed-off-by: Martin Renvoize --- C4/Circulation.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index bf93c32a590..60c8c209acc 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1766,6 +1766,17 @@ sub AddIssue { # In the case that the borrower has an on-site checkout # and SwitchOnSiteCheckouts is enabled this converts it to a regular checkout $issue = Koha::Checkouts->find( { itemnumber => $item_object->itemnumber } ); + + #if this checkout is a booking mark it as completed + if ( + my $booking = $item_object->find_booking( + { checkout_date => $issuedate, due_date => $datedue, patron_id => $patron->borrowernumber } + ) + ) + { + $booking->status('completed')->store; + } + if ($issue) { $issue->set($issue_attributes)->store; } else { @@ -1783,6 +1794,7 @@ sub AddIssue { ); } $issue->discard_changes; + $patron->update_lastseen('check_out'); if ( $item_object->location && $item_object->location eq 'CART' -- 2.50.0