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

(-)a/C4/Circulation.pm (-4 / +7 lines)
Lines 819-826 sub CanBookBeIssued { Link Here
819
    #
819
    #
820
    # BORROWER STATUS
820
    # BORROWER STATUS
821
    #
821
    #
822
    if ( $patron->category->category_type eq 'X' && (  $item_object->barcode  )) {
822
    if ( $patron->category->category_type eq 'X' && ( $item_object->barcode ) ) {
823
    	# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
823
824
        # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1  .
824
        C4::Stats::UpdateStats(
825
        C4::Stats::UpdateStats(
825
            {
826
            {
826
                branch         => C4::Context->userenv->{'branch'},
827
                branch         => C4::Context->userenv->{'branch'},
Lines 835-842 sub CanBookBeIssued { Link Here
835
            }
836
            }
836
        );
837
        );
837
        my $block_lost_return = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
838
        my $block_lost_return = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
838
        my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
839
        my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower );
839
            AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ) if $item_object->onloan;
840
        ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) =
841
            AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 )
842
            if $item_object->onloan;
840
        ModDateLastSeen( $item_object->itemnumber, $block_lost_return );    # FIXME Move to Koha::Item
843
        ModDateLastSeen( $item_object->itemnumber, $block_lost_return );    # FIXME Move to Koha::Item
841
        return (
844
        return (
842
            {
845
            {
(-)a/t/db_dependent/Circulation.t (-6 / +17 lines)
Lines 2479-2485 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2479
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
2479
subtest 'CanBookBeIssued + Statistic patrons "X"' => sub {
2480
    plan tests => 14;
2480
    plan tests => 14;
2481
2481
2482
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
2482
    my $library           = $builder->build_object( { class => 'Koha::Libraries' } );
2483
    my $patron_category_x = $builder->build_object(
2483
    my $patron_category_x = $builder->build_object(
2484
        {
2484
        {
2485
            class => 'Koha::Patron::Categories',
2485
            class => 'Koha::Patron::Categories',
Lines 2505-2511 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
2505
    );
2505
    );
2506
2506
2507
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->barcode );
2507
    my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->barcode );
2508
    is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' );
2508
    is(
2509
        $error->{STATS}, 1,
2510
        '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)'
2511
    );
2509
2512
2510
    my $stat = Koha::Statistics->search( { itemnumber => $item_1->itemnumber } )->next;
2513
    my $stat = Koha::Statistics->search( { itemnumber => $item_1->itemnumber } )->next;
2511
    is( $stat->branch,         C4::Context->userenv->{'branch'}, 'Recorded a branch' );
2514
    is( $stat->branch,         C4::Context->userenv->{'branch'}, 'Recorded a branch' );
Lines 2532-2546 subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { Link Here
2532
    my $item_3 = $builder->build_sample_item( { library => $library->branchcode } );
2535
    my $item_3 = $builder->build_sample_item( { library => $library->branchcode } );
2533
    CanBookBeIssued( $patron, $item_3->barcode );
2536
    CanBookBeIssued( $patron, $item_3->barcode );
2534
    $item_3->discard_changes;
2537
    $item_3->discard_changes;
2535
    is( Koha::Statistics->search( { itemnumber => $item_3->itemnumber } )->count, 1, 'Single entry recorded in the stats table' );
2538
    is(
2539
        Koha::Statistics->search( { itemnumber => $item_3->itemnumber } )->count, 1,
2540
        'Single entry recorded in the stats table'
2541
    );
2536
2542
2537
    my $item_4 = $builder->build_sample_item( { library => $library->branchcode } );
2543
    my $item_4 = $builder->build_sample_item( { library => $library->branchcode } );
2538
    AddIssue( $patron_2, $item_4->barcode );
2544
    AddIssue( $patron_2, $item_4->barcode );
2539
    $item_4->discard_changes;
2545
    $item_4->discard_changes;
2540
    is( Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 1, 'Issue should be recorded in statistics table for item 4.' );
2546
    is(
2547
        Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 1,
2548
        'Issue should be recorded in statistics table for item 4.'
2549
    );
2541
    CanBookBeIssued( $patron, $item_4->barcode );
2550
    CanBookBeIssued( $patron, $item_4->barcode );
2542
    $item_4->discard_changes;
2551
    $item_4->discard_changes;
2543
    is( Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 3, 'Issue, return, and localuse should be recorded in statistics table for item 4.' );
2552
    is(
2553
        Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 3,
2554
        'Issue, return, and localuse should be recorded in statistics table for item 4.'
2555
    );
2544
2556
2545
    # TODO There are other tests to provide here
2557
    # TODO There are other tests to provide here
2546
};
2558
};
2547
- 

Return to bug 35840