View | Details | Raw Unified | Return to bug 32702
Collapse All | Expand All

(-)a/C4/Reserves.pm (-20 / +15 lines)
Lines 436-450 sub CanItemBeReserved { Link Here
436
        }
436
        }
437
    }
437
    }
438
438
439
    # we retrieve borrowers and items informations #
440
    # item->{itype} will come for biblioitems if necessery
441
    my $borrower = $patron->unblessed;
442
439
440
    # must check the notforloan setting of the itemtype
441
    # FIXME - a lot of places in the code do this
442
    #         or something similar - need to be
443
    #         consolidated
444
    my $itemtype = $item->effective_itemtype;
445
    return { status => 'missing_itemtype' }
446
      unless defined $itemtype;
447
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
448
449
    return { status => 'notforloan' } if ( $item->notforloan > 0 || $notforloan_per_itemtype );
450
    return { status => 'itemlost' } if $item->itemlost;
451
    return { status => 'withdrawn' } if $item->withdrawn;
443
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
452
    # If an item is damaged and we don't allow holds on damaged items, we can stop right here
444
    return { status =>'damaged' }
453
    return { status =>'damaged' }
445
      if ( $item->damaged
454
      if ( $item->damaged
446
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
455
        && !C4::Context->preference('AllowHoldsOnDamagedItems') );
447
456
457
    # we retrieve borrowers information #
458
    my $borrower = $patron->unblessed;
459
448
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
460
    if( GetMarcFromKohaField('biblioitems.agerestriction') ){
449
        my $biblio = $item->biblio;
461
        my $biblio = $item->biblio;
450
        # Check for the age restriction
462
        # Check for the age restriction
Lines 1360-1382 sub IsAvailableForItemLevelRequest { Link Here
1360
    # looped outside of IsAvailableForItemLevelRequest to avoid nested loops:
1372
    # looped outside of IsAvailableForItemLevelRequest to avoid nested loops:
1361
    my $items_any_available = shift;
1373
    my $items_any_available = shift;
1362
1374
1363
    my $dbh = C4::Context->dbh;
1364
    # must check the notforloan setting of the itemtype
1365
    # FIXME - a lot of places in the code do this
1366
    #         or something similar - need to be
1367
    #         consolidated
1368
    my $itemtype = $item->effective_itemtype;
1369
    return 0
1370
      unless defined $itemtype;
1371
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
1372
1373
    return 0 if
1374
        $notforloan_per_itemtype ||
1375
        $item->itemlost        ||
1376
        $item->notforloan > 0  || # item with negative or zero notforloan value is holdable
1377
        $item->withdrawn        ||
1378
        ($item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1379
1380
    if ($pickup_branchcode) {
1375
    if ($pickup_branchcode) {
1381
        my $destination = Koha::Libraries->find($pickup_branchcode);
1376
        my $destination = Koha::Libraries->find($pickup_branchcode);
1382
        return 0 unless $destination;
1377
        return 0 unless $destination;
(-)a/t/db_dependent/Reserves.t (-7 / +1 lines)
Lines 1455-1461 $schema->storage->txn_rollback(); Link Here
1455
1455
1456
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1456
subtest 'IsAvailableForItemLevelRequest() tests' => sub {
1457
1457
1458
    plan tests => 2;
1458
    plan tests => 1;
1459
1459
1460
    $schema->storage->txn_begin;
1460
    $schema->storage->txn_begin;
1461
1461
Lines 1468-1478 subtest 'IsAvailableForItemLevelRequest() tests' => sub { Link Here
1468
1468
1469
    my $item = $builder->build_sample_item;
1469
    my $item = $builder->build_sample_item;
1470
1470
1471
    ok(
1472
        !C4::Reserves::IsAvailableForItemLevelRequest( $item, $patron ),
1473
        "Item not available for item-level hold because no effective item type"
1474
    );
1475
1476
    # Weird use case to highlight issue
1471
    # Weird use case to highlight issue
1477
    $item_type = '0';
1472
    $item_type = '0';
1478
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1473
    Koha::ItemTypes->search( { itemtype => $item_type } )->delete;
1479
- 

Return to bug 32702