&CheckReserves
&CanBookBeReserved
- &CanItemBeReserved
+ &CanItemBeReserved
&CanReserveBeCanceledFromOpac
&CancelReserve
&CancelExpiredReserves
damaged, if the Item is damaged.
cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK.
tooManyReserves, if the borrower has exceeded his maximum reserve amount.
+ notReservable, if holds on this item are not allowed
=cut
return 'tooManyReserves';
}
+ my $circ_control_branch = C4::Circulation::_GetCircControlBranch($item,
+ $borrower);
+ my $branchitemrule = C4::Circulation::GetBranchItemRule($circ_control_branch,
+ $item->{itype});
+
+ if ( $branchitemrule->{holdallowed} == 0 ) {
+ return 'notReservable';
+ }
+
+ if ( $branchitemrule->{holdallowed} == 1
+ && $borrower->{branchcode} ne $item->{homebranch} )
+ {
+ return 'cannotReserveFromOtherBranches';
+ }
+
# If reservecount is ok, we check item branch if IndependentBranches is ON
# and canreservefromotherbranches is OFF
if ( C4::Context->preference('IndependentBranches')
my $branch = GetReservesControlBranch( $itemInfo, $borr );
my $policy_holdallowed = !$itemLoopIter->{already_reserved};
- if ($policy_holdallowed) {
- if (my $branchitemrule = GetBranchItemRule( $branch, $itemInfo->{'itype'} )) {
- $policy_holdallowed =
- ($branchitemrule->{'holdallowed'} == 2) ||
- ($branchitemrule->{'holdallowed'} == 1
- && $borr->{'branchcode'} eq $itemInfo->{'homebranch'});
- } else {
- $policy_holdallowed = 0; # No rule - not allowed
- }
- }
$policy_holdallowed &&=
IsAvailableForItemLevelRequest($itemInfo,$borr) &&
CanItemBeReserved($borrowernumber,$itemNum) eq 'OK';
my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo);
my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
- my $policy_holdallowed = 1;
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
- if ( $branchitemrule->{'holdallowed'} == 0 ||
- ( $branchitemrule->{'holdallowed'} == 1 &&
- $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
- $policy_holdallowed = 0;
- }
-
if (
- $policy_holdallowed
- && !$item->{cantreserve}
+ !$item->{cantreserve}
&& IsAvailableForItemLevelRequest($item, $borrowerinfo)
&& CanItemBeReserved(
$borrowerinfo->{borrowernumber}, $itemnumber
use C4::Context;
use C4::Branch;
-use Test::More tests => 38;
+use Test::More tests => 41;
use MARC::Record;
use C4::Biblio;
use C4::Items;
"cannot request item if policy that matches on bib-level item type forbids it (bug 9532)"
);
+
+# Test branch item rules
+
+$dbh->do('DELETE FROM issuingrules');
+$dbh->do(
+ q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed)
+ VALUES (?, ?, ?, ?)},
+ {},
+ '*', '*', '*', 25
+);
+$dbh->do('DELETE FROM branch_item_rules');
+$dbh->do('DELETE FROM default_branch_circ_rules');
+$dbh->do('DELETE FROM default_branch_item_rules');
+$dbh->do('DELETE FROM default_circ_rules');
+$dbh->do(q{
+ INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
+ VALUES (?, ?, ?, ?)
+}, {}, 'CPL', 'CANNOT', 0, 'homebranch');
+$dbh->do(q{
+ INSERT INTO branch_item_rules (branchcode, itemtype, holdallowed, returnbranch)
+ VALUES (?, ?, ?, ?)
+}, {}, 'CPL', 'CAN', 1, 'homebranch');
+($bibnum, $title, $bibitemnum) = create_helper_biblio('CANNOT');
+($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
+ { homebranch => 'CPL', holdingbranch => 'CPL', itype => 'CANNOT' } , $bibnum);
+is(CanItemBeReserved($borrowernumbers[0], $itemnumber), 'notReservable',
+ "CanItemBeReserved should returns 'notReservable'");
+
+($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
+ { homebranch => 'MPL', holdingbranch => 'CPL', itype => 'CAN' } , $bibnum);
+is(CanItemBeReserved($borrowernumbers[0], $itemnumber),
+ 'cannotReserveFromOtherBranches',
+ "CanItemBeReserved should returns 'cannotReserveFromOtherBranches'");
+
+($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem(
+ { homebranch => 'CPL', holdingbranch => 'CPL', itype => 'CAN' } , $bibnum);
+is(CanItemBeReserved($borrowernumbers[0], $itemnumber), 'OK',
+ "CanItemBeReserved should returns 'OK'");
+
+
# Test CancelExpiredReserves
C4::Context->set_preference('ExpireReservesMaxPickUpDelay', 1);
C4::Context->set_preference('ReservesMaxPickUpDelay', 1);