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

(-)a/C4/Circulation.pm (-2 / +7 lines)
Lines 1066-1073 sub CanBookBeIssued { Link Here
1066
    #
1066
    #
1067
    $patron = Koha::Patrons->find( $patron->borrowernumber )
1067
    $patron = Koha::Patrons->find( $patron->borrowernumber )
1068
        ;    # FIXME Refetch just in case, to avoid regressions. But must not be needed
1068
        ;    # FIXME Refetch just in case, to avoid regressions. But must not be needed
1069
    if ( $patron->wants_check_for_previous_checkout && $patron->do_check_for_previous_checkout($item_unblessed) ) {
1069
    my $check_previous_checkout = $patron->do_check_for_previous_checkout($item_unblessed);
1070
        $needsconfirmation{PREVISSUE} = 1;
1070
    if ( $patron->wants_check_for_previous_checkout && $check_previous_checkout ) {
1071
        if ( $check_previous_checkout eq "currentlycheckedout" ) {
1072
            $needsconfirmation{CURRENTISSUE} = 1;
1073
        } else {
1074
            $needsconfirmation{PREVISSUE} = 1;
1075
        }
1071
    }
1076
    }
1072
1077
1073
    #
1078
    #
(-)a/Koha/Patron.pm (-5 / +5 lines)
Lines 865-870 sub do_check_for_previous_checkout { Link Here
865
        itemnumber     => \@item_nos,
865
        itemnumber     => \@item_nos,
866
    };
866
    };
867
867
868
    # Check current issues table
869
    my $issues = Koha::Checkouts->search($criteria);
870
    return "currentlycheckedout" if $issues->count;    # 0 || N
871
868
    my $delay = C4::Context->preference('CheckPrevCheckoutDelay') || 0;
872
    my $delay = C4::Context->preference('CheckPrevCheckoutDelay') || 0;
869
    if ($delay) {
873
    if ($delay) {
870
        my $dtf        = Koha::Database->new->schema->storage->datetime_parser;
874
        my $dtf        = Koha::Database->new->schema->storage->datetime_parser;
Lines 872-884 sub do_check_for_previous_checkout { Link Here
872
        $criteria->{'returndate'} = { '>' => $dtf->format_datetime($newer_than), };
876
        $criteria->{'returndate'} = { '>' => $dtf->format_datetime($newer_than), };
873
    }
877
    }
874
878
875
    # Check current issues table
876
    my $issues = Koha::Checkouts->search($criteria);
877
    return 1 if $issues->count;    # 0 || N
878
879
    # Check old issues table
879
    # Check old issues table
880
    my $old_issues = Koha::Old::Checkouts->search($criteria);
880
    my $old_issues = Koha::Old::Checkouts->search($criteria);
881
    return $old_issues->count;     # 0 || N
881
    return $old_issues->count;                         # 0 || N
882
}
882
}
883
883
884
=head3 is_debarred
884
=head3 is_debarred
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (+4 lines)
Lines 272-277 Link Here
272
                    <li class="needsconfirm highholds">High demand item. Loan period shortened to [% HIGHHOLDS.duration | html %] days (due [% HIGHHOLDS.returndate | $KohaDates %]). Check out anyway?</li>
272
                    <li class="needsconfirm highholds">High demand item. Loan period shortened to [% HIGHHOLDS.duration | html %] days (due [% HIGHHOLDS.returndate | $KohaDates %]). Check out anyway?</li>
273
                [% END %]
273
                [% END %]
274
274
275
                [% IF CURRENTISSUE %]
276
                    <li class="needsconfirm currentissue">Patron has this title currently checked out: <strong>[% biblio.title | html %] [% IF biblio.author %]by [% biblio.author | html %][% END %]</strong>. Check out anyway?</li>
277
                [% END %]
278
275
                [% IF PREVISSUE %]
279
                [% IF PREVISSUE %]
276
                    <li class="needsconfirm previssue">Patron has previously checked out this title: <strong>[% biblio.title | html %] [% IF biblio.author %]by [% biblio.author | html %][% END %]</strong>. Check out anyway?</li>
280
                    <li class="needsconfirm previssue">Patron has previously checked out this title: <strong>[% biblio.title | html %] [% IF biblio.author %]by [% biblio.author | html %][% END %]</strong>. Check out anyway?</li>
277
                [% END %]
281
                [% END %]
(-)a/t/db_dependent/Patron/Borrower_PrevCheckout.t (-6 / +83 lines)
Lines 8-14 use Koha::DateUtils qw( dt_from_string ); Link Here
8
use Koha::Patrons;
8
use Koha::Patrons;
9
9
10
use Test::NoWarnings;
10
use Test::NoWarnings;
11
use Test::More tests => 62;
11
use Test::More tests => 64;
12
12
13
use_ok('Koha::Patron');
13
use_ok('Koha::Patron');
14
14
Lines 315-327 my $cpvPmappings = [ Link Here
315
        msg    => "Same item, same patron [1]",
315
        msg    => "Same item, same patron [1]",
316
        item   => $item_1,
316
        item   => $item_1,
317
        patron => $patron,
317
        patron => $patron,
318
        result => 1,
318
        result => "currentlycheckedout",
319
    },
319
    },
320
    {
320
    {
321
        msg    => "Diff item, same bib, same patron [1]",
321
        msg    => "Diff item, same bib, same patron [1]",
322
        item   => $item_2,
322
        item   => $item_2,
323
        patron => $patron,
323
        patron => $patron,
324
        result => 1,
324
        result => "currentlycheckedout",
325
    },
325
    },
