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

(-)a/C4/Circulation.pm (-5 / +5 lines)
Lines 2159-2169 sub AddReturn { Link Here
2159
        $doreturn = 0;
2159
        $doreturn = 0;
2160
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
2160
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
2161
        # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on
2161
        # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on
2162
        if (C4::Context->preference("RecordLocalUseOnReturn")) {
2162
        if ( C4::Context->preference("RecordLocalUseOnReturn") ) {
2163
           $localuse_count++;
2163
            $localuse_count++;
2164
           $item->localuse( $localuse_count )->store;
2164
            $item->localuse($localuse_count)->store;
2165
           $messages->{'LocalUse'} = 1;
2165
            $messages->{'LocalUse'} = 1;
2166
           $stat_type = 'localuse';
2166
            $stat_type = 'localuse';
2167
        }
2167
        }
2168
    }
2168
    }
2169
2169
(-)a/circ/circulation.pl (-1 / +2 lines)
Lines 380-387 if (@$barcodes && $op eq 'cud-checkout') { Link Here
380
        #increment items.localuse
380
        #increment items.localuse
381
        my $localuse_count = $item->localuse;
381
        my $localuse_count = $item->localuse;
382
        $localuse_count++;
382
        $localuse_count++;
383
        $item->localuse( $localuse_count )->store;
383
        $item->localuse($localuse_count)->store;
384
    }
384
    }
385
385
    # Fix for bug 7494: optional checkout-time fallback search for a book
386
    # Fix for bug 7494: optional checkout-time fallback search for a book
386
387
387
    if ( $issuingimpossible->{'UNKNOWN_BARCODE'}
388
    if ( $issuingimpossible->{'UNKNOWN_BARCODE'}
(-)a/misc/maintenance/update_localuse_from_statistics.pl (-10 / +9 lines)
Lines 25-32 use C4::Context; Link Here
25
use Koha::Items;
25
use Koha::Items;
26
use Koha::Statistics;
26
use Koha::Statistics;
27
use Getopt::Long qw( GetOptions );
27
use Getopt::Long qw( GetOptions );
28
use Pod::Usage qw( pod2usage );
28
use Pod::Usage   qw( pod2usage );
29
30
29
31
sub usage {
30
sub usage {
32
    pod2usage( -verbose => 2 );
31
    pod2usage( -verbose => 2 );
Lines 40-59 sub update_localuse { Link Here
40
    my $items = Koha::Items->search();
39
    my $items = Koha::Items->search();
41
40
42
    # Loop through each item and update it with statistics info
41
    # Loop through each item and update it with statistics info
43
    while( my $item = $items->next ){
42
    while ( my $item = $items->next ) {
44
      my $itemnumber = $item->itemnumber;
43
        my $itemnumber = $item->itemnumber;
45
44
46
      my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count;
45
        my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count;
47
      $item->localuse( $localuse_count );
46
        $item->localuse($localuse_count);
48
      $item->store;
47
        $item->store;
49
48
50
      print "Updated item $itemnumber with localuse statistics info.\n";
49
        print "Updated item $itemnumber with localuse statistics info.\n";
51
    }
50
    }
52
}
51
}
53
52
54
my ( $help );
53
my ($help);
55
my $result = GetOptions(
54
my $result = GetOptions(
56
    'help|h'      => \$help,
55
    'help|h' => \$help,
57
);
56
);
58
57
59
usage() if $help;
58
usage() if $help;
(-)a/t/db_dependent/Circulation.t (-11 / +13 lines)
Lines 6287-6293 subtest 'Tests for RecordLocalUseOnReturn' => sub { Link Here
6287
6287
6288
    plan tests => 5;
6288
    plan tests => 5;
6289
6289
6290
    t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 0);
6290
    t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', 0 );
6291
    my $item = $builder->build_sample_item();
6291
    my $item = $builder->build_sample_item();
6292
6292
6293
    my $item_2 = $builder->build_sample_item(
6293
    my $item_2 = $builder->build_sample_item(
Lines 6300-6324 subtest 'Tests for RecordLocalUseOnReturn' => sub { Link Here
6300
    my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6300
    my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6301
    is_deeply(
6301
    is_deeply(
6302
        \@return,
6302
        \@return,
6303
        [ 0, { NotIssued => $item->barcode, withdrawn => 1  }, undef, {} ], "RecordLocalUSeOnReturn is off, no local use recorded");
6303
        [ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ],
6304
        "RecordLocalUSeOnReturn is off, no local use recorded"
6305
    );
6304
6306
6305
    AddReturn( $item_2->barcode, $item_2->homebranch );
6307
    AddReturn( $item_2->barcode, $item_2->homebranch );
6306
    $item_2->discard_changes; # refresh
6308
    $item_2->discard_changes;    # refresh
6307
    is( $item_2->localuse, undef , 'Without RecordLocalUseOnReturn no localuse is recorded.');
6309
    is( $item_2->localuse, undef, 'Without RecordLocalUseOnReturn no localuse is recorded.' );
6308
6310
6309
    t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 1);
6311
    t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', 1 );
6310
    my @return2 = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6312
    my @return2 = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6311
    is_deeply(
6313
    is_deeply(
6312
        \@return2,
6314
        \@return2,
6313
        [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1  }, undef, {} ], "Local use is recorded");
6315
        [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1 }, undef, {} ], "Local use is recorded"
6316
    );
6314
6317
6315
    AddReturn( $item_2->barcode, $item_2->homebranch );
6318
    AddReturn( $item_2->barcode, $item_2->homebranch );
6316
    $item_2->discard_changes; # refresh
6319
    $item_2->discard_changes;    # refresh
6317
    is( $item_2->localuse, 1 , 'With RecordLocalUseOnReturn localuse is recorded.');
6320
    is( $item_2->localuse, 1, 'With RecordLocalUseOnReturn localuse is recorded.' );
6318
6321
6319
    AddReturn( $item_2->barcode, $item_2->homebranch );
6322
    AddReturn( $item_2->barcode, $item_2->homebranch );
6320
    $item_2->discard_changes; # refresh
6323
    $item_2->discard_changes;    # refresh
6321
    is( $item_2->localuse, 2 , 'With RecordLocalUseOnReturn localuse is recorded.');
6324
    is( $item_2->localuse, 2, 'With RecordLocalUseOnReturn localuse is recorded.' );
6322
};
6325
};
6323
6326
6324
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
6327
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
6325
- 

Return to bug 16122