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

(-)a/C4/Circulation.pm (-2 / +9 lines)
Lines 1289-1295 sub checkHighHolds { Link Here
1289
        due_date    => undef,
1289
        due_date    => undef,
1290
    };
1290
    };
1291
1291
1292
    my $holds = Koha::Holds->search( { biblionumber => $item->{'biblionumber'} } );
1292
    # Count holds on this record, ignoring the borrowers own holds as they would be filled by the checkout
1293
    my $holds = Koha::Holds->search({
1294
        biblionumber => $item->{'biblionumber'},
1295
        borrowernumber => { '!=' => $borrower->{borrowernumber} }
1296
    });
1293
1297
1294
    if ( $holds->count() ) {
1298
    if ( $holds->count() ) {
1295
        $return_data->{outstanding} = $holds->count();
1299
        $return_data->{outstanding} = $holds->count();
Lines 1322-1328 sub checkHighHolds { Link Here
1322
            }
1326
            }
1323
1327
1324
            # Remove any items that are not holdable for this patron
1328
            # Remove any items that are not holdable for this patron
1325
            @items = grep { CanItemBeReserved( $borrower->{borrowernumber}, $_->itemnumber, undef, { ignore_found_holds => 1 } )->{status} eq 'OK' } @items;
1329
            # We need to ignore hold counts as the borrower's own hold that will be filled by the checkout
1330
            # could prevent them from placing further holds
1331
            @items = grep { CanItemBeReserved( $borrower->{borrowernumber}, $_->itemnumber, undef, { ignore_hold_counts => 1 } )->{status} eq 'OK' } @items;
1326
1332
1327
            my $items_count = scalar @items;
1333
            my $items_count = scalar @items;
1328
1334
Lines 1468-1473 sub AddIssue { Link Here
1468
            );
1474
            );
1469
        }
1475
        }
1470
        else {
1476
        else {
1477
1471
            unless ($datedue) {
1478
            unless ($datedue) {
1472
                my $itype = $item_object->effective_itemtype;
1479
                my $itype = $item_object->effective_itemtype;
1473
                $datedue = CalcDateDue( $issuedate, $itype, $branchcode, $borrower );
1480
                $datedue = CalcDateDue( $issuedate, $itype, $branchcode, $borrower );
(-)a/t/db_dependent/DecreaseLoanHighHolds.t (-11 / +6 lines)
Lines 30-36 use Koha::CirculationRules; Link Here
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
use t::lib::Mocks;
31
use t::lib::Mocks;
32
32
33
use Test::More tests => 22;
33
use Test::More tests => 23;
34
34
35
my $dbh    = C4::Context->dbh;
35
my $dbh    = C4::Context->dbh;
36
my $schema = Koha::Database->new()->schema();
36
my $schema = Koha::Database->new()->schema();
Lines 132-138 my $patron_hr = { borrowernumber => $patron->id, branchcode => $library->{branch Link Here
132
132
133
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
133
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
134
is( $data->{exceeded},        1,          "Static mode should exceed threshold" );
134
is( $data->{exceeded},        1,          "Static mode should exceed threshold" );
135
is( $data->{outstanding},     6,          "Should have 6 outstanding holds" );
135
is( $data->{outstanding},     5,          "Should have 5 outstanding holds" );
136
is( $data->{duration},        0,          "Should have duration of 0 because of specific circulation rules" );
136
is( $data->{duration},        0,          "Should have duration of 0 because of specific circulation rules" );
137
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" );
137
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" );
138
138
Lines 164-171 $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); Link Here
164
is( $data->{exceeded}, 0, "Should not exceed threshold" );
164
is( $data->{exceeded}, 0, "Should not exceed threshold" );
165
165
166
166
167
# Place 6 more holds - patrons 5,6,7,8,9,10
167
# Place 7 more holds - patrons 5,6,7,8,9,10,11
168
for my $i ( 5 .. 10 ) {
168
for my $i ( 5 .. 11 ) {
169
    my $patron = $patrons[$i];
169
    my $patron = $patrons[$i];
170
    my $hold   = Koha::Hold->new(
170
    my $hold   = Koha::Hold->new(
171
        {
171
        {
Lines 176-181 for my $i ( 5 .. 10 ) { Link Here
176
    )->store();
176
    )->store();
177
}
177
}
178
178
179
# Note in counts below, patron's own hold is not counted
180
179
# 12 holds, threshold is 1 over 10 holdable items = 11
181
# 12 holds, threshold is 1 over 10 holdable items = 11
180
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
182
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
181
is( $data->{exceeded}, 1, "Should exceed threshold of 1" );
183
is( $data->{exceeded}, 1, "Should exceed threshold of 1" );
Lines 218-229 $unholdable->store(); Link Here
218
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
220
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
219
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
221
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
220
222
221
$patron_hold->found('F')->store;
222
# 11 holds, threshold is 2 over 9 holdable items = 11
223
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr );
224
is( $data->{exceeded}, 1, "Should exceed threshold with one withdrawn item" );
225
$patron_hold->found(undef)->store;
226
227
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
223
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary');
228
224
229
my $patron_object = Koha::Patrons->find( $patron_hr->{borrowernumber} );
225
my $patron_object = Koha::Patrons->find( $patron_hr->{borrowernumber} );
230
- 

Return to bug 29102