From 342b27c3a40d68b7ecb129751b7de794acee2521 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 Signed-off-by: Paul Derscheid Signed-off-by: Lucas Gass (cherry picked from commit a8fd9734c6e6e2d11345cc1ea8bc8e00393322ec) Signed-off-by: Paul Derscheid (cherry picked from commit aeb86483261ef001d1f2e14a77e8ebfef3af715f) Signed-off-by: Fridolin Somers --- C4/Circulation.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 2e45a82735..072104b99c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1719,6 +1719,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; }