Bug 30697

Summary: Cannot renew when record is on hold under specific conditions
Product: Koha Reporter: Shi Yao Wang <shi-yao.wang>
Component: Hold requestsAssignee: Shi Yao Wang <shi-yao.wang>
Status: ASSIGNED --- QA Contact: Testopia <testopia>
Severity: trivial    
Priority: P5 - low CC: arthur.suzuki, caroline.cyr-la-rose, david, gmcharlt, philippe.blouin, shi-yao.wang
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 30697: Fix return value when $items_any_available is defined
Bug 30697: Fix return value when $items_any_available is defined

Description Shi Yao Wang 2022-05-05 20:41:57 UTC
The IsAvailableForItemLevelRequest subroutine returns wrong value when $items_any_available is defined
Comment 1 Shi Yao Wang 2022-05-05 20:45:45 UTC
Created attachment 134661 [details] [review]
Bug 30697: Fix return value when $items_any_available is defined

Return the value of $item_any_available when it is defined instead of
the opposite value.
Comment 2 Arthur Suzuki 2022-05-05 20:49:50 UTC
missing automated tests, and a test plan demonstrating the error and the fix.
Comment 3 Shi Yao Wang 2022-05-05 21:32:03 UTC
Created attachment 134666 [details] [review]
Bug 30697: Fix return value when $items_any_available is defined

Return the value of $item_any_available when it is defined instead of
the opposite value.

Here is a test plan to reproduce an issue created by this bug

Test plan:
1- Go to administration > system preferences >
AllowRenewalIfOtherItemsAvailable and select "Allow"
2- Go to administration > circulation and fine rules and create an
All/All rule where "on shelf holds allowed" is set to "if all unavailable"
3- Have at least 2 library branches
Go to administration > libraries > new library
to create them
4- Have 2 users, one from each library
Go to patrons > new patron
to create them
5- Have 2 items of the same record, but one item from each library
Go to catalog > create or find a record > new > new item
to create them
6- Make the first user check out the first item
7- Make the second user place a hold on the same record (even though it
is not allowd)
8- Go back to the first user's page and try to renew
9- Notice it is written "on hold" under "Renew" even though the first user should be
able to renew his item
10- Apply the patch
11- Refresh and notice it now shows the usual checkbox to renew
Comment 4 Arthur Suzuki 2022-05-06 07:29:23 UTC
Thank you for the test case!
Still missing automated tests though...
Have a look at the file t/db_dependant/Reserves.t
You may find some help in writing unit_tests in this bug too (actually, your patch may solve my problem!) : https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20985

Do you know how to run unit tests?
If you use Koha-testing-docker (ktd) this is very easy :
when in Koha source dir, within ktd (after kshell on the host), you can run this command :
prove t/db_dependant/Reserves.t

Best,