Bug 35394

Summary: Correct the message displayed when attempting to checkout an item during it's booking period
Product: Koha Reporter: Magnus Enger <magnus>
Component: Hold requestsAssignee: Katrin Fischer <katrin.fischer>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, fridolin.somers, gmcharlt, lucas, m.de.rooy, marie.hedbom, martin.renvoize
Version: MainKeywords: Academy
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the logic and message displayed if you try to check out an item where there is a booking. Now you cannot check out an item where there is a booking, and the message displayed is: "The item is booked for another patron".
Version(s) released in:
24.05.00,23.11.06
Bug Depends on: 29002    
Bug Blocks:    
Attachments: Bug 35394: Correction to booked items logic
Bug 35394: Correction to booked items logic
Bug 35394: Correction to booked items logic
Bug 35394: Correction to booked items logic

Description Magnus Enger 2023-11-24 08:24:17 UTC
This looks a bit over-enthusiastic :-) 

$ grep -rn '!!A booking exists!!' *
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt:596:                                    <li>!!A booking exists!!</li>
Comment 1 Katrin Fischer 2024-01-06 20:23:15 UTC
Fixing the message is easy, but I have trouble coming up with a test plan to trigger it in the GUI.

The only one I see is:
Due for another patron booking by: 01/05/2024 

I have tried with a patron without force_checkouts and made sure my attempted loan was within the booking period.

I am not sure how to trigger the issuingimpossible case.
Comment 2 Martin Renvoize 2024-01-07 08:30:35 UTC
Pretty sure this was just debugging left in by mistake.
Comment 3 Martin Renvoize 2024-03-08 15:43:04 UTC
Created attachment 162973 [details] [review]
Bug 35394: Correction to booked items logic

This patch fixes the overly extreme message that was designed to appeared
when someone tried to check out a booked item to the wrong user.
However, the message never appeared due to a logic error within
CanBookBeIssued which this patch also resolved.

Test plan
1) Make an item bookable
2) Add a booking for the item to patron A from tomorrow
3) In the database, update the booking start_date to today (or wait a
   day before the next step)
4) Attempt to check the book out to patron B.
   Note that you are displayed with the new message 'The item is booked
   for another patron' and you are unable to check the item out.
Comment 4 David Nind 2024-03-08 20:43:24 UTC
Created attachment 162979 [details] [review]
Bug 35394: Correction to booked items logic

This patch fixes the overly extreme message that was designed to appeared
when someone tried to check out a booked item to the wrong user.
However, the message never appeared due to a logic error within
CanBookBeIssued which this patch also resolved.

Test plan
1) Make an item bookable
2) Add a booking for the item to patron A from tomorrow
3) In the database, update the booking start_date to today (or wait a
   day before the next step)
4) Attempt to check the book out to patron B.
   Note that you are displayed with the new message 'The item is booked
   for another patron' and you are unable to check the item out.

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2024-03-08 20:50:49 UTC
Testing notes (using KTD):

1. To make an item bookable:
   1.1 In the staff interface, go to the details page for a record with items.
   1.2 Click on the 'Items' tab.
   1.3 For an item, change 'Bookable' to 'Yes' and click on 'Update'.
   1.4 Go back to the normal tab for the record.

2. To place a booking - click on the "Place booking" button for a record.

3. SQL to update the booking start date (adjust start_date and booking_id as appropriate):
   3.1 Access the database: koha-mysql kohadev   
   3.2 SQL query: update bookings set start_date="2024-03-08 11:00:00" where booking_id=1;
Comment 6 Martin Renvoize 2024-04-17 11:57:54 UTC
Created attachment 164998 [details] [review]
Bug 35394: Correction to booked items logic

This patch fixes the overly extreme message that was designed to appeared
when someone tried to check out a booked item to the wrong user.
However, the message never appeared due to a logic error within
CanBookBeIssued which this patch also resolved.

Test plan
1) Make an item bookable
2) Add a booking for the item to patron A from tomorrow
3) In the database, update the booking start_date to today (or wait a
   day before the next step)
4) Attempt to check the book out to patron B.
   Note that you are displayed with the new message 'The item is booked
   for another patron' and you are unable to check the item out.

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Martin Renvoize 2024-04-17 11:58:28 UTC
Rebased.. this is another one in wide use in production here.
Comment 8 Nick Clemens (kidclamp) 2024-04-19 13:24:44 UTC
Created attachment 165172 [details] [review]
Bug 35394: Correction to booked items logic

This patch fixes the overly extreme message that was designed to appeared
when someone tried to check out a booked item to the wrong user.
However, the message never appeared due to a logic error within
CanBookBeIssued which this patch also resolved.

Test plan
1) Make an item bookable
2) Add a booking for the item to patron A from tomorrow
3) In the database, update the booking start_date to today (or wait a
   day before the next step)
4) Attempt to check the book out to patron B.
   Note that you are displayed with the new message 'The item is booked
   for another patron' and you are unable to check the item out.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 9 Katrin Fischer 2024-04-19 16:07:30 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 10 Fridolin Somers 2024-05-23 13:41:47 UTC
Pushed to 23.11.x for 23.11.06
Comment 11 Lucas Gass 2024-05-28 19:43:10 UTC
Missing 23.05.x dependencies, no backport.