https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35937 --- Comment #8 from Jacob O'Mara <jacob.omara@openfifth.co.uk> --- Created attachment 212085 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212085&action=edit Bug 35937: Treat booking date ranges as half-open in clash checks This patch set adds bookings in hours. When the "Unit" circulation rule of an item type is "Hours", staff book the item for a start time and an end time on the booking modal. The booking period, the lead period and the trail period count in hours. Booking times must fall in the opening hours of the pickup library. Bookings in days work as before. All booking periods are now half-open: the end time is not part of the period. A booking that ends at 12:00 does not clash with a booking that starts at 12:00. Other changes: - The bookings table, the bookings timeline, the "Bookings to collect" page, the checkout page and the booking notices show the times of hourly bookings. - The booking modal marks the hours that are already booked. It does not offer start times that are too soon, or end times that are not after the start time. - On a record whose item types count in different units, the booking calendar waits until staff select an item type or an item. - The "Reducing due date to" field on the checkout page leaves the lead period of the next booking free. For a daily booking with no lead period, the item is due at 23:59 on the day before the booking. Before, the item was due at 00:00 on that day. - The booking pre-processing and post-processing periods count in the unit of the loan. The database update multiplies the existing values for hourly loans by 24, so each period keeps its length. - A new column, bookings.period_unit, records the unit of each booking. Test plan: Upgrade (optional, do this before you apply the patches): 1. Go to Administration > Circulation and fine rules. In the rules table at the top of the page, use the last row: select "All" for "Patron category" and "Computer Files" for "Item type". Set "Unit" to "Hours" and click "Save". 2. In the table "Default holds and bookings policies by item type", use the last row: select "Computer Files", set "Booking pre-processing (days)" to 2 and "Booking post-processing (days)" to 1, and click "Add". 3. Apply the patches and run updatedatabase. The update also runs the database updates of the bugs that this bug depends on. 4. Confirm that the update prints "Set 2 booking lead or trail period rules: periods for hourly loans now count in hours and keep their length". 5. Reload Administration > Circulation and fine rules. Confirm that the Computer Files row of "Default holds and bookings policies by item type" shows 48 and 24. 6. Confirm that the column headers now read "Booking pre-processing (days, or hours for hourly loans)" and "Booking post-processing (days, or hours for hourly loans)". Setup: 7. If you did not do the Upgrade section, apply the patches and run updatedatabase. 8. Run "yarn build". Then run restart_all. 9. Go to Administration > Item types. For "Books" and for "Computer Files", click "Edit", select "Bookable" and click "Save changes". 10. Go to Administration > Circulation and fine rules: - In the rules table at the top of the page, find the row for "All" patron categories and "Computer Files". If you did the Upgrade section, click "Edit" on that row. If the row does not exist, use the last row. Set "Loan period" to 4 and "Unit" to "Hours", and click "Save". - In "Default holds and bookings policies by item type", use the last row: select "Computer Files", set "Booking pre-processing (days, or hours for hourly loans)" to 1 and "Booking post-processing (days, or hours for hourly loans)" to 1, and click "Add". This replaces the values from the Upgrade section. 11. Go to Administration > Libraries. Click "Edit" for Centerville. The "Library hours:" table has the columns "Day", "Type", "Open time" and "Close time". For each of the 7 days, set "Open time" to 09:00 and "Close time" to 17:00. Click "Submit". 12. The sample data has no Computer Files items. Make two test records: - Record A: choose a record with one item. Click "Edit" > "Manage items". For the item, click "Actions" > "Edit". Set "y - Koha item type" to "Computer Files" and click "Save changes". - Record B: choose a record with two or more items. Change only one item to "Computer Files" in the same way. Keep the other items as "Books". For each item of both records, make sure that "Home library" and "Current library" are Centerville. Some sample records have items at other libraries. Hourly bookings: 13. Open record A and click "Place booking" in the toolbar. 14. Select a patron and the pickup location Centerville. The item type "Computer Files" fills in by itself. 15. Confirm that the "Booking constraints active:" box shows "Booking period limited to checkout length with renewals (4 hours)", "Lead period: 1 hour before start" and "Trail period: 1 hour after return". 16. Click a day in the future two times (the first click starts a range, the second click selects that one day). Confirm that "Start time" offers only 09:00 to 16:00 and "End time" offers only 10:00 to 17:00. - Select "Start time" 10:00. Confirm that "End time" now offers only 11:00 to 17:00. - Move the pointer over another day. Confirm that the message that shows says "Select a start date", not "Select an end date". 17. Select 10:00 to 12:00 and click "Place booking". Confirm the message "Booking successfully placed". 18. In the left menu of the record, click "Bookings (1)". Confirm that the booking shows "10:00" and "12:00" in "Start date" and "End date". 19. Place a second booking on record A for the same day: - Confirm that "Start time" shows "10:00 (booked)" and "11:00 (booked)" and that you cannot select them. - Select 12:00 to 14:00. Confirm the message "The selected times are too close to another booking or checkout". - Select 14:00 to 16:00 and click "Place booking". Confirm that the booking saves. 20. Open "Bookings (2)" again. Confirm that the timeline on that page uses an hour scale. If a booking is out of view, pan the timeline. Hover over a booking and confirm that it shows the patron and the times. 21. Place a booking on record A for today, before 15:00. Confirm that "Start time" does not offer times before one hour from now. Daily bookings (no change): 22. Open a record that has only Books items. Place a booking for a range of days. 23. Confirm that the modal shows only the date calendar and no time fields. 24. Confirm that the booking saves and shows dates without times. Mixed units: 25. Open record B. Click "Place booking". Select a patron and the pickup location Centerville. 26. Confirm the message "Select an item type or an item to see the booking calendar. The item types on this record are booked in different units (hours and days)." Confirm that the "Booking constraints active:" box does not show. 27. Select the item type "Computer Files". Confirm that the hourly calendar with "Start time" and "End time" shows. 28. Select the item type "Books". Confirm that the daily calendar shows. Checkout of a booked item: 29. On record A, book the item for today for 1 hour. Start at the first full hour that is 2 or more hours from now. The booking must end by 17:00, so do this step before 14:00. If the booking from step 21 is still on record A, cancel it first. 30. Check out the same item to another patron. 31. Confirm that the "Please confirm checkout" box shows "Due for another patron booking by:" with the booking start time. 32. Confirm that "Reducing due date to:" shows the booking start minus 1 hour. Click "Yes, check out (Y)". 33. Click "Show checkouts". Confirm that the item is due at that time. 34. On a record with only Books items, book an item for one day, 3 days from now. Check out the same item to another patron. 35. Confirm that "Reducing due date to:" shows the day before the booking. Click "Yes, check out (Y)". Other confirmations can show first, for example a debt from the Computer Files rental charge. 36. Click "Show checkouts". Confirm that the item is due on the day before the booking. Other pages: 37. Go to Circulation > Holds and bookings > Bookings to collect. The page shows bookings for the next 7 days only. Confirm that the hourly bookings show their times and that the daily bookings show dates only. 38. Open the patron of an hourly booking. Click "Notices" in the left menu. Open "A library booking was confirmed". Confirm that "Dates:" shows the times. Do the same for a daily booking and confirm that it shows dates only. Tests: 39. In ktd --shell, run: prove t/db_dependent/Koha/Booking.t t/db_dependent/Koha/Bookings.t t/db_dependent/Koha/Biblio.t t/db_dependent/Koha/Item.t t/db_dependent/Koha/Biblio/Availability/Booking.t t/db_dependent/Koha/CirculationRules.t t/db_dependent/Koha/Library/OpeningHours.t t/db_dependent/Circulation.t t/db_dependent/api/v1/bookings.t t/db_dependent/api/v1/biblios.t 40. Run the booking component tests: yarn cypress run --component --spec "t/cypress/component/Booking*_spec.ts,t/cypress/component/stores/*.ts,t/cypress/component/lib/booking/**/*.ts,t/cypress/component/useBookingCalendarMaps_spec.ts" 41. Remove the Computer Files rules from step 10 (the integration tests expect the default rules). Then run each booking integration test on its own: yarn cypress run --spec t/cypress/integration/Circulation/bookingsModalBasic_spec.ts yarn cypress run --spec t/cypress/integration/Circulation/bookingsModalDatePicker_spec.ts yarn cypress run --spec t/cypress/integration/Circulation/bookingsModalHourly_spec.ts yarn cypress run --spec t/cypress/integration/Circulation/bookingsModalTimezone_spec.ts Note: on a machine with little memory, a long Cypress run can crash the Electron renderer. Run fewer specs at a time if that happens. bookingsModalBasic_spec.ts uses Books and Computer Files items. With "Unit" = "Hours" for Computer Files, the modal correctly waits for an item type, so that spec fails. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.