Bug 37354 - Bookings should respect circulation rules for max loan periods
Summary: Bookings should respect circulation rules for max loan periods
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize
QA Contact: Testopia
URL:
Keywords:
Depends on: 34440
Blocks:
  Show dependency treegraph
 
Reported: 2024-07-14 06:02 UTC by Martin Renvoize
Modified: 2024-08-22 10:15 UTC (History)
12 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 37354: Set maxDate based on issuelength + renewals * renewalperiod (3.04 KB, patch)
2024-07-14 06:41 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Set maxDate based on issuelength + renewals * renewalperiod (3.04 KB, patch)
2024-07-15 10:08 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Add visual hint at usual loan periods (4.93 KB, patch)
2024-07-15 10:08 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod) (3.59 KB, patch)
2024-07-15 10:20 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Add visual hint at usual loan periods (5.27 KB, patch)
2024-07-15 10:20 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod) (3.63 KB, patch)
2024-07-15 15:42 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Add visual hint at usual loan periods (5.32 KB, patch)
2024-07-15 15:42 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod) (3.60 KB, patch)
2024-07-25 16:12 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Add visual hint at usual loan periods (5.32 KB, patch)
2024-07-25 16:12 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod) (3.60 KB, patch)
2024-07-26 08:05 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Add visual hint at usual loan periods (6.35 KB, patch)
2024-07-26 08:05 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod) (3.65 KB, patch)
2024-08-05 14:18 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 37354: Add visual hint at usual loan periods (6.41 KB, patch)
2024-08-05 14:18 UTC, Paul Derscheid
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize 2024-07-14 06:02:17 UTC
+++ This bug was initially created as a clone of Bug #36271 +++
The original bug for this took on a life of its own and became broader in scope adding a series of circulation rules for the bookings system

I've cloned it here to propose my original more limited-in-scope solution using existing circulation rules for loan length * renewals count.

---------------------------------------------------------------
Currently, bookings are on/off at the item level, but the booking period is entirely open meaning an item can be booked for any period.

We should refine this to allow libraries to control the maximum length an item can be booked for.

During the original development, I suggested perhaps we should set the maximum to the loan length of the item times the max renewals from the circulation rules.. However, I didn't get much feedback as to whether this was appropriate or whether people wanted a distinct rule for these items or another alternative.
Comment 1 Martin Renvoize 2024-07-14 06:41:20 UTC
Created attachment 168950 [details] [review]
Bug 37354: Set maxDate based on issuelength + renewals * renewalperiod

This patch sets the flatpickr maxDate in the bookings range picker to
the startdate selected + issuelength + renewals * renewalperiod
circulation rules.
Comment 2 Martin Renvoize 2024-07-14 06:42:08 UTC
We'll likely want to also enforce this in the API controller level.. or perhaps at the koha object level.
Comment 3 Martin Renvoize 2024-07-15 10:08:44 UTC
Created attachment 168964 [details] [review]
Bug 37354: Set maxDate based on issuelength + renewals * renewalperiod

This patch sets the flatpickr maxDate in the bookings range picker to
the startdate selected + issuelength + renewals * renewalperiod
circulation rules.
Comment 4 Martin Renvoize 2024-07-15 10:08:47 UTC
Created attachment 168965 [details] [review]
Bug 37354: Add visual hint at usual loan periods

This patch adds a visual hint to the datepicker to highlight dates that
line up with normal loan and renewal lengths.

We use bold to highlight such dates.
Comment 5 Martin Renvoize 2024-07-15 10:20:07 UTC
Created attachment 168966 [details] [review]
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod)

This patch sets the flatpickr maxDate in the bookings range picker to
the startdate selected + issuelength + renewals * renewalperiod
circulation rules.

Test plan
1) Set an item in a test biblio to 'bookable' from the items tab.
2) Note the itemtype of the above item
3) Add circulation rules for the above item type, in particular the
   'Loan period', 'Renewals allowed' and 'Renewal period' options.
4) Go back to your biblio and 'Place booking'. Select a user, pickup
   location and item.
5) Open the booking dates flatpickr.
6) Select a start date.
7) Note that the date that is 'Loan period' + 'Renewals allowed' *
'Renewal period' is now greyed out and cannot be selected or any date
beyond it either.
Comment 6 Martin Renvoize 2024-07-15 10:20:09 UTC
Created attachment 168967 [details] [review]
Bug 37354: Add visual hint at usual loan periods

This patch adds a visual hint to the datepicker to highlight dates that
line up with normal loan and renewal lengths.

We use bold to highlight such dates.

Test plan
1) Repeat the test plan for the previous patch
2) Note that once you have selected your first date, that date will
   become bold, the date a 'Loan period' after the start date will also
   be bold and you'll also have bold dates for the number of 'Renewals
   allowed' at each 'Renewal period' beyond the initial 'Loan period'
   date.
Comment 7 Martin Renvoize 2024-07-15 15:42:33 UTC
Created attachment 169008 [details] [review]
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod)

This patch sets the flatpickr maxDate in the bookings range picker to
the startdate selected + issuelength + renewals * renewalperiod
circulation rules.

Test plan
1) Set an item in a test biblio to 'bookable' from the items tab.
2) Note the itemtype of the above item
3) Add circulation rules for the above item type, in particular the
   'Loan period', 'Renewals allowed' and 'Renewal period' options.
4) Go back to your biblio and 'Place booking'. Select a user, pickup
   location and item.
5) Open the booking dates flatpickr.
6) Select a start date.
7) Note that the date that is 'Loan period' + 'Renewals allowed' *
'Renewal period' is now greyed out and cannot be selected or any date
beyond it either.
Comment 8 Martin Renvoize 2024-07-15 15:42:35 UTC
Created attachment 169009 [details] [review]
Bug 37354: Add visual hint at usual loan periods