326
    {
326
    {
327
        msg    => "Diff item, diff bib, same patron [0]",
327
        msg    => "Diff item, diff bib, same patron [0]",
Lines 354-359 test_it( $cpvPmappings, "PostIssue" ); Link Here
354
# Return item_1 from patron:
354
# Return item_1 from patron:
355
BAIL_OUT("Return Failed") unless AddReturn( $item_1->{barcode}, $patron->{branchcode} );
355
BAIL_OUT("Return Failed") unless AddReturn( $item_1->{barcode}, $patron->{branchcode} );
356
356
357
#Since currently checked in item now return status "currentlycheckedout" we need use
358
#same test scenarions for returned item as above but without "currentlycheckedout"
359
$cpvPmappings = [
360
    {
361
        msg    => "Same item, same patron [1]",
362
        item   => $item_1,
363
        patron => $patron,
364
        result => 1,
365
    },
366
    {
367
        msg    => "Diff item, same bib, same patron [1]",
368
        item   => $item_2,
369
        patron => $patron,
370
        result => 1,
371
    },
372
    {
373
        msg    => "Diff item, diff bib, same patron [0]",
374
        item   => $item_d,
375
        patron => $patron,
376
        result => 0,
377
    },
378
    {
379
        msg    => "Same item, diff patron [0]",
380
        item   => $item_1,
381
        patron => $patron_d,
382
        result => 0,
383
    },
384
    {
385
        msg    => "Diff item, same bib, diff patron [0]",
386
        item   => $item_2,
387
        patron => $patron_d,
388
        result => 0,
389
    },
390
    {
391
        msg    => "Diff item, diff bib, diff patron [0]",
392
        item   => $item_d,
393
        patron => $patron_d,
394
        result => 0,
395
    },
396
];
397
357
# Then:
398
# Then:
358
test_it( $cpvPmappings, "PostReturn" );
399
test_it( $cpvPmappings, "PostReturn" );
359
400
Lines 364-370 test_it( $cpvPmappings, "PostReturn" ); Link Here
364
# whetherthe different combinational outcomes of the above return values in
405
# whetherthe different combinational outcomes of the above return values in
365
# CanBookBeIssued result in the approriate $needsconfirmation.
406
# CanBookBeIssued result in the approriate $needsconfirmation.
366
407
367
# We want to test:
408
# We want to test when item is currently issued to the patron:
409
# - DESCRIPTION [RETURNVALUE (0/1)]
410
# - patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout
411
#   [!$issuingimpossible,!$needsconfirmation->{CURRENTISSUE}]
412
# - patron, wants_check_for_previous_checkout, !do_check_for_previous_checkout
413
#   [!$issuingimpossible,!$needsconfirmation->{CURRENTISSUE}]
414
# - patron, !wants_check_for_previous_checkout, do_check_for_previous_checkout
415
#   [!$issuingimpossible,!$needsconfirmation->{CURRENTISSUE}]
416
# - patron, wants_check_for_previous_checkout, do_check_for_previous_checkout
417
#   [!$issuingimpossible,$needsconfirmation->{CURRENTISSUE}]
418
419
# And we also need to test when item has been previously issued to the patron:
368
# - DESCRIPTION [RETURNVALUE (0/1)]
420
# - DESCRIPTION [RETURNVALUE (0/1)]
369
# - patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout
421
# - patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout
370
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
422
#   [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}]
Lines 424-429 my $CBBI_mappings = [ Link Here
424
    },
476
    },
425
];
477
];
426
478
479
# Tests
480
map {
481
    t::lib::Mocks::mock_preference( 'checkprevcheckout', $_->{syspref} );
482
    my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $_->{item}->{barcode} );
483
    is( $needsconfirmation->{CURRENTISSUE}, $_->{result}, $_->{msg} );
484
} @{$CBBI_mappings};
485
486
# Return $prev_item from patron:
487
BAIL_OUT("Return Failed") unless AddReturn( $prev_item->{barcode}, $patron->{branchcode} );
488
489
# Mappings
490
$CBBI_mappings = [
491
    {
492
        syspref => 'hardno',
493
        item    => $prev_item,
494
        result  => undef,
495
        msg     => "patron, !wants_check_for_previous_checkout, do_check_for_previous_checkout"
496
    },
497
    {
498
        syspref => 'hardyes',
499
        item    => $prev_item,
500
        result  => 1,
501
        msg     => "patron, wants_check_for_previous_checkout, do_check_for_previous_checkout"
502
    },
503
];
504
427
# Tests
505
# Tests
428
map {
506
map {
429
    t::lib::Mocks::mock_preference( 'checkprevcheckout', $_->{syspref} );
507
    t::lib::Mocks::mock_preference( 'checkprevcheckout', $_->{syspref} );
Lines 456-462 subtest 'Check previous checkouts for serial' => sub { Link Here
456
    AddIssue( $patron, $item1->barcode );
534
    AddIssue( $patron, $item1->barcode );
457
535
458
    is(
536
    is(
459
        $patron->do_check_for_previous_checkout( $item1->unblessed ), 1,
537
        $patron->do_check_for_previous_checkout( $item1->unblessed ), "currentlycheckedout",
460
        'Check only one item if bibliographic record is serial'
538
        'Check only one item if bibliographic record is serial'
461
    );
539
    );
462
    is(
540
    is(
463
- 

Return to bug 38356