Bug 38175 - Improve bookings behavior with new status field
Summary: Improve bookings behavior with new status field
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Thibaud Guillot (thibaud_g)
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
: 36248 (view as bug list)
Depends on: 37803
Blocks: 38222 38342
  Show dependency treegraph
 
Reported: 2024-10-15 12:22 UTC by Thibaud Guillot (thibaud_g)
Modified: 2024-11-20 18:38 UTC (History)
6 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
We opted to move away from deleting bookings on collection/cancellation and instead use a status field to signify booking state. This allows for future reporting against fulfilled bookings.
Version(s) released in:
24.11.00
Circulation function: bookings


Attachments
Bug 38175: Improve Bookings feature with status (17.09 KB, patch)
2024-10-15 12:46 UTC, Thibaud Guillot (thibaud_g)
Details | Diff | Splinter Review
Bug 38175: Add tests (8.22 KB, patch)
2024-10-15 12:46 UTC, Thibaud Guillot (thibaud_g)
Details | Diff | Splinter Review
Bug 38175: Improve Bookings feature with status (17.09 KB, patch)
2024-10-15 12:49 UTC, Thibaud Guillot (thibaud_g)
Details | Diff | Splinter Review
Bug 38175: Add tests (8.22 KB, patch)
2024-10-15 12:49 UTC, Thibaud Guillot (thibaud_g)
Details | Diff | Splinter Review
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency (19.62 KB, patch)
2024-10-16 12:19 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38175: Improve Bookings feature with status (17.15 KB, patch)
2024-10-16 12:21 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38175: Add tests (8.28 KB, patch)
2024-10-16 12:21 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency (19.67 KB, patch)
2024-10-16 12:21 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38175: Improve Bookings feature with status (17.24 KB, patch)
2024-10-17 14:09 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: Add tests (8.35 KB, patch)
2024-10-17 14:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency (19.62 KB, patch)
2024-10-17 14:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (QA follow-up) Remove superflous method (871 bytes, patch)
2024-10-17 14:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (QA follow-up) DRY out PATCH handling (29.92 KB, patch)
2024-10-17 14:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: Improve Bookings feature with status (17.24 KB, patch)
2024-10-22 16:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: Add tests (8.35 KB, patch)
2024-10-22 16:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency (19.62 KB, patch)
2024-10-22 16:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (QA follow-up) Remove superflous method (871 bytes, patch)
2024-10-22 16:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (QA follow-up) DRY out PATCH handling (29.92 KB, patch)
2024-10-22 16:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (QA follow-up) Ensure we handle cancelled in clash detection (7.01 KB, patch)
2024-10-22 16:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (QA follow-up) Unit test for filter_by_active change (3.55 KB, patch)
2024-10-22 16:31 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: Unit tests for assign_item_for_booking (3.33 KB, patch)
2024-10-23 10:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: Handle satus in item auto-assignment for bookings (2.66 KB, patch)
2024-10-23 10:11 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: Handle status in item auto-assignment for bookings (2.66 KB, patch)
2024-10-23 10:11 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (QA follow-up) Add cancelled handling to find_booking (4.82 KB, patch)
2024-10-25 11:10 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38175: (follow-up) Quiet warnings in tests (1.30 KB, patch)
2024-11-04 13:12 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Thibaud Guillot (thibaud_g) 2024-10-15 12:22:48 UTC
Hello,

For the moment, in the "Bookings" code and functionality, when a booking is cancelled via the action button or graphically on the timeline, it is completely deleted.
Given the recent enhancement adding the status column to the bookings table, it would probably be preferable to change the status and keep the booking in the table.

Later, having another table like holds and old_holds would be preferable, but it's a first step towards a more logical change.
Comment 1 Thibaud Guillot (thibaud_g) 2024-10-15 12:46:48 UTC Comment hidden (obsolete)
Comment 2 Thibaud Guillot (thibaud_g) 2024-10-15 12:46:50 UTC Comment hidden (obsolete)
Comment 3 Thibaud Guillot (thibaud_g) 2024-10-15 12:49:26 UTC
Created attachment 172772 [details] [review]
Bug 38175: Improve Bookings feature with status

With the integration of the new status column for bookings, it would be preferable to keep the booking in database and simply change its status to 'cancel' when you cancel it via the action button or the timeline.

So I've added partial updating via the API with a new PATCH method to partially edit a booking. It is currently active for status changes.
Graphically, this translates into the disappearance of the action buttons if the booking has already been canceled, although it remains visible in the table and timeline (the style is a proposal for the moment, intended simply to graphically differentiate a canceled booking from others).

I've also added a filter to the filter_by_active method to exclude cancelled bookings.

Test plan:
1) Create a booking on a bookable item
2) Cancel it and see that it's simply deleted
3) Apply the patch and run “restart_all”.
4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
5) Try the filters in the table

Sponsored by: BibLibre
Comment 4 Thibaud Guillot (thibaud_g) 2024-10-15 12:49:28 UTC
Created attachment 172773 [details] [review]
Bug 38175: Add tests

