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

(-)a/C4/Reserves.pm (-23 lines)
Lines 1148-1169 sub IsAvailableForItemLevelRequest { Link Here
1148
    }
1148
    }
1149
}
1149
}
1150
1150
1151
=head2 OnShelfHoldsAllowed
1152
1153
  OnShelfHoldsAllowed($itemtype,$borrowercategory,$branchcode);
1154
1155
Checks issuingrules, using the borrowers categorycode, the itemtype, and branchcode to see if onshelf
1156
holds are allowed, returns true if so.
1157
1158
=cut
1159
1160
sub OnShelfHoldsAllowed {
1161
    my ($item, $borrower) = @_;
1162
1163
    my $itype = _get_itype($item);
1164
    return _OnShelfHoldsAllowed($itype,$borrower->{categorycode},$item->{holdingbranch});
1165
}
1166
1167
sub _get_itype {
1151
sub _get_itype {
1168
    my $item = shift;
1152
    my $item = shift;
1169
1153
Lines 1191-1203 sub _get_itype { Link Here
1191
    return $itype;
1175
    return $itype;
1192
}
1176
}
1193
1177
1194
sub _OnShelfHoldsAllowed {
1195
    my ($itype,$borrowercategory,$branchcode) = @_;
1196
1197
    my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule({ categorycode => $borrowercategory, itemtype => $itype, branchcode => $branchcode });
1198
    return $issuing_rule ? $issuing_rule->onshelfholds : undef;
1199
}
1200
1201
=head2 AlterPriority
1178
=head2 AlterPriority
1202
1179
1203
  AlterPriority( $where, $reserve_id );
1180
  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