Bug 34440 - Add warm-up and cool-down periods to bookings
Summary: Add warm-up and cool-down periods to bookings
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Paul Derscheid
URL:
Keywords:
: 35670 (view as bug list)
Depends on: 36120 36641 35944
Blocks: 37354 37363 37477 37707 38287 38308 38016
  Show dependency treegraph
 
Reported: 2023-07-28 11:24 UTC by Martin Renvoize (ashimema)
Modified: 2024-11-15 20:34 UTC (History)
12 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement to the recently added bookings functionality allows libraries to define a lead-in and trail-out period to be prepended and appended to bookings. These periods prevent checkouts or bookings from taking place too close to each other and allow for things like transfers and maintenance to be carried out.
Version(s) released in:
24.11.00
Circulation function: bookings


Attachments
Bug 34440: Add lead and trail time to circulation rules (18.86 KB, patch)
2024-06-21 11:26 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Take preparation period into account at checkout (3.24 KB, patch)
2024-06-21 11:26 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add itemtype selection to bookings modal (9.30 KB, patch)
2024-06-21 11:26 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add handling for lead/trail display (7.34 KB, patch)
2024-06-21 11:26 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add isSameOrBefore dayjs plugin (1.04 KB, patch)
2024-06-21 11:26 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Simplify modal code using isSameOr* functions (14.88 KB, patch)
2024-06-21 11:26 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Use circulation_rules for buffer timing (5.82 KB, patch)
2024-06-21 11:27 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: (TEMP) Comment 'rules' param (1.21 KB, patch)
2024-06-21 11:27 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add lead and trail time to circulation rules (18.86 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Take preparation period into account at checkout (3.24 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add itemtype selection to bookings modal (9.31 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add handling for lead/trail display (7.34 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add isSameOrBefore dayjs plugin (1.04 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Simplify modal code using isSameOr* functions (14.88 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Use circulation_rules for buffer timing (5.82 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: (TEMP) Comment 'rules' param (1.21 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Update for change to /circulation_rules (1.89 KB, patch)
2024-07-14 05:48 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add lead and trail time to circulation rules (18.86 KB, patch)
2024-07-15 15:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Take preparation period into account at checkout (3.24 KB, patch)
2024-07-15 15:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add itemtype selection to bookings modal (9.31 KB, patch)
2024-07-15 15:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add handling for lead/trail display (7.34 KB, patch)
2024-07-15 15:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add isSameOrBefore dayjs plugin (1.04 KB, patch)
2024-07-15 15:38 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Simplify modal code using isSameOr* functions (14.88 KB, patch)
2024-07-15 15:38 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Use circulation_rules for buffer timing (5.82 KB, patch)
2024-07-15 15:38 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Update for change to /circulation_rules (1.89 KB, patch)
2024-07-15 15:38 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: (follow-up) Enable flatpickr only once rules are populated (3.24 KB, patch)
2024-07-15 15:38 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Highlight overlaping lead and trail periods (1.77 KB, patch)
2024-07-15 15:38 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add lead and trail time to circulation rules (18.86 KB, patch)
2024-07-25 15:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Take preparation period into account at checkout (3.24 KB, patch)
2024-07-25 15:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add itemtype selection to bookings modal (9.31 KB, patch)
2024-07-25 15:43 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add handling for lead/trail display (7.34 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add isSameOrBefore dayjs plugin (1.04 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Simplify modal code using isSameOr* functions (14.88 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Use circulation_rules for buffer timing (5.82 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Update for change to /circulation_rules (1.89 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: (follow-up) Enable flatpickr only once rules are populated (3.24 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Highlight overlaping lead and trail periods (1.77 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Enforce lead/trail restrictions (6.50 KB, patch)
2024-07-25 15:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Enforce lead/trail restrictions (6.13 KB, patch)
2024-07-25 16:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Enforce lead/trail restrictions (5.82 KB, patch)
2024-07-25 16:09 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add lead and trail time to circulation rules (18.86 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Take preparation period into account at checkout (3.24 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add itemtype selection to bookings modal (9.31 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add handling for lead/trail display (7.34 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add isSameOrBefore dayjs plugin (1.04 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Simplify modal code using isSameOr* functions (14.88 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Use circulation_rules for buffer timing (5.82 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Update for change to /circulation_rules (1.89 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: (follow-up) Enable flatpickr only once rules are populated (3.24 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Highlight overlaping lead and trail periods (1.77 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Enforce lead/trail restrictions (5.90 KB, patch)
2024-08-03 06:20 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add lead and trail time to circulation rules (18.91 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Take preparation period into account at checkout (3.30 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Add itemtype selection to bookings modal (9.37 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Add handling for lead/trail display (7.40 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Add isSameOrBefore dayjs plugin (1.09 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Simplify modal code using isSameOr* functions (14.92 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Use circulation_rules for buffer timing (5.87 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Update for change to /circulation_rules (1.95 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: (follow-up) Enable flatpickr only once rules are populated (3.30 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Highlight overlaping lead and trail periods (1.83 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Enforce lead/trail restrictions (5.95 KB, patch)
2024-08-05 10:50 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: Add lead and trail time to circulation rulesa (19.05 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Take preparation period into account at checkout (3.43 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add itemtype selection to bookings modal (9.50 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add handling for lead/trail display (7.54 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Add isSameOrBefore dayjs plugin (1.23 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Simplify modal code using isSameOr* functions (15.07 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Use circulation_rules for buffer timing (6.01 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Update for change to /circulation_rules (2.08 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: (follow-up) Enable flatpickr only once rules are populated (3.43 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Highlight overlaping lead and trail periods (1.96 KB, patch)
2024-08-22 10:08 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Enforce lead/trail restrictions (6.09 KB, patch)
2024-08-22 10:09 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Unit test for change to Koha::Item (3.43 KB, patch)
2024-08-22 10:09 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 34440: Unit test for change to Koha::Item (3.49 KB, patch)
2024-08-22 12:16 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: (QA follow-up) Tidy changes to t/db_dependent/Koha/Item.t (1012 bytes, patch)
2024-08-22 13:06 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 34440: bookings_lead_period and bookings_trail_period cant be set at categorycode level (1.11 KB, patch)
2024-09-02 16:26 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2023-07-28 11:24:07 UTC
We should add the option to include a warm-up period to add before a booking and a cool-down to add after a booking in the bookings system.

This would allow for late returns and any maintenance that may need to take place before the next booking is due.

This would also give us something clear to bind on for check-ins to trigger a 'ready for collection' type notice to the patron who booked the materials.
Comment 1 Martin Renvoize (ashimema) 2024-01-15 10:47:48 UTC
*** Bug 35670 has been marked as a duplicate of this bug. ***
Comment 2 Martin Renvoize (ashimema) 2024-02-26 12:30:38 UTC
Quoting Esther Melander:

This is perhaps the beginning of a list of circulation rules needed for bookings.

To replicate:
1. Find an item and create a booking to start tomorrow for Patron 1.
2. Check out the same item to Patron 2 today.

The bookings work correctly in that the item checked out today is also due today. However, if that item actually went out the door with Patron 2 the chances of getting it back in time for the booking is zero. A circulation rule is needed to prevent circulation within so many days of a booking and/or a circulation alert is needed for staff to not let the book circulate because of a pending booking.
Comment 3 Martin Renvoize (ashimema) 2024-04-17 15:44:09 UTC
Work in progress for this is available at https://github.com/PTFS-Europe/koha/tree/bug_34440.

I'm still refining the last pieces of it but will be asking for feedback imminently.

The best way to help it continue to move forward at the moment however is to look at the dependencies and help those work their way through signoff and QA.
Comment 4 Martin Renvoize (ashimema) 2024-06-21 11:26:45 UTC
Created attachment 167948 [details] [review]
Bug 34440: Add lead and trail time to circulation rules
Comment 5 Martin Renvoize (ashimema) 2024-06-21 11:26:47 UTC
Created attachment 167949 [details] [review]
Bug 34440: Take preparation period into account at checkout

This patch ensures we catch checkouts that would interfer with the
preparation period set for an existing booking by adding said period to
the bookings search.

We also reduce the proposed due date for the checkout to be confirmed by
the preparation period for the item.

Test plan
1) Set a booking preparation period for an itemtype
2) Add a booking for an item with that itemtype to fall beyond the due
   date that the item would be assigned if you were to check it out now
   to your test user, but within the number of days you've set for your
   preparation period.
3) Attempt to check the item out to your test user.
4) Note that we catch the booking and warn and that the latest return
   date suggested take the preparation period into account.
Comment 6 Martin Renvoize (ashimema) 2024-06-21 11:26:50 UTC
Created attachment 167950 [details] [review]
Bug 34440: Add itemtype selection to bookings modal

Whilst we still don't need to know the specific item we will need to
know the itemtype to be able to fetch the correct circulation rules for
adjusting the datepicker with lead and trail times.

This patch adds such a picker option. You should be able to select the
item or itemtype in either order.. selecting itemtype first will limit
the items list to options available (and 'Any item').. upon selecting a
specific item the itemtype selector should become disabled and reflect
the itemtype of the item selected.
Comment 7 Martin Renvoize (ashimema) 2024-06-21 11:26:52 UTC
Created attachment 167951 [details] [review]
Bug 34440: Add handling for lead/trail display

This patch adds code to insert classes into the flatpickr for lead and
trail time on bookings and includes some scss additions to highlight
said periods in display.
Comment 8 Martin Renvoize (ashimema) 2024-06-21 11:26:55 UTC
Created attachment 167952 [details] [review]
Bug 34440: Add isSameOrBefore dayjs plugin
Comment 9 Martin Renvoize (ashimema) 2024-06-21 11:26:57 UTC
Created attachment 167953 [details] [review]
Bug 34440: Simplify modal code using isSameOr* functions
Comment 10 Martin Renvoize (ashimema) 2024-06-21 11:27:00 UTC
Created attachment 167954 [details] [review]
Bug 34440: Use circulation_rules for buffer timing
Comment 11 Martin Renvoize (ashimema) 2024-06-21 11:27:03 UTC
Created attachment 167955 [details] [review]
Bug 34440: (TEMP) Comment 'rules' param

Right now, the 'multi' flag used in the 'rules' query param in bug 36641
doesn't work as expected.
Comment 12 Martin Renvoize (ashimema) 2024-07-14 05:48:08 UTC
Created attachment 168941 [details] [review]
Bug 34440: Add lead and trail time to circulation rules
Comment 13 Martin Renvoize (ashimema) 2024-07-14 05:48:10 UTC
Created attachment 168942 [details] [review]
Bug 34440: Take preparation period into account at checkout

This patch ensures we catch checkouts that would interfer with the
preparation period set for an existing booking by adding said period to
the bookings search.

We also reduce the proposed due date for the checkout to be confirmed by
the preparation period for the item.

Test plan
1) Set a booking preparation period for an itemtype
2) Add a booking for an item with that itemtype to fall beyond the due
   date that the item would be assigned if you were to check it out now
   to your test user, but within the number of days you've set for your
   preparation period.
3) Attempt to check the item out to your test user.
4) Note that we catch the booking and warn and that the latest return
   date suggested take the preparation period into account.
Comment 14 Martin Renvoize (ashimema) 2024-07-14 05:48:13 UTC
Created attachment 168943 [details] [review]
Bug 34440: Add itemtype selection to bookings modal

Whilst we still don't need to know the specific item we will need to
know the itemtype to be able to fetch the correct circulation rules for
adjusting the datepicker with lead and trail times.

This patch adds such a picker option. You should be able to select the
item or itemtype in either order.. selecting itemtype first will limit
the items list to options available (and 'Any item').. upon selecting a
specific item the itemtype selector should become disabled and reflect
the itemtype of the item selected.
Comment 15 Martin Renvoize (ashimema) 2024-07-14 05:48:16 UTC
Created attachment 168944 [details] [review]
Bug 34440: Add handling for lead/trail display

This patch adds code to insert classes into the flatpickr for lead and
trail time on bookings and includes some scss additions to highlight
said periods in display.
Comment 16 Martin Renvoize (ashimema) 2024-07-14 05:48:18 UTC
Created attachment 168945 [details] [review]
Bug 34440: Add isSameOrBefore dayjs plugin
Comment 17 Martin Renvoize (ashimema) 2024-07-14 05:48:21 UTC
Created attachment 168946 [details] [review]
Bug 34440: Simplify modal code using isSameOr* functions
Comment 18 Martin Renvoize (ashimema) 2024-07-14 05:48:24 UTC
Created attachment 168947 [details] [review]
Bug 34440: Use circulation_rules for buffer timing
Comment 19 Martin Renvoize (ashimema) 2024-07-14 05:48:27 UTC
Created attachment 168948 [details] [review]
Bug 34440: (TEMP) Comment 'rules' param

Right now, the 'multi' flag used in the 'rules' query param in bug 36641
doesn't work as expected.
Comment 20 Martin Renvoize (ashimema) 2024-07-14 05:48:30 UTC
Created attachment 168949 [details] [review]
Bug 34440: Update for change to /circulation_rules

We updated the preceeding bug that introducing the /circulation_rules
endpoint such that it always returns an array.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Martin Renvoize (ashimema) 2024-07-15 15:37:50 UTC
Created attachment 168998 [details] [review]
Bug 34440: Add lead and trail time to circulation rules
Comment 22 Martin Renvoize (ashimema) 2024-07-15 15:37:52 UTC
Created attachment 168999 [details] [review]
Bug 34440: Take preparation period into account at checkout

This patch ensures we catch checkouts that would interfer with the
preparation period set for an existing booking by adding said period to
the bookings search.

We also reduce the proposed due date for the checkout to be confirmed by
the preparation period for the item.

Test plan
1) Set a booking preparation period for an itemtype
2) Add a booking for an item with that itemtype to fall beyond the due
   date that the item would be assigned if you were to check it out now
   to your test user, but within the number of days you've set for your
   preparation period.
3) Attempt to check the item out to your test user.
4) Note that we catch the booking and warn and that the latest return
   date suggested take the preparation period into account.
Comment 23 Martin Renvoize (ashimema) 2024-07-15 15:37:55 UTC
Created attachment 169000 [details] [review]
Bug 34440: Add itemtype selection to bookings modal

Whilst we still don't need to know the specific item we will need to
know the itemtype to be able to fetch the correct circulation rules for
adjusting the datepicker with lead and trail times.

This patch adds such a picker option. You should be able to select the
item or itemtype in either order.. selecting itemtype first will limit
the items list to options available (and 'Any item').. upon selecting a
specific item the itemtype selector should become disabled and reflect
the itemtype of the item selected.
Comment 24 Martin Renvoize (ashimema) 2024-07-15 15:37:58 UTC
Created attachment 169001 [details] [review]
Bug 34440: Add handling for lead/trail display

This patch adds code to insert classes into the flatpickr for lead and
trail time on bookings and includes some scss additions to highlight
said periods in display.
Comment 25 Martin Renvoize (ashimema) 2024-07-15 15:38:00 UTC
Created attachment 169002 [details] [review]
Bug 34440: Add isSameOrBefore dayjs plugin
Comment 26 Martin Renvoize (ashimema) 2024-07-15 15:38:03 UTC
Created attachment 169003 [details] [review]
Bug 34440: Simplify modal code using isSameOr* functions
Comment 27 Martin Renvoize (ashimema) 2024-07-15 15:38:06 UTC
Created attachment 169004 [details] [review]
Bug 34440: Use circulation_rules for buffer timing
Comment 28 Martin Renvoize (ashimema) 2024-07-15 15:38:08 UTC
Created attachment 169005 [details] [review]
Bug 34440: Update for change to /circulation_rules

We updated the preceeding bug that introducing the /circulation_rules
endpoint such that it always returns an array.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 29 Martin Renvoize (ashimema) 2024-07-15 15:38:11 UTC
Created attachment 169006 [details] [review]
Bug 34440: (follow-up) Enable flatpickr only once rules are populated
Comment 30 Martin Renvoize (ashimema) 2024-07-15 15:38:14 UTC
Created attachment 169007 [details] [review]
Bug 34440: Highlight overlaping lead and trail periods

This adds a further distinction between a lead/trail period and whether
it would conflict with an existing booking or not.
Comment 31 Martin Renvoize (ashimema) 2024-07-15 15:41:50 UTC
I need some testing and feedback on this one at this point.

At booking time, this is mostly visual.. i.e. we allow bookings to take place even though the lead or trail times may be conflicting.  We highlight that an overlap is taking place by darkening the hinted area's for lead and trail times.

I considered making this require an override but haven't added that code at this time.

I've also not prevented these lead/trail overlaps at the server level.
Comment 32 Kristi 2024-07-17 20:20:01 UTC
I am moving through the test plan in a sandbox and will follow up tomorrow there. 

Re: 
"I need some testing and feedback on this one at this point.

At booking time, this is mostly visual.. i.e. we allow bookings to take place even though the lead or trail times may be conflicting.  We highlight that an overlap is taking place by darkening the hinted area's for lead and trail times.

I considered making this require an override but haven't added that code at this time.

I've also not prevented these lead/trail overlaps at the server level."

Our use case for prep time/warm up and cool down is that the bookable item may need to travel from one branch to another for pickup, or it may need to be cleaned or otherwise re-set before another patron can use it.

The prep time functions to ensure that the patron who booked the item cannot have it out these days, but no one else can reserve it at this time either. 

We have over 100 staff that may place bookings, so if we do not prevent bookings conflicting with warm up/cool down days there is a high chance of confusion/bookings not ready for pickup on the start date.

Hope that helps!
Comment 33 Kristi 2024-07-18 18:49:46 UTC
Could I ask for more parameters on step 2 of the test plan? 

Add a booking for an item with that itemtype to fall beyond the due date that the item would be assigned if you were to check it out now to your test user, but within the number of days you've set for your preparation period.

Am I correct in thinking that could be: 
I set an item type with 2 days of prep time on either end.
I set up a booking where the prep time starts Monday, 7/22, the actual booking begins Wednesday, 7/24, and ends Monday, 7/29. The prep time at the end goes until Wednesday, 7/31.  

Try to check out the item with the booking to a patron on 7/22, and see if the warning describes pops up?
Comment 34 Martin Renvoize (ashimema) 2024-07-25 15:43:54 UTC Comment hidden (obsolete)
Comment 35 Martin Renvoize (ashimema) 2024-07-25 15:43:56 UTC Comment hidden (obsolete)
Comment 36 Martin Renvoize (ashimema) 2024-07-25 15:43:59 UTC Comment hidden (obsolete)
Comment 37 Martin Renvoize (ashimema) 2024-07-25 15:44:02 UTC Comment hidden (obsolete)
Comment 38 Martin Renvoize (ashimema) 2024-07-25 15:44:05 UTC Comment hidden (obsolete)
Comment 39 Martin Renvoize (ashimema) 2024-07-25 15:44:08 UTC Comment hidden (obsolete)
Comment 40 Martin Renvoize (ashimema) 2024-07-25 15:44:11 UTC Comment hidden (obsolete)
Comment 41 Martin Renvoize (ashimema) 2024-07-25 15:44:14 UTC Comment hidden (obsolete)
Comment 42 Martin Renvoize (ashimema) 2024-07-25 15:44:17 UTC Comment hidden (obsolete)
Comment 43 Martin Renvoize (ashimema) 2024-07-25 15:44:20 UTC Comment hidden (obsolete)
Comment 44 Martin Renvoize (ashimema) 2024-07-25 15:44:23 UTC
Created attachment 169581 [details] [review]
Bug 34440: Enforce lead/trail restrictions

This patch adds rule enforcement into the user interface. When
attempting to make a booking now, instead of just visually displaying
the lead and trail period and highlighting when an overlap appears, we
now block the ability to select a date when such an overlap case is
found.
Comment 45 Martin Renvoize (ashimema) 2024-07-25 15:55:13 UTC
Thanks for the feedback Kristi.

I've now added the code to block bookings that would infringe the lead/trail period.

Currently, it only takes into account the additional periods for the item you are booking and not the surrounding bookings, however.. I think I may need to update it to take more into account.

i.e it currently acts like:

booking 1 --||-- lead | booking 2 | trail -- ||-- booking 3

Should it be the following in your opinion:

booking 1 --| trail --||-- lead | booking 2 | trail -- ||-- lead | booking 3
Comment 46 Martin Renvoize (ashimema) 2024-07-25 15:58:48 UTC
(In reply to Kristi from comment #33)
> Could I ask for more parameters on step 2 of the test plan? 
> 
> Add a booking for an item with that itemtype to fall beyond the due date
> that the item would be assigned if you were to check it out now to your test
> user, but within the number of days you've set for your preparation period.
> 
> Am I correct in thinking that could be: 
> I set an item type with 2 days of prep time on either end.
> I set up a booking where the prep time starts Monday, 7/22, the actual
> booking begins Wednesday, 7/24, and ends Monday, 7/29. The prep time at the
> end goes until Wednesday, 7/31.  
> 
> Try to check out the item with the booking to a patron on 7/22, and see if
> the warning describes pops up?

I'd be more than happy to have a call.. this is all rather involved so maybe a little video chat would help?  It sounds like you've understood it correctly though.

I envisage 'prep time = lead time' and it's about what you may need to do to prepare the item for the next user and 'trail time' to be a buffer for 'late returns' in the way I've written it.
Comment 47 Martin Renvoize (ashimema) 2024-07-25 16:07:54 UTC Comment hidden (obsolete)
Comment 48 Martin Renvoize (ashimema) 2024-07-25 16:09:36 UTC Comment hidden (obsolete)
Comment 49 Martin Renvoize (ashimema) 2024-08-03 06:20:13 UTC
Created attachment 170032 [details] [review]
Bug 34440: Add lead and trail time to circulation rules
Comment 50 Martin Renvoize (ashimema) 2024-08-03 06:20:16 UTC
Created attachment 170033 [details] [review]
Bug 34440: Take preparation period into account at checkout

This patch ensures we catch checkouts that would interfer with the
preparation period set for an existing booking by adding said period to
the bookings search.

We also reduce the proposed due date for the checkout to be confirmed by
the preparation period for the item.

Test plan
1) Set a booking preparation period for an itemtype
2) Add a booking for an item with that itemtype to fall beyond the due
   date that the item would be assigned if you were to check it out now
   to your test user, but within the number of days you've set for your
   preparation period.
3) Attempt to check the item out to your test user.
4) Note that we catch the booking and warn and that the latest return
   date suggested take the preparation period into account.
Comment 51 Martin Renvoize (ashimema) 2024-08-03 06:20:19 UTC
Created attachment 170034 [details] [review]
Bug 34440: Add itemtype selection to bookings modal

Whilst we still don't need to know the specific item we will need to
know the itemtype to be able to fetch the correct circulation rules for
adjusting the datepicker with lead and trail times.

This patch adds such a picker option. You should be able to select the
item or itemtype in either order.. selecting itemtype first will limit
the items list to options available (and 'Any item').. upon selecting a
specific item the itemtype selector should become disabled and reflect
the itemtype of the item selected.
Comment 52 Martin Renvoize (ashimema) 2024-08-03 06:20:22 UTC
Created attachment 170035 [details] [review]
Bug 34440: Add handling for lead/trail display

This patch adds code to insert classes into the flatpickr for lead and
trail time on bookings and includes some scss additions to highlight
said periods in display.
Comment 53 Martin Renvoize (ashimema) 2024-08-03 06:20:25 UTC
Created attachment 170036 [details] [review]
Bug 34440: Add isSameOrBefore dayjs plugin
Comment 54 Martin Renvoize (ashimema) 2024-08-03 06:20:28 UTC
Created attachment 170037 [details] [review]
Bug 34440: Simplify modal code using isSameOr* functions
Comment 55 Martin Renvoize (ashimema) 2024-08-03 06:20:31 UTC
Created attachment 170038 [details] [review]
Bug 34440: Use circulation_rules for buffer timing
Comment 56 Martin Renvoize (ashimema) 2024-08-03 06:20:34 UTC
Created attachment 170039 [details] [review]
Bug 34440: Update for change to /circulation_rules

We updated the preceeding bug that introducing the /circulation_rules
endpoint such that it always returns an array.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 57 Martin Renvoize (ashimema) 2024-08-03 06:20:36 UTC
Created attachment 170040 [details] [review]
Bug 34440: (follow-up) Enable flatpickr only once rules are populated
Comment 58 Martin Renvoize (ashimema) 2024-08-03 06:20:39 UTC
Created attachment 170041 [details] [review]
Bug 34440: Highlight overlaping lead and trail periods

This adds a further distinction between a lead/trail period and whether
it would conflict with an existing booking or not.
Comment 59 Martin Renvoize (ashimema) 2024-08-03 06:20:42 UTC
Created attachment 170042 [details] [review]
Bug 34440: Enforce lead/trail restrictions

This patch adds rule enforcement into the user interface. When
attempting to make a booking now, instead of just visually displaying
the lead and trail period and highlighting when an overlap appears, we
now block the ability to select a date when such an overlap case is
found.
Comment 60 Paul Derscheid 2024-08-05 10:50:15 UTC
Created attachment 170046 [details] [review]
Bug 34440: Add lead and trail time to circulation rules

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 61 Paul Derscheid 2024-08-05 10:50:18 UTC
Created attachment 170047 [details] [review]
Bug 34440: Take preparation period into account at checkout

This patch ensures we catch checkouts that would interfer with the
preparation period set for an existing booking by adding said period to
the bookings search.

We also reduce the proposed due date for the checkout to be confirmed by
the preparation period for the item.

Test plan
1) Set a booking preparation period for an itemtype
2) Add a booking for an item with that itemtype to fall beyond the due
   date that the item would be assigned if you were to check it out now
   to your test user, but within the number of days you've set for your
   preparation period.
3) Attempt to check the item out to your test user.
4) Note that we catch the booking and warn and that the latest return
   date suggested take the preparation period into account.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 62 Paul Derscheid 2024-08-05 10:50:21 UTC
Created attachment 170048 [details] [review]
Bug 34440: Add itemtype selection to bookings modal

Whilst we still don't need to know the specific item we will need to
know the itemtype to be able to fetch the correct circulation rules for
adjusting the datepicker with lead and trail times.

This patch adds such a picker option. You should be able to select the
item or itemtype in either order.. selecting itemtype first will limit
the items list to options available (and 'Any item').. upon selecting a
specific item the itemtype selector should become disabled and reflect
the itemtype of the item selected.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 63 Paul Derscheid 2024-08-05 10:50:24 UTC
Created attachment 170049 [details] [review]
Bug 34440: Add handling for lead/trail display

This patch adds code to insert classes into the flatpickr for lead and
trail time on bookings and includes some scss additions to highlight
said periods in display.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 64 Paul Derscheid 2024-08-05 10:50:27 UTC
Created attachment 170050 [details] [review]
Bug 34440: Add isSameOrBefore dayjs plugin

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 65 Paul Derscheid 2024-08-05 10:50:30 UTC
Created attachment 170051 [details] [review]
Bug 34440: Simplify modal code using isSameOr* functions

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 66 Paul Derscheid 2024-08-05 10:50:33 UTC
Created attachment 170052 [details] [review]
Bug 34440: Use circulation_rules for buffer timing

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 67 Paul Derscheid 2024-08-05 10:50:36 UTC
Created attachment 170053 [details] [review]
Bug 34440: Update for change to /circulation_rules

We updated the preceeding bug that introducing the /circulation_rules
endpoint such that it always returns an array.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 68 Paul Derscheid 2024-08-05 10:50:39 UTC
Created attachment 170054 [details] [review]
Bug 34440: (follow-up) Enable flatpickr only once rules are populated

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 69 Paul Derscheid 2024-08-05 10:50:42 UTC
Created attachment 170055 [details] [review]
Bug 34440: Highlight overlaping lead and trail periods

This adds a further distinction between a lead/trail period and whether
it would conflict with an existing booking or not.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 70 Paul Derscheid 2024-08-05 10:50:45 UTC
Created attachment 170056 [details] [review]
Bug 34440: Enforce lead/trail restrictions

This patch adds rule enforcement into the user interface. When
attempting to make a booking now, instead of just visually displaying
the lead and trail period and highlighting when an overlap appears, we
now block the ability to select a date when such an overlap case is
found.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 71 Martin Renvoize (ashimema) 2024-08-07 08:41:56 UTC
(In reply to Martin Renvoize from comment #45)
> Thanks for the feedback Kristi.
> 
> I've now added the code to block bookings that would infringe the lead/trail
> period.
> 
> Currently, it only takes into account the additional periods for the item
> you are booking and not the surrounding bookings, however.. I think I may
> need to update it to take more into account.
> 
> i.e it currently acts like:
> 
> booking 1 --||-- lead | booking 2 | trail -- ||-- booking 3
> 
> Should it be the following in your opinion:
> 
> booking 1 --| trail --||-- lead | booking 2 | trail -- ||-- lead | booking 3

I discussed this with Kristi and she agree's that it should be the combination of periods as proposed in the example above.


A- | TA >|< LB | -B- | TB >|< LC | -C

I'll look at adding a following to deal with that ASAP
Comment 72 Martin Renvoize (ashimema) 2024-08-22 10:08:27 UTC
Created attachment 170589 [details] [review]
Bug 34440: Add lead and trail time to circulation rulesa

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 73 Martin Renvoize (ashimema) 2024-08-22 10:08:31 UTC
Created attachment 170590 [details] [review]
Bug 34440: Take preparation period into account at checkout

This patch ensures we catch checkouts that would interfer with the
preparation period set for an existing booking by adding said period to
the bookings search.

We also reduce the proposed due date for the checkout to be confirmed by
the preparation period for the item.

Test plan
1) Set a booking preparation period for an itemtype
2) Add a booking for an item with that itemtype to fall beyond the due
   date that the item would be assigned if you were to check it out now
   to your test user, but within the number of days you've set for your
   preparation period.
3) Attempt to check the item out to your test user.
4) Note that we catch the booking and warn and that the latest return
   date suggested take the preparation period into account.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 74 Martin Renvoize (ashimema) 2024-08-22 10:08:34 UTC
Created attachment 170591 [details] [review]
Bug 34440: Add itemtype selection to bookings modal

Whilst we still don't need to know the specific item we will need to
know the itemtype to be able to fetch the correct circulation rules for
adjusting the datepicker with lead and trail times.

This patch adds such a picker option. You should be able to select the
item or itemtype in either order.. selecting itemtype first will limit
the items list to options available (and 'Any item').. upon selecting a
specific item the itemtype selector should become disabled and reflect
the itemtype of the item selected.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 75 Martin Renvoize (ashimema) 2024-08-22 10:08:37 UTC
Created attachment 170592 [details] [review]
Bug 34440: Add handling for lead/trail display

This patch adds code to insert classes into the flatpickr for lead and
trail time on bookings and includes some scss additions to highlight
said periods in display.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 76 Martin Renvoize (ashimema) 2024-08-22 10:08:41 UTC
Created attachment 170593 [details] [review]
Bug 34440: Add isSameOrBefore dayjs plugin

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 77 Martin Renvoize (ashimema) 2024-08-22 10:08:44 UTC
Created attachment 170594 [details] [review]
Bug 34440: Simplify modal code using isSameOr* functions

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 78 Martin Renvoize (ashimema) 2024-08-22 10:08:48 UTC
Created attachment 170595 [details] [review]
Bug 34440: Use circulation_rules for buffer timing

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 79 Martin Renvoize (ashimema) 2024-08-22 10:08:51 UTC
Created attachment 170596 [details] [review]
Bug 34440: Update for change to /circulation_rules

We updated the preceeding bug that introducing the /circulation_rules
endpoint such that it always returns an array.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 80 Martin Renvoize (ashimema) 2024-08-22 10:08:54 UTC
Created attachment 170597 [details] [review]
Bug 34440: (follow-up) Enable flatpickr only once rules are populated

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 81 Martin Renvoize (ashimema) 2024-08-22 10:08:57 UTC
Created attachment 170598 [details] [review]
Bug 34440: Highlight overlaping lead and trail periods

This adds a further distinction between a lead/trail period and whether
it would conflict with an existing booking or not.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 82 Martin Renvoize (ashimema) 2024-08-22 10:09:00 UTC
Created attachment 170599 [details] [review]
Bug 34440: Enforce lead/trail restrictions

This patch adds rule enforcement into the user interface. When
attempting to make a booking now, instead of just visually displaying
the lead and trail period and highlighting when an overlap appears, we
now block the ability to select a date when such an overlap case is
found.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Kristi Krueger <KKRUEGER@cuyahogalibrary.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 83 Martin Renvoize (ashimema) 2024-08-22 10:09:03 UTC
Created attachment 170600 [details] [review]
Bug 34440: Unit test for change to Koha::Item

This adds a unit test for the new preparation_period handling introduced
into the find_booking method of Koha::Item.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Comment 84 Paul Derscheid 2024-08-22 12:16:49 UTC
Created attachment 170603 [details] [review]
Bug 34440: Unit test for change to Koha::Item

This adds a unit test for the new preparation_period handling introduced
into the find_booking method of Koha::Item.

Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 85 Paul Derscheid 2024-08-22 13:06:14 UTC
Created attachment 170610 [details] [review]
Bug 34440: (QA follow-up) Tidy changes to t/db_dependent/Koha/Item.t
Comment 86 Katrin Fischer 2024-08-30 13:20:20 UTC
Something went wrong here when attaching the patches. I will try to fix, but please double check.

Please don't forget to obsolete patches manually where you updated the commit message.


Bug 34440 - Add warm-up and cool-down periods to bookings

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 34440: Add lead and trail time to circulation rules
Applying: Bug 34440: Add lead and trail time to circulation rulesa
Using index info to reconstruct a base tree...
M	Koha/CirculationRules.pm
M	admin/smart-rules.pl
M	installer/onboarding.pl
M	koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
******No changes -- Patch already applied.
Applying: Bug 34440: Take preparation period into account at checkout
Applying: Bug 34440: Add itemtype selection to bookings modal
Applying: Bug 34440: Add handling for lead/trail display
Applying: Bug 34440: Add isSameOrBefore dayjs plugin
Applying: Bug 34440: Simplify modal code using isSameOr* functions
Applying: Bug 34440: Use circulation_rules for buffer timing
Applying: Bug 34440: Update for change to /circulation_rules
Applying: Bug 34440: (follow-up) Enable flatpickr only once rules are populated
Applying: Bug 34440: Highlight overlaping lead and trail periods
Applying: Bug 34440: Enforce lead/trail restrictions
Applying: Bug 34440: Unit test for change to Koha::Item
Applying: Bug 34440: (QA follow-up) Tidy changes to t/db_dependent/Koha/Item.t
Comment 87 Katrin Fischer 2024-08-30 13:38:08 UTC
Notes from RM testing :)

1) Terminology

The code uses trail and lead, the GUI uses preparation and precaution, the bug description uses warm-up and cool-down periods. I have to admit all were new to me :) Can we standardize a little at least between GUI and bug?                       

2) Item type or Itemtype?

The label on the bookings form used Itemtype, but then we also have:

+        placeholder: __("Item type"),

We actually don't have that resolved in the terminology list either. Asking on Mattermost, something more to standardize!

2) GUI

I have been wondering if adding "days" behind the input fields might help usability a bit or not.

3) Release notes please!!
Comment 88 Katrin Fischer 2024-08-30 14:42:36 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 89 Jonathan Druart 2024-09-02 11:03:20 UTC
It took me a long time to notice that this patchset was the culprit!

https://jenkins.koha-community.org/job/Koha_Main/3019/consoleFull

t/db_dependent/selenium/opac_holds.t is failing with
17:36:02 koha_1       |         #   Failed test 'Detail page - Place hold button should be absent. Authenticated - onshelfholds If all unavailable'
17:36:02 koha_1       |         #   at t/db_dependent/selenium/opac_holds.t line 402.
17:36:02 koha_1       |         #          got: 'Place hold'
17:36:02 koha_1       |         #     expected: 'Print'
17:36:02 koha_1       |         # Looks like you failed 1 test of 7.
17:36:02 koha_1       | 
17:36:02 koha_1       |     #   Failed test 'detail page'
17:36:02 koha_1       |     #   at t/db_dependent/selenium/opac_holds.t line 308.
17:36:02 koha_1       |     # Looks like you failed 1 test of 5.
17:36:02 koha_1       | 
17:36:02 koha_1       | #   Failed test 'authenticated'
17:36:02 koha_1       | #   at t/db_dependent/selenium/opac_holds.t line 310.

Then lot of other tests, but I think we should focus on the first failure.

You can recreate using:

root@kohadevbox:koha$ perl ../misc4dev/run_tests.pl --run-all-tests

Easier if you replace this line:
-    @prove_files = map { chomp ; $_ } qx{ ( find t/db_dependent/selenium -name '*.t' -not -name '00-onboarding.t' | sort ) ; ( find t xt -name '*.t' -not -path "t/db_dependent/selenium/*" | shuf ) };

+    @prove_files = qw( t/db_dependent/selenium/01-installation.t t/db_dependent/selenium/opac_holds.t );

I have no idea what's going on, neither why it fails, but it fails :)
Comment 90 Jonathan Druart 2024-09-02 11:11:22 UTC
If I comment, in t/db_dependent/selenium/opac_holds.t:

reset_data() that is after
  detail_page_hold_button_absent('Authenticated - onshelfholds If all unavailable');

Then cleanup_data();, I can see the problem on the UI

It seems that opac/opac-detail.pl
 701         $can_holds_be_placed =
 702             $can_holds_be_placed || $patron && IsAvailableForItemLevelRequest( $item, $patron, undef );

This is 1 when it should be 0.

IF I go to admin/smart-rules.pl, edit and save (ie. set default to circ rules), the test will pass!
Comment 91 Katrin Fischer 2024-09-02 11:34:22 UTC
(In reply to Jonathan Druart from comment #90)
> If I comment, in t/db_dependent/selenium/opac_holds.t:
> 
> reset_data() that is after
>   detail_page_hold_button_absent('Authenticated - onshelfholds If all
> unavailable');
> 
> Then cleanup_data();, I can see the problem on the UI
> 
> It seems that opac/opac-detail.pl
>  701         $can_holds_be_placed =
>  702             $can_holds_be_placed || $patron &&
> IsAvailableForItemLevelRequest( $item, $patron, undef );
> 
> This is 1 when it should be 0.
> 
> IF I go to admin/smart-rules.pl, edit and save (ie. set default to circ
> rules), the test will pass!

I believe Martin is back at work this week, so hope he can help to shed some light on this!
Comment 92 Pedro Amorim 2024-09-02 16:26:59 UTC
Created attachment 170951 [details] [review]
Bug 34440: bookings_lead_period and bookings_trail_period cant be set at categorycode level

Follow Joubu's test plan. It should no longer fail.

Error from eval Koha::CirculationRules->set_rules($params) at onboarding.pl was:
set_rule cannot set 'bookings_trail_period' for a 'categorycode'! at /kohadevbox/koha/installer/onboarding.pl line 301.
Comment 93 Martin Renvoize (ashimema) 2024-09-03 04:17:39 UTC
Thanks Pedro, great work.

I honestly have no idea how those lines got added in the first place to onboarding.. I don't remember adding them and certainly didn't test that.
Comment 94 Martin Renvoize (ashimema) 2024-09-03 04:23:26 UTC
Follow-up pushed.. lets see how Jenkins does now.
Comment 95 Jonathan Druart 2024-09-03 06:59:16 UTC
Thanks Pedro, nice one. It drove me crazy!

I didn't noticed the error in the logs!
Comment 96 Jonathan Druart 2024-09-03 07:11:26 UTC
Reading the code:

koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js

 149                 leadDays = rules.bookings_lead_period;
 150                 trailDays = rules.n;

 819                             const leadStart = startDate
 820                                 ? startDate.subtract(leadDays, "day")
 821                                 : hoverDate.subtract(leadDays, "day");
 822                             const leadEnd = startDate ? startDate : hoverDate;

I think we should test if startDate is defined.

Then also if bookings_lead_period and bookings_trail_period are defined.

I see, at least, "Uncaught TypeError: startDate is null" when no start date is selected.