Bug 20889: Prevent not for loan items to be checked out
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 6 Jun 2018 17:25:19 +0000 (14:25 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 8 Jun 2018 10:19:41 +0000 (10:19 +0000)
1. Item type defined at item level (item-level_itypes=1)
2. Mark an item type not for loan (itemtypes.notforloan=1)
3. Checkout an item using this item type (items.itype="BK" for instance)
=> Checkout is not blocked!

I suspect
  commit 3953fdb921d7f280ffbaca813956357aa67d42ca
  Bug 19943: Remove itemtype vs itype confusion in CanBookBeIssued
to be the root of this issue.
One occurrence of $item->{itemtype} has not been replaced.
In this case it refers to the biblioitem->{itemtype} value whereas we want to use
$item->{itype}. So this issue does not happen if items.itype==biblioitem.itemtype
(just in case you are not reproducing the problem).

Test plan:
Make sure not for loan items cannot be checked out

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Circulation.pm

index 7bd789c..6aada15 100644 (file)
@@ -917,7 +917,7 @@ sub CanBookBeIssued {
         if (C4::Context->preference('item-level_itypes')){
             # this should probably be a subroutine
             my $sth = $dbh->prepare("SELECT notforloan FROM itemtypes WHERE itemtype = ?");
-            $sth->execute($item->{'itemtype'});
+            $sth->execute($effective_itemtype);
             my $notforloan=$sth->fetchrow_hashref();
             if ($notforloan->{'notforloan'}) {
                 if (!C4::Context->preference("AllowNotForLoanOverride")) {