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

(-)a/C4/Circulation.pm (-5 / +5 lines)
Lines 2167-2177 sub AddReturn { Link Here
2167
        $doreturn = 0;
2167
        $doreturn = 0;
2168
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
2168
        # No issue, no borrowernumber.  ONLY if $doreturn, *might* you have a $borrower later.
2169
        # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on
2169
        # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on
2170
        if (C4::Context->preference("RecordLocalUseOnReturn")) {
2170
        if ( C4::Context->preference("RecordLocalUseOnReturn") ) {
2171
           $localuse_count++;
2171
            $localuse_count++;
2172
           $item->localuse( $localuse_count )->store;
2172
            $item->localuse($localuse_count)->store;
2173
           $messages->{'LocalUse'} = 1;
2173
            $messages->{'LocalUse'} = 1;
2174
           $stat_type = 'localuse';
2174
            $stat_type = 'localuse';
2175
        }
2175
        }
2176
    }
2176
    }
2177
2177
(-)a/circ/circulation.pl (-1 / +2 lines)
Lines 373-380 if (@$barcodes && $op eq 'cud-checkout') { Link Here
373
        #increment items.localuse
373
        #increment items.localuse
374
        my $localuse_count = $item->localuse;
374
        my $localuse_count = $item->localuse;
375
        $localuse_count++;
375
        $localuse_count++;
376
        $item->localuse( $localuse_count )->store;
376
        $item->localuse($localuse_count)->store;
377
    }
377
    }
378
378
    # Fix for bug 7494: optional checkout-time fallback search for a book
379
    # Fix for bug 7494: optional checkout-time fallback search for a book
379
380
380
    if ( $issuingimpossible->{'UNKNOWN_BARCODE'}
381
    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 6290-6296 subtest 'Tests for RecordLocalUseOnReturn' => sub { Link Here
6290
6290
6291
    plan tests => 5;
6291
    plan tests => 5;
6292
6292
6293
    t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 0);
6293
    t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', 0 );
6294
    my $item = $builder->build_sample_item();
6294
    my $item = $builder->build_sample_item();
6295
6295
6296
    my $item_2 = $builder->build_sample_item(
6296
    my $item_2 = $builder->build_sample_item(
Lines 6303-6327 subtest 'Tests for RecordLocalUseOnReturn' => sub { Link Here
6303
    my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6303
    my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6304
    is_deeply(
6304
    is_deeply(
6305
        \@return,
6305
        \@return,
6306
        [ 0, { NotIssued => $item->barcode, withdrawn => 1  }, undef, {} ], "RecordLocalUSeOnReturn is off, no local use recorded");
6306
        [ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ],
6307
        "RecordLocalUSeOnReturn is off, no local use recorded"
6308
    );
6307
6309
6308
    AddReturn( $item_2->barcode, $item_2->homebranch );
6310
    AddReturn( $item_2->barcode, $item_2->homebranch );
6309
    $item_2->discard_changes; # refresh
6311
    $item_2->discard_changes;    # refresh
6310
    is( $item_2->localuse, undef , 'Without RecordLocalUseOnReturn no localuse is recorded.');
6312
    is( $item_2->localuse, undef, 'Without RecordLocalUseOnReturn no localuse is recorded.' );
6311
6313
6312
    t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 1);
6314
    t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', 1 );
6313
    my @return2 = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6315
    my @return2 = AddReturn( $item->barcode, $item->homebranch, 0, undef );
6314
    is_deeply(
6316
    is_deeply(
6315
        \@return2,
6317
        \@return2,
6316
        [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1  }, undef, {} ], "Local use is recorded");
6318
        [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1 }, undef, {} ], "Local use is recorded"
6319
    );
6317
6320
6318
    AddReturn( $item_2->barcode, $item_2->homebranch );
6321
    AddReturn( $item_2->barcode, $item_2->homebranch );
6319
    $item_2->discard_changes; # refresh
6322
    $item_2->discard_changes;    # refresh
6320
    is( $item_2->localuse, 1 , 'With RecordLocalUseOnReturn localuse is recorded.');
6323
    is( $item_2->localuse, 1, 'With RecordLocalUseOnReturn localuse is recorded.' );
6321
6324
6322
    AddReturn( $item_2->barcode, $item_2->homebranch );
6325
    AddReturn( $item_2->barcode, $item_2->homebranch );
6323
    $item_2->discard_changes; # refresh
6326
    $item_2->discard_changes;    # refresh
6324
    is( $item_2->localuse, 2 , 'With RecordLocalUseOnReturn localuse is recorded.');
6327
    is( $item_2->localuse, 2, 'With RecordLocalUseOnReturn localuse is recorded.' );
6325
};
6328
};
6326
6329
6327
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
6330
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
6328
- 

Return to bug 16122