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

(-)a/C4/Reserves.pm (-3 / +3 lines)
Lines 551-566 sub CanItemBeReserved { Link Here
551
    }
551
    }
552
552
553
    my $circ_control_branch =
553
    my $circ_control_branch =
554
      C4::Circulation::_GetCircControlBranch( $item, $borrower );
554
      C4::Circulation::_GetCircControlBranch( $item->unblessed(), $borrower );
555
    my $branchitemrule =
555
    my $branchitemrule =
556
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->{itype} );
556
      C4::Circulation::GetBranchItemRule( $circ_control_branch, $item->itype );
557
557
558
    if ( $branchitemrule->{holdallowed} == 0 ) {
558
    if ( $branchitemrule->{holdallowed} == 0 ) {
559
        return 'notReservable';
559
        return 'notReservable';
560
    }
560
    }
561
561
562
    if (   $branchitemrule->{holdallowed} == 1
562
    if (   $branchitemrule->{holdallowed} == 1
563
        && $borrower->{branchcode} ne $item->{homebranch} )
563
        && $borrower->{branchcode} ne $item->homebranch )
564
    {
564
    {
565
        return 'cannotReserveFromOtherBranches';
565
        return 'cannotReserveFromOtherBranches';
566
    }
566
    }
(-)a/t/db_dependent/Holds.t (-12 / +12 lines)
Lines 216-231 my ($foreign_item_bibnum, $foreign_item_bibitemnum, $foreign_itemnumber) Link Here
216
  = AddItem({ homebranch => $branch_2, holdingbranch => $branch_2 } , $foreign_bibnum);
216
  = AddItem({ homebranch => $branch_2, holdingbranch => $branch_2 } , $foreign_bibnum);
217
$dbh->do('DELETE FROM issuingrules');
217
$dbh->do('DELETE FROM issuingrules');
218
$dbh->do(
218
$dbh->do(
219
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
219
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
220
      VALUES (?, ?, ?, ?)},
220
      VALUES (?, ?, ?, ?, ?)},
221
    {},
221
    {},
222
    '*', '*', '*', 25
222
    '*', '*', '*', 25, 99
223
);
223
);
224
$dbh->do(
224
$dbh->do(
225
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
225
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
226
      VALUES (?, ?, ?, ?)},
226
      VALUES (?, ?, ?, ?, ?)},
227
    {},
227
    {},
228
    '*', '*', 'CANNOT', 0
228
    '*', '*', 'CANNOT', 0, 99
229
);
229
);
230
230
231
# make sure some basic sysprefs are set
231
# make sure some basic sysprefs are set
Lines 316-322 is( $reserve3->{priority}, 1, "After ModReserve, the 3rd reserve becomes the fir Link Here
316
316
317
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber);
317
ModItem({ damaged => 1 }, $item_bibnum, $itemnumber);
318
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 1 );
318
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 1 );
319
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
319
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
320
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
320
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
321
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 0 );
321
C4::Context->set_preference( 'AllowHoldsOnDamagedItems', 0 );
322
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" );
322
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" );
Lines 332-339 AddReserve( Link Here
332
    '',
332
    '',
333
    1,
333
    1,
334
);
334
);
335
ok(
335
is(
336
    CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'tooManyReserves',
336
    CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'tooManyReserves',
337
    "cannot request item if policy that matches on item-level item type forbids it"
337
    "cannot request item if policy that matches on item-level item type forbids it"
338
);
338
);
339
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber);
339
ModItem({ itype => 'CAN' }, $item_bibnum, $itemnumber);
Lines 439-448 $dbh->do('DELETE FROM biblio'); Link Here
439
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
439
    = AddItem( { homebranch => $branch_1, holdingbranch => $branch_1 }, $bibnum );
440
440
441
$dbh->do(
441
$dbh->do(
442
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
442
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record)
443
      VALUES (?, ?, ?, ?)},
443
      VALUES (?, ?, ?, ?, ?)},
444
    {},
444
    {},
445
    '*', '*', 'ONLY1', 1
445
    '*', '*', 'ONLY1', 1, 99
446
);
446
);
447
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
447
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
448
    'OK', 'Patron can reserve item with hold limit of 1, no holds placed' );
448
    '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 => 73;
20
use Test::More tests => 71;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use MARC::Record;
23
use MARC::Record;
Lines 448-461 $p = C4::Reserves::CalculatePriority($bibnum, $resdate); Link Here
448
is($p, 3, 'CalculatePriority should now return priority 3');
448
is($p, 3, 'CalculatePriority should now return priority 3');
449
# End of tests for bug 8918
449
# End of tests for bug 8918
450
450
451
# Test for bug 5144
452
warning_is {
453
    $reserve_id = AddReserve('CPL',  $requesters{'CPL3'}, $bibnum,
454
           $bibitems,  $p, output_pref($resdate), $expdate, $notes,
455
           $title,      $checkitem, $found)
456
} "AddReserve: borrower $requesters{CPL3} already has a hold for biblionumber $bibnum";
457
is( $reserve_id, undef, 'Attempt to add a second reserve on a given record for the same patron fails.' );
458
459
# Tests for cancel reserves by users from OPAC.
451
# Tests for cancel reserves by users from OPAC.
460
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
452
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
461
AddReserve('CPL',  $requesters{'CPL'}, $item_bibnum,
453
AddReserve('CPL',  $requesters{'CPL'}, $item_bibnum,
462
- 

Return to bug 14695