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

(-)a/C4/Reserves.pm (-23 lines)
Lines 1141-1162 sub IsAvailableForItemLevelRequest { Link Here
1141
    return $item->{onloan} || GetReserveStatus($item->{itemnumber}) eq "Waiting";
1141
    return $item->{onloan} || GetReserveStatus($item->{itemnumber}) eq "Waiting";
1142
}
1142
}
1143
1143
1144
=head2 OnShelfHoldsAllowed
1145
1146
  OnShelfHoldsAllowed($itemtype,$borrowercategory,$branchcode);
1147
1148
Checks issuingrules, using the borrowers categorycode, the itemtype, and branchcode to see if onshelf
1149
holds are allowed, returns true if so.
1150
1151
=cut
1152
1153
sub OnShelfHoldsAllowed {
1154
    my ($item, $borrower) = @_;
1155
1156
    my $itype = _get_itype($item);
1157
    return _OnShelfHoldsAllowed($itype,$borrower->{categorycode},$item->{holdingbranch});
1158
}
1159
1160
sub _get_itype {
1144
sub _get_itype {
1161
    my $item = shift;
1145
    my $item = shift;
1162
1146
Lines 1184-1196 sub _get_itype { Link Here
1184
    return $itype;
1168
    return $itype;
1185
}
1169
}
1186
1170
1187
sub _OnShelfHoldsAllowed {
1188
    my ($itype,$borrowercategory,$branchcode) = @_;
1189
1190
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $borrowercategory, itemtype => $itype, branchcode => $branchcode });
1191
    return $issuing_rule ? $issuing_rule->onshelfholds : undef;
1192
}
1193
1194
=head2 AlterPriority
1171
=head2 AlterPriority
1195
1172
1196
  AlterPriority( $where, $reserve_id );
1173
  AlterPriority( $where, $reserve_id );
(-)a/t/db_dependent/Reserves.t (-26 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 58;
20
use Test::More tests => 56;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 540-569 $item = GetItem($itemnumber); Link Here
540
540
541
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a book on item level" );
541
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a book on item level" );
542
542
543
my $itype = C4::Reserves::_get_itype($item);
544
my $categorycode = $borrower->{categorycode};
545
my $holdingbranch = $item->{holdingbranch};
546
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule(
547
    {
548
        categorycode => $categorycode,
549
        itemtype     => $itype,
550
        branchcode   => $holdingbranch
551
    }
552
);
553
554
$dbh->do(
555
    "UPDATE issuingrules SET onshelfholds = 1 WHERE categorycode = ? AND itemtype= ? and branchcode = ?",
556
    undef,
557
    $issuing_rule->categorycode, $issuing_rule->itemtype, $issuing_rule->branchcode
558
);
559
ok( C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() allowed" );
560
$dbh->do(
561
    "UPDATE issuingrules SET onshelfholds = 0 WHERE categorycode = ? AND itemtype= ? and branchcode = ?",
562
    undef,
563
    $issuing_rule->categorycode, $issuing_rule->itemtype, $issuing_rule->branchcode
564
);
565
ok( !C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() disallowed" );
566
567
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
543
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
568
#   hold from A pos 1, today, no fut holds: MoveReserve should fill it
544
#   hold from A pos 1, today, no fut holds: MoveReserve should fill it
569
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
545
$dbh->do('DELETE FROM reserves', undef, ($bibnum));
570
- 

Return to bug 19301