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 7223-7229 subtest 'Tests for RecordLocalUseOnReturn' => sub { Link Here
7223
};
7223
};
7224
7224
7225
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
7225
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
7226
    plan tests => 4;
7226
    plan tests => 16;
7227
7227
7228
    my $homebranch    = $builder->build( { source => 'Branch' } );
7228
    my $homebranch    = $builder->build( { source => 'Branch' } );
7229
    my $holdingbranch = $builder->build( { source => 'Branch' } );
7229
    my $holdingbranch = $builder->build( { source => 'Branch' } );
Lines 7266-7291 subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub { Link Here
7266
            reservation_date => dt_from_string,
7266
            reservation_date => dt_from_string,
7267
            expiration_date  => dt_from_string,
7267
            expiration_date  => dt_from_string,
7268
            itemnumber       => $item->id,
7268
            itemnumber       => $item->id,
7269
            found            => 'W',
7270
        }
7269
        }
7271
    );
7270
    );
7272
7271
7272
    my $reserve_obj = Koha::Holds->find($reserve_id);
7273
7273
    set_userenv($holdingbranch);
7274
    set_userenv($holdingbranch);
7274
7275
7275
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, 0 );
7276
    my $ignore_reserves = {
7277
        'pending'     => 1,
7278
        'waiting'     => 1,
7279
        'processing'  => 1,
7280
        'transferred' => 1,
7281
    };
7282
7283
    # Test pending hold
7284
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7285
    is(
7286
        keys(%$error) + keys(%$alerts), 0,
7287
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7288
    );
7289
    is( exists $question->{RESERVED}, 1, 'RESERVED should be set' );
7290
7291
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7292
    is(
7293
        keys(%$error) + keys(%$alerts), 0,
7294
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7295
    );
7296
    isnt( exists $question->{RESERVED}, 1, 'RESERVED should not be set' );
7297
7298
    # Test processing hold
7299
    $reserve_obj->set_processing();
7300
7301
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7302
    is(
7303
        keys(%$error) + keys(%$alerts), 0,
7304
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7305
    );
7306
    is( exists $question->{PROCESSING}, 1, 'PROCESSING should be set' );
7307
7308
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7309
    is(
7310
        keys(%$error) + keys(%$alerts), 0,
7311
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7312
    );
7313
    isnt( exists $question->{PROCESSING}, 1, 'PROCESSING should not be set' );
7314
7315
    # Test transferred hold
7316
    $reserve_obj->set_transfer();
7317
7318
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7319
    is(
7320
        keys(%$error) + keys(%$alerts), 0,
7321
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7322
    );
7323
    is( exists $question->{TRANSFERRED}, 1, 'TRANSFERRED should be set' );
7324
7325
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7276
    is(
7326
    is(
7277
        keys(%$error) + keys(%$alerts), 0,
7327
        keys(%$error) + keys(%$alerts), 0,
7278
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7328
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7279
    );
7329
    );
7280
    is( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING is set' );
7330
    isnt( exists $question->{TRANSFERRED}, 1, 'TRANSFERRED should not be set' );
7331
7332
    # Test waiting hold
7333
    $reserve_obj->set_waiting();
7281
7334
7282
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, 1 );
7335
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, undef );
7283
    is(
7336
    is(
7284
        keys(%$error) + keys(%$alerts), 0,
7337
        keys(%$error) + keys(%$alerts), 0,
7285
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7338
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7286
    );
7339
    );
7287
    isnt( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING is not set' );
7340
    is( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING should be set' );
7288
7341
7342
    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode, undef, undef, $ignore_reserves );
7343
    is(
7344
        keys(%$error) + keys(%$alerts), 0,
7345
        'There should not be any errors or alerts (impossible)' . str( $error, $question, $alerts )
7346
    );
7347
    isnt( exists $question->{RESERVE_WAITING}, 1, 'RESERVE_WAITING should not be set' );
7289
};
7348
};
7290
7349
7291
subtest 'NoRefundOnLostFinesPaidAge' => sub {
7350
subtest 'NoRefundOnLostFinesPaidAge' => sub {
7292
- 

Return to bug 21572