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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 2473-2479 sub AddReturn { Link Here
2473
        ccode          => $item->ccode,
2473
        ccode          => $item->ccode,
2474
        categorycode   => $categorycode,
2474
        categorycode   => $categorycode,
2475
        interface      => C4::Context->interface,
2475
        interface      => C4::Context->interface,
2476
    }) unless $localuse;
2476
    }) unless ( $localuse && $stat_type eq 'localuse' );
2477
2477
2478
    # Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then.
2478
    # Send a check-in slip. # NOTE: borrower may be undef. Do not try to send messages then.
2479
    if ( $patron ) {
2479
    if ( $patron ) {
(-)a/t/db_dependent/Circulation.t (-3 / +21 lines)
Lines 2434-2440 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2434
};
2434
};
2435
2435
2436
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
2436
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
2437
    plan tests => 11;
2437
    plan tests => 14;
2438
2438
2439
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
2439
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
2440
    my $patron_category_x = $builder->build_object(
2440
    my $patron_category_x = $builder->build_object(
Lines 2455-2466 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
2455
            }
2455
            }
2456
        }
2456
        }
2457
    );
2457
    );
2458
2458
    my $item_1 = $builder->build_sample_item(
2459
    my $item_1 = $builder->build_sample_item(
2459
        {
2460
        {
2460
            library => $library->{branchcode},
2461
            library => $library->{branchcode},
2461
        }
2462
        }
2462
    );
2463
    );
2463
2464
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->barcode );
2464
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->barcode );
2465
    is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' );
2465
    is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' );
2466
2466
Lines 2474-2479 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
2474
    is( $stat->categorycode,   $patron->categorycode,            'Recorded a categorycode' );
2474
    is( $stat->categorycode,   $patron->categorycode,            'Recorded a categorycode' );
2475
    is( $stat->location,       $item_1->location,                'Recorded a location' );
2475
    is( $stat->location,       $item_1->location,                'Recorded a location' );
2476
2476
2477
2477
    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } );
2478
    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } );
2478
    my $patron_2 = $builder->build_object(
2479
    my $patron_2 = $builder->build_object(
2479
        { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
2480
        { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } );
Lines 2486-2491 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
2486
    $item_2->discard_changes;
2487
    $item_2->discard_changes;
2487
    ok( !$item_2->onloan, "Checked out item is returned" );
2488
    ok( !$item_2->onloan, "Checked out item is returned" );
2488
2489
2490
    my $item_3 = $builder->build_sample_item( { library => $library->branchcode } );
2491
    CanBookBeIssued( $patron, $item_3->barcode );
2492
    my $stat_2 = Koha::Statistics->search( { itemnumber => $item_3->itemnumber } )->next;
2493
2494
    $item_3->discard_changes;
2495
2496
    is( $stat_2->type, 'localuse', 'Book checked out to statistical patron records a localuse' );
2497
2498
    AddIssue( $patron_2, $item_3->barcode );
2499
    $item_3->discard_changes;
2500
2501
    CanBookBeIssued( $patron, $item_3->barcode );
2502
    my $stat_3 = Koha::Statistics->search( { itemnumber => $item_3->itemnumber } )->next;
2503
2504
    my $stat_4 = Koha::Statistics->search( { itemnumber => $item_3->itemnumber } )->last;
2505
2506
    is( $stat_3->type, 'localuse', 'Book checked out to statistical patron records a localuse' );
2507
    is( $stat_4->type, 'return', 'Book checked out to statistical patron also records a return' );
2489
    # TODO There are other tests to provide here
2508
    # TODO There are other tests to provide here
2490
};
2509
};
2491
2510
2492
- 

Return to bug 35840