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

(-)a/C4/Circulation.pm (-10 / +10 lines)
Lines 2686-2701 sub CanBookBeRenewed { Link Here
2686
            # can be filled with available items. We can get the union of the sets simply
2686
            # can be filled with available items. We can get the union of the sets simply
2687
            # by pushing all the elements onto an array and removing the duplicates.
2687
            # by pushing all the elements onto an array and removing the duplicates.
2688
            my @reservable;
2688
            my @reservable;
2689
            my %borrowers;
2689
            my %patrons;
2690
            ITEM: foreach my $i (@itemnumbers) {
2690
            ITEM: foreach my $itemnumber (@itemnumbers) {
2691
                my $item = Koha::Items->find($i)->unblessed;
2691
                my $item = Koha::Items->find( $itemnumber );
2692
                next if IsItemOnHoldAndFound($i);
2692
                next if IsItemOnHoldAndFound( $itemnumber );
2693
                for my $b (@borrowernumbers) {
2693
                for my $borrowernumber (@borrowernumbers) {
2694
                    my $borr = $borrowers{$b} //= Koha::Patrons->find( $b )->unblessed;
2694
                    my $patron = $patrons{$borrowernumber} //= Koha::Patrons->find( $borrowernumber );
2695
                    next unless IsAvailableForItemLevelRequest($item, $borr);
2695
                    next unless IsAvailableForItemLevelRequest($item, $patron);
2696
                    next unless CanItemBeReserved($b,$i);
2696
                    next unless CanItemBeReserved($borrowernumber,$itemnumber);
2697
2697
2698
                    push @reservable, $i;
2698
                    push @reservable, $itemnumber;
2699
                    if (@reservable >= @borrowernumbers) {
2699
                    if (@reservable >= @borrowernumbers) {
2700
                        $resfound = 0;
2700
                        $resfound = 0;
2701
                        last ITEM;
2701
                        last ITEM;
(-)a/C4/ILSDI/Services.pm (-1 / +1 lines)
Lines 562-568 sub GetServices { Link Here
562
    my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber );
562
    my $canbookbereserved = CanBookBeReserved( $borrower, $biblionumber );
563
    if ($canbookbereserved->{status} eq 'OK') {
563
    if ($canbookbereserved->{status} eq 'OK') {
564
        push @availablefor, 'title level hold';
564
        push @availablefor, 'title level hold';
565
        my $canitembereserved = IsAvailableForItemLevelRequest($item->unblessed, $borrower);
565
        my $canitembereserved = IsAvailableForItemLevelRequest($item, $patron);
566
        if ($canitembereserved) {
566
        if ($canitembereserved) {
567
            push @availablefor, 'item level hold';
567
            push @availablefor, 'item level hold';
568
        }
568
        }
(-)a/C4/Reserves.pm (-16 / +12 lines)
Lines 1163-1208 and canreservefromotherbranches. Link Here
1163
=cut
1163
=cut
1164
1164
1165
sub IsAvailableForItemLevelRequest {
1165
sub IsAvailableForItemLevelRequest {
1166
    my $item = shift;
1166
    my ( $item, $patron, $pickup_branchcode ) = @_;
1167
    my $borrower = shift;
1168
    my $pickup_branchcode = shift;
1169
1167
1170
    my $dbh = C4::Context->dbh;
1168
    my $dbh = C4::Context->dbh;
1171
    # must check the notforloan setting of the itemtype
1169
    # must check the notforloan setting of the itemtype
1172
    # FIXME - a lot of places in the code do this
1170
    # FIXME - a lot of places in the code do this
1173
    #         or something similar - need to be
1171
    #         or something similar - need to be
1174
    #         consolidated
1172
    #         consolidated
1175
    my $patron = Koha::Patrons->find( $borrower->{borrowernumber} );
1173
    my $itemtype = $item->effective_itemtype;
1176
    my $item_object = Koha::Items->find( $item->{itemnumber } );
1177
    my $itemtype = $item_object->effective_itemtype;
1178
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
1174
    my $notforloan_per_itemtype = Koha::ItemTypes->find($itemtype)->notforloan;
1179
1175
1180
    return 0 if
1176
    return 0 if
1181
        $notforloan_per_itemtype ||
1177
        $notforloan_per_itemtype ||
1182
        $item->{itemlost}        ||
1178
        $item->itemlost        ||
1183
        $item->{notforloan} > 0  ||
1179
        $item->notforloan > 0  ||
1184
        $item->{withdrawn}        ||
1180
        $item->withdrawn        ||
1185
        ($item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1181
        ($item->damaged && !C4::Context->preference('AllowHoldsOnDamagedItems'));
1186
1182
1187
    my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item_object, patron => $patron } );
1183
    my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } );
1188
1184
1189
    if ($pickup_branchcode) {
1185
    if ($pickup_branchcode) {
1190
        my $destination = Koha::Libraries->find($pickup_branchcode);
1186
        my $destination = Koha::Libraries->find($pickup_branchcode);
1191
        return 0 unless $destination;
1187
        return 0 unless $destination;
1192
        return 0 unless $destination->pickup_location;
1188
        return 0 unless $destination->pickup_location;
1193
        return 0 unless $item_object->can_be_transferred( { to => $destination } );
1189
        return 0 unless $item->can_be_transferred( { to => $destination } );
1194
    }
1190
    }
1195
1191
1196
    if ( $on_shelf_holds == 1 ) {
1192
    if ( $on_shelf_holds == 1 ) {
1197
        return 1;
1193
        return 1;
1198
    } elsif ( $on_shelf_holds == 2 ) {
1194
    } elsif ( $on_shelf_holds == 2 ) {
1199
        my @items =
1195
        my @items =
1200
          Koha::Items->search( { biblionumber => $item->{biblionumber} } );
1196
          Koha::Items->search( { biblionumber => $item->biblionumber } );
1201
1197
1202
        my $any_available = 0;
1198
        my $any_available = 0;
1203
1199
1204
        foreach my $i (@items) {
1200
        foreach my $i (@items) {
1205
            my $reserves_control_branch = GetReservesControlBranch( $i->unblessed(), $borrower );
1201
            my $reserves_control_branch = GetReservesControlBranch( $i->unblessed(), $patron->unblessed );
1206
            my $branchitemrule = C4::Circulation::GetBranchItemRule( $reserves_control_branch, $i->itype );
1202
            my $branchitemrule = C4::Circulation::GetBranchItemRule( $reserves_control_branch, $i->itype );
1207
1203
1208
            $any_available = 1
1204
            $any_available = 1
Lines 1214-1225 sub IsAvailableForItemLevelRequest { Link Here
1214
              || ( $i->damaged
1210
              || ( $i->damaged
1215
                && !C4::Context->preference('AllowHoldsOnDamagedItems') )
1211
                && !C4::Context->preference('AllowHoldsOnDamagedItems') )
1216
              || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1212
              || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1217
              || $branchitemrule->{holdallowed} == 1 && $borrower->{branchcode} ne $i->homebranch;
1213
              || $branchitemrule->{holdallowed} == 1 && $patron->branchcode ne $i->homebranch;
1218
        }
1214
        }
1219
1215
1220
        return $any_available ? 0 : 1;
1216
        return $any_available ? 0 : 1;
1221
    } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1217
    } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1222
        return $item->{onloan} || IsItemOnHoldAndFound( $item->{itemnumber} );
1218
        return $item->onloan || IsItemOnHoldAndFound( $item->itemnumber );
1223
    }
1219
    }
1224
}
1220
}
1225
1221
(-)a/opac/opac-reserve.pl (-1 / +1 lines)
Lines 542-548 foreach my $biblioNum (@biblionumbers) { Link Here
542
542
543
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
543
        my $policy_holdallowed = !$itemLoopIter->{already_reserved};
544
        $policy_holdallowed &&=
544
        $policy_holdallowed &&=
545
            IsAvailableForItemLevelRequest($itemInfo,$patron_unblessed) &&
545
            IsAvailableForItemLevelRequest($item, $patron) &&
546
            CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
546
            CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
547
547
548
        if ($policy_holdallowed) {
548
        if ($policy_holdallowed) {
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 497-503 foreach my $biblionumber (@biblionumbers) { Link Here
497
                if (
497
                if (
498
                       !$item->{cantreserve}
498
                       !$item->{cantreserve}
499
                    && !$exceeded_maxreserves
499
                    && !$exceeded_maxreserves
500
                    && IsAvailableForItemLevelRequest($item, $patron_unblessed)
500
                    && IsAvailableForItemLevelRequest($item_object, $patron)
501
                    && $can_item_be_reserved->{status} eq 'OK'
501
                    && $can_item_be_reserved->{status} eq 'OK'
502
                  )
502
                  )
503
                {
503
                {
(-)a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t (-35 / +27 lines)
Lines 36-67 my $itemtype = $builder->build({ Link Here
36
t::lib::Mocks::mock_userenv({ branchcode => $library1->{branchcode} });
36
t::lib::Mocks::mock_userenv({ branchcode => $library1->{branchcode} });
37
37
38
38
39
my $borrower1 = $builder->build({
39
my $patron1 = $builder->build_object({
40
    source => 'Borrower',
40
    class => 'Koha::Patrons',
41
    value => {
41
    value => {
42
        branchcode => $library1->{branchcode},
42
        branchcode => $library1->{branchcode},
43
        dateexpiry => '3000-01-01',
43
        dateexpiry => '3000-01-01',
44
    }
44
    }
45
});
45
});
46
my $borrower1 = $patron1->unblessed;
46
47
47
my $borrower2 = $builder->build({
48
my $patron2 = $builder->build_object({
48
    source => 'Borrower',
49
    class => 'Koha::Patrons',
49
    value => {
50
    value => {
50
        branchcode => $library1->{branchcode},
51
        branchcode => $library1->{branchcode},
51
        dateexpiry => '3000-01-01',
52
        dateexpiry => '3000-01-01',
52
    }
53
    }
53
});
54
});
54
55
55
my $borrower3 = $builder->build({
56
my $patron3 = $builder->build_object({
56
    source => 'Borrower',
57
    class => 'Koha::Patrons',
57
    value => {
58
    value => {
58
        branchcode => $library2->{branchcode},
59
        branchcode => $library2->{branchcode},
59
        dateexpiry => '3000-01-01',
60
        dateexpiry => '3000-01-01',
60
    }
61
    }
61
});
62
});
62
63
63
my $borrowernumber1 = $borrower1->{borrowernumber};
64
my $borrowernumber2 = $borrower2->{borrowernumber};
65
my $library_A = $library1->{branchcode};
64
my $library_A = $library1->{branchcode};
66
my $library_B = $library2->{branchcode};
65
my $library_B = $library2->{branchcode};
67
66
Lines 72-89 my $item1 = $builder->build_sample_item({ Link Here
72
    itype=>$itemtype,
71
    itype=>$itemtype,
73
    homebranch => $library_A,
72
    homebranch => $library_A,
74
    holdingbranch => $library_A
73
    holdingbranch => $library_A
75
})->unblessed;
74
});
76
my $item2  = $builder->build_sample_item({
75
my $item2  = $builder->build_sample_item({
77
    biblionumber=>$biblionumber,
76
    biblionumber=>$biblionumber,
78
    itype=>$itemtype,
77
    itype=>$itemtype,
79
    homebranch => $library_A,
78
    homebranch => $library_A,
80
    holdingbranch => $library_A
79
    holdingbranch => $library_A
81
})->unblessed;
80
});
82
81
83
# Test hold_fulfillment_policy
82
# Test hold_fulfillment_policy
84
85
86
87
my $rule = Koha::IssuingRule->new(
83
my $rule = Koha::IssuingRule->new(
88
    {
84
    {
89
        categorycode => '*',
85
        categorycode => '*',
Lines 97-116 my $rule = Koha::IssuingRule->new( Link Here
97
);
93
);
98
$rule->store();
94
$rule->store();
99
95
100
my $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
96
my $is = IsAvailableForItemLevelRequest( $item1, $patron1);
101
is( $is, 0, "Item cannot be held, 2 items available" );
97
is( $is, 0, "Item cannot be held, 2 items available" );
102
98
103
my $issue1 = AddIssue( $borrower2, $item1->{barcode} );
99
my $issue1 = AddIssue( $patron2->unblessed, $item1->barcode );
104
100
105
$is = IsAvailableForItemLevelRequest( $item1, $borrower1);
101
$is = IsAvailableForItemLevelRequest( $item1, $patron1);
106
is( $is, 0, "Item cannot be held, 1 item available" );
102
is( $is, 0, "Item cannot be held, 1 item available" );
107
103
108
AddIssue( $borrower2, $item2->{barcode} );
104
AddIssue( $patron2->unblessed, $item2->barcode );
109
105
110
$is = IsAvailableForItemLevelRequest( $item1, $borrower1);
106
$is = IsAvailableForItemLevelRequest( $item1, $patron1);
111
is( $is, 1, "Item can be held, no items available" );
107
is( $is, 1, "Item can be held, no items available" );
112
108
113
AddReturn( $item1->{barcode} );
109
AddReturn( $item1->barcode );
114
110
115
{ # Remove the issue for the first patron, and modify the branch for item1
111
{ # Remove the issue for the first patron, and modify the branch for item1
116
    subtest 'IsAvailableForItemLevelRequest behaviours depending on ReservesControlBranch + holdallowed' => sub {
112
    subtest 'IsAvailableForItemLevelRequest behaviours depending on ReservesControlBranch + holdallowed' => sub {
Lines 125-133 AddReturn( $item1->{barcode} ); Link Here
125
        subtest 'Item is available at a different library' => sub {
121
        subtest 'Item is available at a different library' => sub {
126
            plan tests => 7;
122
            plan tests => 7;
127
123
128
            $item1 = Koha::Items->find( $item1->{itemnumber} );
129
            $item1->set({homebranch => $library_B, holdingbranch => $library_B })->store;
124
            $item1->set({homebranch => $library_B, holdingbranch => $library_B })->store;
130
            $item1 = $item1->unblessed;
131
            #Scenario is:
125
            #Scenario is:
132
            #One shelf holds is 'If all unavailable'/2
126
            #One shelf holds is 'If all unavailable'/2
133
            #Item 1 homebranch library B is available
127
            #Item 1 homebranch library B is available
Lines 139-159 AddReturn( $item1->{barcode} ); Link Here
139
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
133
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
140
134
141
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
135
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
142
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
136
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
143
                is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" );
137
                is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" );
144
                $is = IsAvailableForItemLevelRequest( $item1, $borrower2);
138
                $is = IsAvailableForItemLevelRequest( $item1, $patron2);
145
                is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at home library, holdable = one available => the hold is not allowed at item level" );
139
                is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at home library, holdable = one available => the hold is not allowed at item level" );
146
                $sth_insert_branch_rule->execute( $library_B, $hold_allowed_from_any_libraries );
140
                $sth_insert_branch_rule->execute( $library_B, $hold_allowed_from_any_libraries );
147
                #Adding a rule for the item's home library affects the availability for a borrower from another library because ReservesControlBranch is set to ItemHomeLibrary
141
                #Adding a rule for the item's home library affects the availability for a borrower from another library because ReservesControlBranch is set to ItemHomeLibrary
148
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
142
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
149
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" );
143
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" );
150
144
151
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
145
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
152
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
146
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
153
                is( $is, 1, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" );
147
                is( $is, 1, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" );
154
                #Adding a rule for the patron's home library affects the availability for an item from another library because ReservesControlBranch is set to PatronLibrary
148
                #Adding a rule for the patron's home library affects the availability for an item from another library because ReservesControlBranch is set to PatronLibrary
155
                $sth_insert_branch_rule->execute( $library_A, $hold_allowed_from_any_libraries );
149
                $sth_insert_branch_rule->execute( $library_A, $hold_allowed_from_any_libraries );
156
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
150
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
157
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" );
151
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, holdable = one available => the hold is not allowed at item level" );
158
            }
152
            }
159
153
Lines 162-172 AddReturn( $item1->{barcode} ); Link Here
162
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
156
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
163
157
164
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
158
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
165
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
159
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
166
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" );
160
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" );
167
161
168
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
162
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
169
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
163
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
170
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" );
164
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" );
171
            }
165
            }
172
        };
166
        };
Lines 174-182 AddReturn( $item1->{barcode} ); Link Here
174
        subtest 'Item is available at the same library' => sub {
168
        subtest 'Item is available at the same library' => sub {
175
            plan tests => 4;
169
            plan tests => 4;
176
170
177
            $item1 = Koha::Items->find( $item1->{itemnumber} );
178
            $item1->set({homebranch => $library_A, holdingbranch => $library_A })->store;
171
            $item1->set({homebranch => $library_A, holdingbranch => $library_A })->store;
179
            $item1 = $item1->unblessed;
180
            #Scenario is:
172
            #Scenario is:
181
            #One shelf holds is 'If all unavailable'/2
173
            #One shelf holds is 'If all unavailable'/2
182
            #Item 1 homebranch library A is available
174
            #Item 1 homebranch library A is available
Lines 190-200 AddReturn( $item1->{barcode} ); Link Here
190
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
182
                $sth_insert_rule->execute( $hold_allowed_from_home_library );
191
183
192
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
184
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
193
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
185
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
194
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library, holdable = 1 available  => the hold is not allowed at item level" );
186
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library, holdable = 1 available  => the hold is not allowed at item level" );
195
187
196
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
188
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
197
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
189
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
198
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at the same library, holdable = 1 available  => the hold is not allowed at item level" );
190
                is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at the same library, holdable = 1 available  => the hold is not allowed at item level" );
199
            }
191
            }
200
192
Lines 203-213 AddReturn( $item1->{barcode} ); Link Here
203
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
195
                $sth_insert_rule->execute( $hold_allowed_from_any_libraries );
204
196
205
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
197
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary');
206
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
198
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
207
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library, holdable = 1 available => the hold is not allowed at item level" );
199
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library, holdable = 1 available => the hold is not allowed at item level" );
208
200
209
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
201
                t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary');
210
                $is = IsAvailableForItemLevelRequest( $item1, $borrower1);
202
                $is = IsAvailableForItemLevelRequest( $item1, $patron1);
211
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the same library, holdable = 1 available  => the hold is not allowed at item level" );
203
                is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the same library, holdable = 1 available  => the hold is not allowed at item level" );
212
            }
204
            }
213
        };
205
        };
Lines 241-247 $rule = Koha::IssuingRule->new( Link Here
241
);
233
);
242
$rule->store();
234
$rule->store();
243
235
244
$is = IsAvailableForItemLevelRequest( $item3->unblessed, $borrower1);
236
$is = IsAvailableForItemLevelRequest( $item3, $patron1);
245
is( $is, 1, "Item can be held, items in transit are not available" );
237
is( $is, 1, "Item can be held, items in transit are not available" );
246
238
247
# Cleanup
239
# Cleanup
(-)a/t/db_dependent/Reserves.t (-11 / +10 lines)
Lines 109-115 my %data = ( Link Here
109
);
109
);
110
Koha::Patron::Categories->find($category_1)->set({ enrolmentfee => 0})->store;
110
Koha::Patron::Categories->find($category_1)->set({ enrolmentfee => 0})->store;
111
my $borrowernumber = Koha::Patron->new(\%data)->store->borrowernumber;
111
my $borrowernumber = Koha::Patron->new(\%data)->store->borrowernumber;
112
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
112
my $patron = Koha::Patrons->find( $borrowernumber );
113
my $borrower = $patron->unblessed;
113
my $biblionumber   = $bibnum;
114
my $biblionumber   = $bibnum;
114
my $barcode        = $testbarcode;
115
my $barcode        = $testbarcode;
115
116
Lines 520-541 is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblio_with_no_item->{bibl Link Here
520
####### EO Bug 13113 <<<
521
####### EO Bug 13113 <<<
521
       ####
522
       ####
522
523
523
$item = Koha::Items->find($itemnumber)->unblessed;
524
$item = Koha::Items->find($itemnumber);
524
525
525
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower), "Reserving a book on item level" );
526
ok( C4::Reserves::IsAvailableForItemLevelRequest($item, $patron), "Reserving a book on item level" );
526
527
527
my $pickup_branch = $builder->build({ source => 'Branch' })->{ branchcode };
528
my $pickup_branch = $builder->build({ source => 'Branch' })->{ branchcode };
528
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits',  '1' );
529
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits',  '1' );
529
t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' );
530
t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' );
530
my ($item_object) = Koha::Biblios->find($biblionumber)->items->as_list;
531
my $limit = Koha::Item::Transfer::Limit->new(
531
my $limit = Koha::Item::Transfer::Limit->new(
532
    {
532
    {
533
        toBranch   => $pickup_branch,
533
        toBranch   => $pickup_branch,
534
        fromBranch => $item_object->holdingbranch,
534
        fromBranch => $item->holdingbranch,
535
        itemtype   => $item_object->effective_itemtype,
535
        itemtype   => $item->effective_itemtype,
536
    }
536
    }
537
)->store();
537
)->store();
538
is( C4::Reserves::IsAvailableForItemLevelRequest($item, $borrower, $pickup_branch), 0, "Item level request not available due to transfer limit" );
538
is( C4::Reserves::IsAvailableForItemLevelRequest($item, $patron, $pickup_branch), 0, "Item level request not available due to transfer limit" );
539
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits',  '0' );
539
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits',  '0' );
540
540
541
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
541
# tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526)
Lines 643-652 subtest '_koha_notify_reserve() tests' => sub { Link Here
643
        })->{borrowernumber};
643
        })->{borrowernumber};
644
644
645
    C4::Reserves::AddReserve(
645
    C4::Reserves::AddReserve(
646
        $item->{homebranch}, $hold_borrower,
646
        $item->homebranch, $hold_borrower,
647
        $item->{biblionumber} );
647
        $item->biblionumber );
648
648
649
    ModReserveAffect($item->{itemnumber}, $hold_borrower, 0);
649
    ModReserveAffect($item->itemnumber, $hold_borrower, 0);
650
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
650
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
651
            letter_code     => 'HOLD',
651
            letter_code     => 'HOLD',
652
            message_transport_type => 'sms',
652
            message_transport_type => 'sms',
653
- 

Return to bug 19302