Sponsored by: BibLibre
Comment 5 Martin Renvoize (ashimema) 2024-10-16 10:28:18 UTC
I know Paul is looking here, but I'm also lined up for a QA asap once he's tested and worked on it a bit too :)

Thanks Thubaud :)
Comment 6 Paul Derscheid 2024-10-16 12:19:06 UTC
Created attachment 172814 [details] [review]
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency

In the spirit of the current movement for more modern JS, the refactor tries to limit jQuery usage.

Test plan:
    1) Create a booking on a bookable item
    2) Cancel it and see that it's simply deleted
    3) Apply the patch and run “restart_all”.
    4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
    5) Try the filters in the table
Comment 7 Paul Derscheid 2024-10-16 12:21:22 UTC
Created attachment 172815 [details] [review]
Bug 38175: Improve Bookings feature with status

With the integration of the new status column for bookings, it would be preferable to keep the booking in database and simply change its status to 'cancel' when you cancel it via the action button or the timeline.

So I've added partial updating via the API with a new PATCH method to partially edit a booking. It is currently active for status changes.
Graphically, this translates into the disappearance of the action buttons if the booking has already been canceled, although it remains visible in the table and timeline (the style is a proposal for the moment, intended simply to graphically differentiate a canceled booking from others).

I've also added a filter to the filter_by_active method to exclude cancelled bookings.

Test plan:
1) Create a booking on a bookable item
2) Cancel it and see that it's simply deleted
3) Apply the patch and run “restart_all”.
4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
5) Try the filters in the table

Sponsored by: BibLibre

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 8 Paul Derscheid 2024-10-16 12:21:24 UTC
Created attachment 172816 [details] [review]
Bug 38175: Add tests

Sponsored by: BibLibre

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 9 Paul Derscheid 2024-10-16 12:21:27 UTC
Created attachment 172817 [details] [review]
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency

In the spirit of the current movement for more modern JS, the refactor tries to limit jQuery usage.

Test plan:
    1) Create a booking on a bookable item
    2) Cancel it and see that it's simply deleted
    3) Apply the patch and run “restart_all”.
    4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
    5) Try the filters in the table

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 10 Martin Renvoize (ashimema) 2024-10-16 16:06:36 UTC
Working on this one, just lining up the ducks for an easy push for Katrin.. I'm going to rebase it against the new dependencies I've added in.
Comment 11 Martin Renvoize (ashimema) 2024-10-17 14:09:59 UTC
Created attachment 172880 [details] [review]
Bug 38175: Improve Bookings feature with status

With the integration of the new status column for bookings, it would be preferable to keep the booking in database and simply change its status to 'cancel' when you cancel it via the action button or the timeline.

So I've added partial updating via the API with a new PATCH method to partially edit a booking. It is currently active for status changes.
Graphically, this translates into the disappearance of the action buttons if the booking has already been canceled, although it remains visible in the table and timeline (the style is a proposal for the moment, intended simply to graphically differentiate a canceled booking from others).

I've also added a filter to the filter_by_active method to exclude cancelled bookings.

Test plan:
1) Create a booking on a bookable item
2) Cancel it and see that it's simply deleted
3) Apply the patch and run “restart_all”.
4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
5) Try the filters in the table

Sponsored by: BibLibre
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize (ashimema) 2024-10-17 14:10:01 UTC
Created attachment 172881 [details] [review]
Bug 38175: Add tests

Sponsored by: BibLibre
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize (ashimema) 2024-10-17 14:10:04 UTC
Created attachment 172882 [details] [review]
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency

In the spirit of the current movement for more modern JS, the refactor tries to limit jQuery usage.

Test plan:
    1) Create a booking on a bookable item
    2) Cancel it and see that it's simply deleted
    3) Apply the patch and run “restart_all”.
    4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
    5) Try the filters in the table

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Martin Renvoize (ashimema) 2024-10-17 14:10:07 UTC
Created attachment 172883 [details] [review]
Bug 38175: (QA follow-up) Remove superflous method

If all we're doing is calling SUPER, then we don't need to wrap ;P

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 15 Martin Renvoize (ashimema) 2024-10-17 14:10:10 UTC
Created attachment 172884 [details] [review]
Bug 38175: (QA follow-up) DRY out PATCH handling

We were repeating some code for the PATCH endpoint instead of using the
existing update handling code.  This lead to two issues:

1) We weren't catching status updates on standard updates, only the
   patch.
2) We were limiting the PATCH endpoint to just status updates when it
   could happily be used for other fields too.

This patch removes the introduction of the 'edit' method from both the
REST controller and the corresponding object and moves the logic into
the store method of the object where it's easily testable.

We also DRY out the notice sending code a little for re-use.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 16 Martin Renvoize (ashimema) 2024-10-22 16:11:46 UTC
Found a missing unit test and also a bug in clash detection.. working on the follow-up now.
Comment 17 Martin Renvoize (ashimema) 2024-10-22 16:31:18 UTC
Created attachment 173172 [details] [review]
Bug 38175: Improve Bookings feature with status

With the integration of the new status column for bookings, it would be preferable to keep the booking in database and simply change its status to 'cancel' when you cancel it via the action button or the timeline.

