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

(-)a/C4/Circulation.pm (-6 / +12 lines)
Lines 699-705 data is keyed in lower case! Link Here
699
699
700
=item C<$inprocess> boolean switch
700
=item C<$inprocess> boolean switch
701
701
702
=item C<$ignore_reserves> boolean switch
702
=item C<$ignore_reserves> Hashref of boolean switches
703
704
Available keys:
705
    pending - ignore pending holds
706
    waiting - ignore waiting holds
707
    processing - ignore holds in processing
708
    transferred - ignore holds in transit
703
709
704
=item C<$params> Hashref of additional parameters
710
=item C<$params> Hashref of additional parameters
705
711
Lines 1211-1217 sub CanBookBeIssued { Link Here
1211
        }
1217
        }
1212
    }
1218
    }
1213
1219
1214
    unless ( $ignore_reserves || $recall ) {
1220
    unless ($recall) {
1215
1221
1216
        # See if the item is on reserve.
1222
        # See if the item is on reserve.
1217
        my ( $restype, $res ) = C4::Reserves::CheckReserves($item_object);
1223
        my ( $restype, $res ) = C4::Reserves::CheckReserves($item_object);
Lines 1219-1225 sub CanBookBeIssued { Link Here
1219
            my $resbor = $res->{'borrowernumber'};
1225
            my $resbor = $res->{'borrowernumber'};
1220
            if ( $resbor ne $patron->borrowernumber ) {
1226
            if ( $resbor ne $patron->borrowernumber ) {
1221
                my $patron = Koha::Patrons->find($resbor);
1227
                my $patron = Koha::Patrons->find($resbor);
1222
                if ( $restype eq "Waiting" ) {
1228
                if ( $restype eq "Waiting" && !$ignore_reserves->{'waiting'} ) {
1223
1229
1224
                    # The item is on reserve and waiting, but has been
1230
                    # The item is on reserve and waiting, but has been
1225
                    # reserved by some other patron.
1231
                    # reserved by some other patron.
Lines 1231-1237 sub CanBookBeIssued { Link Here
1231
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1237
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1232
                    $needsconfirmation{'reswaitingdate'}    = $res->{'waitingdate'};
1238
                    $needsconfirmation{'reswaitingdate'}    = $res->{'waitingdate'};
1233
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1239
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1234
                } elsif ( $restype eq "Reserved" ) {
1240
                } elsif ( $restype eq "Reserved" && !$ignore_reserves->{'pending'} ) {
1235
1241
1236
                    # The item is on reserve for someone else.
1242
                    # The item is on reserve for someone else.
1237
                    $needsconfirmation{RESERVED}            = 1;
1243
                    $needsconfirmation{RESERVED}            = 1;
Lines 1242-1248 sub CanBookBeIssued { Link Here
1242
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1248
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1243
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1249
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1244
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1250
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1245
                } elsif ( $restype eq "Transferred" ) {
1251
                } elsif ( $restype eq "Transferred" && !$ignore_reserves->{'transferred'} ) {
1246
1252
1247
                    # The item is determined hold being transferred for someone else.
1253
                    # The item is determined hold being transferred for someone else.
1248
                    $needsconfirmation{TRANSFERRED}         = 1;
1254
                    $needsconfirmation{TRANSFERRED}         = 1;
Lines 1253-1259 sub CanBookBeIssued { Link Here
1253
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1259
                    $needsconfirmation{'resbranchcode'}     = $res->{branchcode};
1254
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1260
                    $needsconfirmation{'resreservedate'}    = $res->{reservedate};
1255
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1261
                    $needsconfirmation{'reserve_id'}        = $res->{reserve_id};
1256
                } elsif ( $restype eq "Processing" ) {
1262
                } elsif ( $restype eq "Processing" && !$ignore_reserves->{'processing'} ) {
1257
1263
1258
                    # The item is determined hold being processed for someone else.
1264
                    # The item is determined hold being processed for someone else.
1259
                    $needsconfirmation{PROCESSING}          = 1;
1265
                    $needsconfirmation{PROCESSING}          = 1;
(-)a/Koha/REST/V1/Checkouts.pm (-1 / +1 lines)
Lines 109-115 sub _check_availability { Link Here
109
    my ( $c, $patron, $item ) = @_;
109
    my ( $c, $patron, $item ) = @_;
110
110
111
    my $inprocess       = 0;                   # What does this do?
111
    my $inprocess       = 0;                   # What does this do?
112
    my $ignore_reserves = 0;                   # Don't ignore reserves
112
    my $ignore_reserves = undef;               # Don't ignore reserves
113
    my $params          = { item => $item };
113
    my $params          = { item => $item };
114
114
115
    my ( $impossible, $confirmation, $alerts, $messages ) = C4::Circulation::CanBookBeIssued(
115
    my ( $impossible, $confirmation, $alerts, $messages ) = C4::Circulation::CanBookBeIssued(
(-)a/t/db_dependent/Circulation.t (-7 / +65 lines)
Lines 7348-7354 subtest 'Tests for RecordLocalUseOnReturn' => sub { Link Here
7348
};
7348
};
7349
7349
7350
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
7350
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
7351
    plan tests => 4;
7351
    plan tests => 16;
7352
7352
7353
    my $homebranch    = $builder->build( { source => 'Branch' } );
7353
    my $homebranch    = $builder->build( { source => 'Branch' } );
7354
    my $holdingbranch = $builder->build( { source => 'Branch' } );
7354
    my $holdingbranch = $builder->build( { source => 'Branch' } );
Lines 7391-7416 subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub { Link Here
7391
            reservation_date => dt_from_string,
7391
            reservation_date => dt_from_string,
7392
            expiration_date  => dt_from_string,
7392
            expiration_date  => dt_from_string,
7393
            itemnumber       => $item->id,
7393
            itemnumber       => $item->id,
7394
            found            => 'W',
7395
        }
7394
        }
7396
    );
7395
    );
7397
7396
7397
    my $reserve_obj = Koha::Holds->find($reserve_id);
7398
7398
    set_userenv($holdingbranch);
7399
    set_userenv($holdingbranch);
7399
7400
7400
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, 0 );
7401
    my $ignore_reserves = {
7402
        'pending'     => 1,
7403
        'waiting'     => 1,
7404
        'processing'  => 1,
7405
        'transferred' => 1,
7406
    };
7407
7408
    # Test pending hold
7409
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7410
    is(
7411
        keys(%$error) + keys(%$alerts), 0,
7412
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7413
    );
7414
    is( exists $question->{RESERVED}, 1, 'RESERVED should be set' );
7415
7416
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7417
    is(
7418
        keys(%$error) + keys(%$alerts), 0,
7419
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7420
    );
7421
    isnt( exists $question->{RESERVED}, 1, 'RESERVED should not be set' );
7422
7423
    # Test processing hold
7424
    $reserve_obj->set_processing();
7425
7426
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7427
    is(
7428
        keys(%$error) + keys(%$alerts), 0,
7429
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7430
    );
7431
    is( exists $question->{PROCESSING}, 1, 'PROCESSING should be set' );
7432
7433
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7434
    is(
7435
        keys(%$error) + keys(%$alerts), 0,
7436
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7437
    );
7438
    isnt( exists $question->{PROCESSING}, 1, 'PROCESSING should not be set' );
7439
7440
    # Test transferred hold
7441
    $reserve_obj->set_transfer();
7442
7443
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7444
    is(
7445
        keys(%$error) + keys(%$alerts), 0,
7446
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7447
    );
7448
    is( exists $question->{TRANSFERRED}, 1, 'TRANSFERRED should be set' );
7449
7450
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7401
    is(
7451
    is(
7402
        keys(%$error) + keys(%$alerts), 0,
7452
        keys(%$error) + keys(%$alerts), 0,
7403
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7453
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7404
    );
7454
    );
7405
    is( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING is set' );
7455
    isnt( exists $question->{TRANSFERRED}, 1, 'TRANSFERRED should not be set' );
7456
7457
    # Test waiting hold
7458
    $reserve_obj->set_waiting();
7406
7459
7407
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, 1 );
7460
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7408
    is(
7461
    is(
7409
        keys(%$error) + keys(%$alerts), 0,
7462
        keys(%$error) + keys(%$alerts), 0,
7410
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7463
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7411
    );
7464
    );
7412
    isnt( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING is not set' );
7465
    is( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING should be set' );
7413
7466
7467
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7468
    is(
7469
        keys(%$error) + keys(%$alerts), 0,
7470
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7471
    );
7472
    isnt( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING should not be set' );
7414
};
7473
};
7415
7474
7416
subtest 'NoRefundOnLostFinesPaidAge' => sub {
7475
subtest 'NoRefundOnLostFinesPaidAge' => sub {
7417
- 

Return to bug 21572