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

(-)a/C4/Reserves.pm (-1 / +2 lines)
Lines 1343-1349 sub ItemsAnyAvailableAndNotRestricted { Link Here
1343
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1343
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1344
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1344
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1345
            || $branchitemrule->{holdallowed} == 1 && $param->{patron}->branchcode ne $i->homebranch
1345
            || $branchitemrule->{holdallowed} == 1 && $param->{patron}->branchcode ne $i->homebranch
1346
            || $branchitemrule->{holdallowed} == 3 && ! $item_library->validate_hold_sibling( { branchcode => $param->{patron}->branchcode } );
1346
            || $branchitemrule->{holdallowed} == 3 && ! $item_library->validate_hold_sibling( { branchcode => $param->{patron}->branchcode } )
1347
            || CanItemBeReserved( $param->{patron}->borrowernumber, $i->id )->{status} ne 'OK';
1347
    }
1348
    }
1348
1349
1349
    return 0;
1350
    return 0;
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-2 / +80 lines)
Lines 8-14 use C4::Items; Link Here
8
use Koha::Items;
8
use Koha::Items;
9
use Koha::CirculationRules;
9
use Koha::CirculationRules;
10
10
11
use Test::More tests => 10;
11
use Test::More tests => 11;
12
12
13
use t::lib::TestBuilder;
13
use t::lib::TestBuilder;
14
use t::lib::Mocks;
14
use t::lib::Mocks;
Lines 285-290 is( $is, 1, "Items availability: 1 item is available, 1 item held in T" ); Link Here
285
$is = IsAvailableForItemLevelRequest( $item3, $patron1);
285
$is = IsAvailableForItemLevelRequest( $item3, $patron1);
286
is( $is, 1, "Item can be held, items in transit are not available" );
286
is( $is, 1, "Item can be held, items in transit are not available" );
287
287
288
subtest 'Check holds availability with different item types' => sub {
289
    plan tests => 6;
290
291
    # Check for holds availability when different item types have different
292
    # smart rules assigned both with "if all unavailable" set,
293
    # and $itemtype rule allows holds, $itemtype2 rule disallows holds.
294
    # So, $item should be available for hold when checked out even if $item2
295
    # is not checked out, because anyway $item2 unavailable for holds by rule
296
    # (Bug 24683):
297
298
    my $biblio2       = $builder->build_sample_biblio( { itemtype => $itemtype } );
299
    my $biblionumber1 = $biblio2->biblionumber;
300
    my $item4         = $builder->build_sample_item(
301
        {   biblionumber  => $biblionumber1,
302
            itype         => $itemtype,
303
            homebranch    => $library_A,
304
            holdingbranch => $library_A
305
        }
306
    );
307
    my $item5 = $builder->build_sample_item(
308
        {   biblionumber  => $biblionumber1,
309
            itype         => $itemtype2,
310
            homebranch    => $library_A,
311
            holdingbranch => $library_A
312
        }
313
    );
314
315
    # Test hold_fulfillment_policy
316
    $dbh->do("DELETE FROM circulation_rules");
317
    Koha::CirculationRules->set_rules(
318
        {   categorycode => undef,
319
            itemtype     => $itemtype,
320
            branchcode   => undef,
321
            rules        => {
322
                issuelength      => 7,
323
                lengthunit       => 8,
324
                reservesallowed  => 99,
325
                holds_per_record => 99,
326
                onshelfholds     => 2,
327
            }
328
        }
329
    );
330
    Koha::CirculationRules->set_rules(
331
        {   categorycode => undef,
332
            itemtype     => $itemtype2,
333
            branchcode   => undef,
334
            rules        => {
335
                issuelength      => 7,
336
                lengthunit       => 8,
337
                reservesallowed  => 0,
338
                holds_per_record => 0,
339
                onshelfholds     => 2,
340
            }
341
        }
342
    );
343
344
    $is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber1, patron => $patron1 } );
345
    is( $is, 1, "Items availability: 2 items, one allowed by smart rule but not checked out, another one not allowed to be held by smart rule" );
346
347
    $is = IsAvailableForItemLevelRequest( $item4, $patron1 );
348
    is( $is, 0, "Item4 cannot be requested to hold: 2 items, Item4 available, Item5 restricted" );
349
350
    $is = IsAvailableForItemLevelRequest( $item5, $patron1 );
351
    is( $is, 0, "Item5 cannot be requested to hold: 2 items, Item4 available, Item5 restricted" );
352
353
    AddIssue( $patron2->unblessed, $item4->barcode );
354
355
    $is = ItemsAnyAvailableAndNotRestricted( { biblionumber => $biblionumber1, patron => $patron1 } );
356
    is( $is, 0, "Items availability: 2 items, one allowed by smart rule and checked out, another one not allowed to be held by smart rule" );
357
358
    $is = IsAvailableForItemLevelRequest( $item4, $patron1 );
359
    is( $is, 1, "Item4 can be requested to hold, 2 items, Item4 checked out, Item5 restricted" );
360
361
    $is = IsAvailableForItemLevelRequest( $item5, $patron1 );
362
    # Note: read IsAvailableForItemLevelRequest sub description about CanItemBeReserved/CanBookBeReserved:
363
    is( $is, 1, "Item5 can be requested to hold, 2 items, Item4 checked out, Item5 restricted" );
364
};
365
366
288
# Cleanup
367
# Cleanup
289
$schema->storage->txn_rollback;
368
$schema->storage->txn_rollback;
290
369
291
- 

Return to bug 24683