So I've added partial updating via the API with a new PATCH method to partially edit a booking. It is currently active for status changes.
Graphically, this translates into the disappearance of the action buttons if the booking has already been canceled, although it remains visible in the table and timeline (the style is a proposal for the moment, intended simply to graphically differentiate a canceled booking from others).

I've also added a filter to the filter_by_active method to exclude cancelled bookings.

Test plan:
1) Create a booking on a bookable item
2) Cancel it and see that it's simply deleted
3) Apply the patch and run “restart_all”.
4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
5) Try the filters in the table

Sponsored by: BibLibre
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 18 Martin Renvoize (ashimema) 2024-10-22 16:31:21 UTC
Created attachment 173173 [details] [review]
Bug 38175: Add tests

Sponsored by: BibLibre
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 19 Martin Renvoize (ashimema) 2024-10-22 16:31:24 UTC
Created attachment 173174 [details] [review]
Bug 38175: (follow-up) Refactor staff interface additions to vanilla JS; adjust modules, controllers for coding guidelines and consistency

In the spirit of the current movement for more modern JS, the refactor tries to limit jQuery usage.

Test plan:
    1) Create a booking on a bookable item
    2) Cancel it and see that it's simply deleted
    3) Apply the patch and run “restart_all”.
    4) Repeat the same cancel operation and see that it's still there, albeit with a different appearance.
    5) Try the filters in the table

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 20 Martin Renvoize (ashimema) 2024-10-22 16:31:26 UTC
Created attachment 173175 [details] [review]
Bug 38175: (QA follow-up) Remove superflous method

If all we're doing is calling SUPER, then we don't need to wrap ;P

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Martin Renvoize (ashimema) 2024-10-22 16:31:29 UTC
Created attachment 173176 [details] [review]
Bug 38175: (QA follow-up) DRY out PATCH handling

We were repeating some code for the PATCH endpoint instead of using the
existing update handling code.  This lead to two issues:

1) We weren't catching status updates on standard updates, only the
   patch.
2) We were limiting the PATCH endpoint to just status updates when it
   could happily be used for other fields too.

This patch removes the introduction of the 'edit' method from both the
REST controller and the corresponding object and moves the logic into
the store method of the object where it's easily testable.

We also DRY out the notice sending code a little for re-use.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 22 Martin Renvoize (ashimema) 2024-10-22 16:31:32 UTC
Created attachment 173177 [details] [review]
Bug 38175: (QA follow-up) Ensure we handle cancelled in clash detection

We need to ensure we handle the new status tracking cancelled/completed
in our clash detection code too.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 23 Martin Renvoize (ashimema) 2024-10-22 16:31:34 UTC
Created attachment 173178 [details] [review]
Bug 38175: (QA follow-up) Unit test for filter_by_active change

We now filter out 'cancelled' and 'completed' bookings in the
filter_by_active method. We need tests for that.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 24 Martin Renvoize (ashimema) 2024-10-23 10:10:59 UTC
Created attachment 173201 [details] [review]
Bug 38175: Unit tests for assign_item_for_booking

This patch adds more comprehensive tests to the item autoassignment for
'Any item' handling in bookings.

We check for both random assignment, which was missing before now but
always intended, and that we take cancelled status into account.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 25 Martin Renvoize (ashimema) 2024-10-23 10:11:02 UTC
Created attachment 173202 [details] [review]
Bug 38175: Handle satus in item auto-assignment for bookings

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 26 Martin Renvoize (ashimema) 2024-10-23 10:11:26 UTC
Created attachment 173203 [details] [review]
Bug 38175: Handle status in item auto-assignment for bookings

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 27 Martin Renvoize (ashimema) 2024-10-23 10:25:37 UTC
*** Bug 36248 has been marked as a duplicate of this bug. ***
Comment 28 Katrin Fischer 2024-10-24 16:28:09 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 29 Martin Renvoize (ashimema) 2024-10-25 11:10:12 UTC
Created attachment 173346 [details] [review]
Bug 38175: (QA follow-up) Add cancelled handling to find_booking

We need to also exclude cancelled bookings from the find_booking routine
used at checkout.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 30 Katrin Fischer 2024-10-25 13:39:01 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 31 Martin Renvoize (ashimema) 2024-11-04 13:12:31 UTC
Created attachment 173915 [details] [review]
Bug 38175: (follow-up) Quiet warnings in tests

We weren't passing the required data into the FKConstraint exception,
this patch passes biblio_id and value as required.
Comment 32 Katrin Fischer 2024-11-07 15:31:50 UTC
Please re-set to PQA when you have a follow-up - it helps so I don't miss things.
Comment 33 Katrin Fischer 2024-11-07 15:49:30 UTC
(In reply to Katrin Fischer from comment #32)
> Please re-set to PQA when you have a follow-up - it helps so I don't miss
> things.

Looks like the follow-ups were already pushed including "Quiet warnings in tests".
Comment 34 Lucas Gass (lukeg) 2024-11-20 18:38:13 UTC
Enhancement will not be included in 24.05.x