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

(-)a/C4/Reserves.pm (-3 / +3 lines)
Lines 562-577 sub CanItemBeReserved { Link Here
562
    }
562
    }
563
563
564
    my $circ_control_branch =
564
    my $circ_control_branch =
565
      C4::Circulation::_GetCircControlBranch( $item, $borrower );
565
      C4::Circulation::_GetCircControlBranch( $item->unblessed(), $borrower );
566
    my $branchitemrule =
566
    my $branchitemrule =
567
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->{itype} );
567
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->itype );
568
568
569
    if ( $branchitemrule->{holdallowed} == 0 ) {
569
    if ( $branchitemrule->{holdallowed} == 0 ) {
570
        return 'notReservable';
570
        return 'notReservable';
571
    }
571
    }
572
572
573
    if (   $branchitemrule->{holdallowed} == 1
573
    if (   $branchitemrule->{holdallowed} == 1
574
        && $borrower->{branchcode} ne $item->{homebranch} )
574
        && $borrower->{branchcode} ne $item->homebranch )
575
    {
575
    {
576
        return 'cannotReserveFromOtherBranches';
576
        return 'cannotReserveFromOtherBranches';
577
    }
577
    }
(-)a/t/db_dependent/Holds.t (-12 / +12 lines)
Lines 237-252 my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber) Link Here
237
  = AddItem({ homebranch => $branch_2, holdingbranch => $branch_2 } , $foreign_bibnum);
237
  = AddItem({ homebranch => $branch_2, holdingbranch => $branch_2 } , $foreign_bibnum);
238
$dbh->do('DELETE FROM issuingrules');
238
$dbh->do('DELETE FROM issuingrules');
239
$dbh->do(
239
$dbh->do(
240
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
240
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
241
      VALUES (?, ?, ?, ?)},
241
      VALUES (?, ?, ?, ?, ?)},
242
    {},
242
    {},
243
    '*', '*', '*', 25
243
    '*', '*', '*', 25, 99
244
);
244
);
245
$dbh->do(
245
$dbh->do(
246
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
246
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
247
      VALUES (?, ?, ?, ?)},
247
      VALUES (?, ?, ?, ?, ?)},
248
    {},
248
    {},
249
    '*', '*', 'CANNOT', 0
249
    '*', '*', 'CANNOT', 0, 99
250
);
250
);
251
251
252
# make sure some basic sysprefs are set
252
# make sure some basic sysprefs are set
Lines 337-343 is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the fir Link Here
337
337
338
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber);
338
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber);
339
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
339
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
340
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
340
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
341
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
341
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
342
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 );
342
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 );
343
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" );
343
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" );
Lines 353-360 AddReserve( Link Here
353
    '',
353
    '',
354
    1,
354
    1,
355
);
355
);
356
ok(
356
is(
357
    CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'tooManyReserves',
357
    CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'tooManyReserves',
358
    "cannot request item if policy that matches on item-level item type forbids it"
358
    "cannot request item if policy that matches on item-level item type forbids it"
359
);
359
);
360
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber);
360
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber);
Lines 460-469 $dbh->do('DELETE FROM biblio'); Link Here
460
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
460
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
461
461
462
$dbh->do(
462
$dbh->do(
463
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
463
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
464
      VALUES (?, ?, ?, ?)},
464
      VALUES (?, ?, ?, ?, ?)},
465
    {},
465
    {},
466
    '*', '*', 'ONLY1', 1
466
    '*', '*', 'ONLY1', 1, 99
467
);
467
);
468
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
468
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
469
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
469
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
(-)a/t/db_dependent/Reserves.t (-10 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 74;
20
use Test::More tests => 72;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 450-463 $p = C4::Reserves::CalculatePriority($bibnum, $resdate); Link Here
450
is($p, 3, 'CalculatePriority should now return priority 3');
450
is($p, 3, 'CalculatePriority should now return priority 3');
451
# End of tests for bug 8918
451
# End of tests for bug 8918
452
452
453
# Test for bug 5144
454
warning_is {
455
    $reserve_id = AddReserve('CPL',  $requesters{'CPL3'}, $bibnum,
456
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
457
           $title,      $checkitem, $found)
458
} "AddReserve: borrower $requesters{CPL3} already has a hold for biblionumber $bibnum";
459
is( $reserve_id, undef, 'Attempt to add a second reserve on a given record for the same patron fails.' );
460
461
# Tests for cancel reserves by users from OPAC.
453
# Tests for cancel reserves by users from OPAC.
462
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
454
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
463
AddReserve('CPL',  $requesters{'CPL'}, $item_bibnum,
455
AddReserve('CPL',  $requesters{'CPL'}, $item_bibnum,
464
- 

Return to bug 14695