Bugzilla – Attachment 185417 Details for
Bug 40644
Bookings biblio checks erroneously if multiple check-outs and bookings exist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40644: Only count checkouts that have not yet been counted as bookings
Bug-40644-Only-count-checkouts-that-have-not-yet-b.patch (text/plain), 1.92 KB, created by
Andrew Fuerste-Henry
on 2025-08-14 18:09:32 UTC
(
hide
)
Description:
Bug 40644: Only count checkouts that have not yet been counted as bookings
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2025-08-14 18:09:32 UTC
Size:
1.92 KB
patch
obsolete
>From 47467743a9e869b87145bc79c8b5ad6e95483e62 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Wed, 13 Aug 2025 11:28:41 +0000 >Subject: [PATCH] Bug 40644: Only count checkouts that have not yet been > counted as bookings > >Test plan: >1) Have a record with 8 items. >2) Place a booking on 6 of the items (6 bookings total) for a full month > (e.g. August) >3) Check-out all 6 of those bookings >4) Attempt to place a new booking for one of the 2 free items for end of month, e.g. (Aug 26 -> Aug 28). >5) It will fail with error "Booking conflicts". This is because the code > is adding 6 checkouts with 6 bookings = 12 which is higher than 8 >bookable items. >6) With this patch, check-outs that refer to an existing booking are > excluded, so the check becomes if 8 - 6 > 0 (which passes the check) rather than 8 - 12 > 0 (which fails the check) > >Run existing tests: >prove t/db_dependent/Koha/Item.t >prove t/db_dependent/Koha/Biblio.t >prove t/db_dependent/Koha/Booking.t > >Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> >--- > Koha/Biblio.pm | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 4c88bcd8a58..3ab87b9ea85 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -394,7 +394,12 @@ sub check_booking { > ? $existing_bookings->search( { booking_id => { '!=' => $booking_id } } )->count > : $existing_bookings->count; > >- my $checkouts = $self->current_checkouts->search( { date_due => { '>=' => $dtf->format_datetime($start_date) } } ); >+ my $checkouts = $self->current_checkouts->search( >+ { >+ date_due => { '>=' => $dtf->format_datetime($start_date) }, >+ "me.itemnumber" => { '-not_in' => $existing_bookings->_resultset->get_column('item_id')->as_query } >+ } >+ ); > $booked_count += $checkouts->count; > > return ( ( $total_bookable - $booked_count ) > 0 ) ? 1 : 0; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40644
:
185358
|
185359
|
185360
| 185417