This patch adds a visual hint to the datepicker to highlight dates that
line up with normal loan and renewal lengths.

We use bold to highlight such dates.

Test plan
1) Repeat the test plan for the previous patch
2) Note that once you have selected your first date, that date will
   become bold, the date a 'Loan period' after the start date will also
   be bold and you'll also have bold dates for the number of 'Renewals
   allowed' at each 'Renewal period' beyond the initial 'Loan period'
   date.
Comment 9 Thibaud Guillot 2024-07-18 08:06:13 UTC
I would test it today but there is just a little conflict with a fresh main branch in koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js
Comment 10 Martin Renvoize 2024-07-25 16:12:14 UTC
Created attachment 169590 [details] [review]
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod)

This patch sets the flatpickr maxDate in the bookings range picker to
the startdate selected + issuelength + renewals * renewalperiod
circulation rules.

Test plan
1) Set an item in a test biblio to 'bookable' from the items tab.
2) Note the itemtype of the above item
3) Add circulation rules for the above item type, in particular the
   'Loan period', 'Renewals allowed' and 'Renewal period' options.
4) Go back to your biblio and 'Place booking'. Select a user, pickup
   location and item.
5) Open the booking dates flatpickr.
6) Select a start date.
7) Note that the date that is 'Loan period' + 'Renewals allowed' *
'Renewal period' is now greyed out and cannot be selected or any date
beyond it either.
Comment 11 Martin Renvoize 2024-07-25 16:12:17 UTC
Created attachment 169591 [details] [review]
Bug 37354: Add visual hint at usual loan periods

This patch adds a visual hint to the datepicker to highlight dates that
line up with normal loan and renewal lengths.

We use bold to highlight such dates.

Test plan
1) Repeat the test plan for the previous patch
2) Note that once you have selected your first date, that date will
   become bold, the date a 'Loan period' after the start date will also
   be bold and you'll also have bold dates for the number of 'Renewals
   allowed' at each 'Renewal period' beyond the initial 'Loan period'
   date.
Comment 12 Martin Renvoize 2024-07-25 16:14:37 UTC
Rebased and ready for testing again.
Comment 13 Martin Renvoize 2024-07-26 08:05:20 UTC
Created attachment 169685 [details] [review]
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod)

This patch sets the flatpickr maxDate in the bookings range picker to
the startdate selected + issuelength + renewals * renewalperiod
circulation rules.

Test plan
1) Set an item in a test biblio to 'bookable' from the items tab.
2) Note the itemtype of the above item
3) Add circulation rules for the above item type, in particular the
   'Loan period', 'Renewals allowed' and 'Renewal period' options.
4) Go back to your biblio and 'Place booking'. Select a user, pickup
   location and item.
5) Open the booking dates flatpickr.
6) Select a start date.
7) Note that the date that is 'Loan period' + 'Renewals allowed' *
'Renewal period' is now greyed out and cannot be selected or any date
beyond it either.
Comment 14 Martin Renvoize 2024-07-26 08:05:24 UTC
Created attachment 169686 [details] [review]
Bug 37354: Add visual hint at usual loan periods

This patch adds a visual hint to the datepicker to highlight dates that
line up with normal loan and renewal lengths.

We use bold to highlight such dates.

Test plan
1) Repeat the test plan for the previous patch
2) Note that once you have selected your first date, that date will
   become bold, the date a 'Loan period' after the start date will also
   be bold and you'll also have bold dates for the number of 'Renewals
   allowed' at each 'Renewal period' beyond the initial 'Loan period'
   date.
Comment 15 Sam Lau 2024-07-26 18:14:42 UTC
In testing I noticed that if you don't select an item and just leave it to the 'Any item' selection you can select whatever booking dates. Is the expected behavior? If so I can sign-off.
Comment 16 Paul Derscheid 2024-08-05 14:18:40 UTC
Created attachment 170066 [details] [review]
Bug 37354: Set maxDate based on issuelength + (renewals * renewalperiod)

This patch sets the flatpickr maxDate in the bookings range picker to
the startdate selected + issuelength + renewals * renewalperiod
circulation rules.

Test plan
1) Set an item in a test biblio to 'bookable' from the items tab.
2) Note the itemtype of the above item
3) Add circulation rules for the above item type, in particular the
   'Loan period', 'Renewals allowed' and 'Renewal period' options.
4) Go back to your biblio and 'Place booking'. Select a user, pickup
   location and item.
5) Open the booking dates flatpickr.
6) Select a start date.
7) Note that the date that is 'Loan period' + 'Renewals allowed' *
'Renewal period' is now greyed out and cannot be selected or any date
beyond it either.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 17 Paul Derscheid 2024-08-05 14:18:43 UTC
Created attachment 170067 [details] [review]
Bug 37354: Add visual hint at usual loan periods

This patch adds a visual hint to the datepicker to highlight dates that
line up with normal loan and renewal lengths.

We use bold to highlight such dates.

Test plan
1) Repeat the test plan for the previous patch
2) Note that once you have selected your first date, that date will
   become bold, the date a 'Loan period' after the start date will also
   be bold and you'll also have bold dates for the number of 'Renewals
   allowed' at each 'Renewal period' beyond the initial 'Loan period'
   date.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 18 Martin Renvoize 2024-08-22 10:15:45 UTC
(In reply to Sam Lau from comment #15)
> In testing I noticed that if you don't select an item and just leave it to
> the 'Any item' selection you can select whatever booking dates. Is the
> expected behaviour? If so I can sign-off.

I'm afraid I couldn't replicate this.. maybe I've fixed it already inadvertently in the work I've continued on during bug 34440.