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

(-)a/C4/Reserves.pm (-1 / +14 lines)
Lines 1119-1124 item-level hold request. An item is available if Link Here
1119
* it is not lost AND
1119
* it is not lost AND
1120
* it is not damaged AND
1120
* it is not damaged AND
1121
* it is not withdrawn AND
1121
* it is not withdrawn AND
1122
* a waiting or in transit reserve is placed on
1122
* does not have a not for loan value > 0
1123
* does not have a not for loan value > 0
1123
1124
1124
Need to check the issuingrules onshelfholds column,
1125
Need to check the issuingrules onshelfholds column,
Lines 1135-1140 and canreservefromotherbranches. Link Here
1135
sub IsAvailableForItemLevelRequest {
1136
sub IsAvailableForItemLevelRequest {
1136
    my $item = shift;
1137
    my $item = shift;
1137
    my $borrower = shift;
1138
    my $borrower = shift;
1139
    my $flag = shift;
1138
1140
1139
    my $dbh = C4::Context->dbh;
1141
    my $dbh = C4::Context->dbh;
1140
    # must check the notforloan setting of the itemtype
1142
    # must check the notforloan setting of the itemtype
Lines 1178-1184 sub IsAvailableForItemLevelRequest { Link Here
1178
        return $any_available ? 0 : 1;
1180
        return $any_available ? 0 : 1;
1179
    }
1181
    }
1180
1182
1181
    return $item->{onloan} || GetReserveStatus($item->{itemnumber}) eq "Waiting";
1183
    if ($item->{onloan}) {
1184
        return 1;
1185
    }
1186
1187
    if (Koha::Holds->search({itemnumber => $item->{itemnumber},
1188
                             found => ['W', 'T']},
1189
                             {order_by => {-asc => 'priority'}})) {
1190
        return 1;
1191
    }
1192
1193
    return 0;
1194
    return GetReserveStatus($item->{itemnumber}) eq "Waiting";
1182
}
1195
}
1183
1196
1184
=head2 OnShelfHoldsAllowed
1197
=head2 OnShelfHoldsAllowed
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-2 / +43 lines)
Lines 7-13 use C4::Items; Link Here
7
use C4::Circulation;
7
use C4::Circulation;
8
use Koha::IssuingRule;
8
use Koha::IssuingRule;
9
9
10
use Test::More tests => 4;
10
use Test::More tests => 5;
11
11
12
use t::lib::TestBuilder;
12
use t::lib::TestBuilder;
13
13
Lines 114-118 AddIssue( $borrower2, $item2->{barcode} ); Link Here
114
$is = IsAvailableForItemLevelRequest( $item1, $borrower1);
114
$is = IsAvailableForItemLevelRequest( $item1, $borrower1);
115
is( $is, 1, "Item can be held, no items available" );
115
is( $is, 1, "Item can be held, no items available" );
116
116
117
my $biblio = $builder->build({
118
    source => 'Biblio',
119
});
120
121
my $item3 = $builder->build({
122
    source => 'Item',
123
    value => {
124
        biblionumber => $biblio->{biblionumber},
125
        itemlost     => 0,
126
        notforloan   => 0,
127
        withdrawn    => 0,
128
        damaged      => 0,
129
        onloan       => 0
130
    }
131
});
132
133
my $hold = $builder->build({
134
    source => 'Reserve',
135
    value =>{
136
        itemnumber => $item3->{itemnumber},
137
        found => 'T'
138
    }
139
});
140
141
$dbh->do("DELETE FROM issuingrules");
142
$rule = Koha::IssuingRule->new(
143
    {
144
        categorycode => '*',
145
        itemtype     => '*',
146
        branchcode   => '*',
147
        maxissueqty  => 99,
148
        issuelength  => 7,
149
        lengthunit   => 8,
150
        reservesallowed => 99,
151
        onshelfholds => 0,
152
    }
153
);
154
$rule->store();
155
156
$is = IsAvailableForItemLevelRequest( $item3, $borrower1, 'ici');
157
is( $is, 1, "Item can be held, items in transit are not available" );
158
117
# Cleanup
159
# Cleanup
118
$schema->storage->txn_rollback;
160
$schema->storage->txn_rollback;
119
- 

Return to bug 4319