Bug 27058: Make checkout availability use all notforloan reasons
authorJoonas Kylmälä <joonas.kylmala@helsinki.fi>
Thu, 19 Nov 2020 14:55:18 +0000 (16:55 +0200)
committerFridolin Somers <fridolin.somers@biblibre.com>
Fri, 12 Mar 2021 08:05:18 +0000 (09:05 +0100)
commit8dce8789a253457d9e0c8287bbdbd418dae1af44
tree4e7165239cf8edeb404daf4358b0942bdff8efe6
parent1031e9dcdc8c40ae96cd9dd2cdd5bbb4a64e50a2
Bug 27058: Make checkout availability use all notforloan reasons

The ItemsAnyAvailableAndNotRestricted function is checking whether an
item can be checked out and it incorrectly only checks the positive
notforloan values when there can be also negative notforloan
values. If notforloan value is not 0 then it means the item cannot be
checked out. In the case of ordered items the value is negative (-1)
and thus before this change the checkout availability was reported
incorrectly.

To test:
 1) Run prove t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t
    Notice it fails
 2) Apply this patch
 3) Run prove t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t
    Notice it passes now.

To test via Koha sandbox (Alternatively):
 1) Create circ rule with If all unavailable
 2) Create new biblio
 3) Order a new item to the biblio via acquisitions and set the not
    for loan value to Ordered / -1
 4) Notice you cannot place a hold to the biblio
 5) Apply patch
 6) Notice you can now place a hold to the biblio

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 18128cc810a00a46f8d4af19bebaa4c562761456)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
C4/Reserves.pm