@@ -, +, @@ --- C4/Circulation.pm | 10 ++++---- circ/circulation.pl | 3 ++- .../update_localuse_from_statistics.pl | 19 ++++++++------- t/db_dependent/Circulation.t | 23 +++++++++++-------- 4 files changed, 29 insertions(+), 26 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -2167,11 +2167,11 @@ sub AddReturn { $doreturn = 0; # No issue, no borrowernumber. ONLY if $doreturn, *might* you have a $borrower later. # Record this as a local use, instead of a return, if the RecordLocalUseOnReturn is on - if (C4::Context->preference("RecordLocalUseOnReturn")) { - $localuse_count++; - $item->localuse( $localuse_count )->store; - $messages->{'LocalUse'} = 1; - $stat_type = 'localuse'; + if ( C4::Context->preference("RecordLocalUseOnReturn") ) { + $localuse_count++; + $item->localuse($localuse_count)->store; + $messages->{'LocalUse'} = 1; + $stat_type = 'localuse'; } } --- a/circ/circulation.pl +++ a/circ/circulation.pl @@ -373,8 +373,9 @@ if (@$barcodes && $op eq 'cud-checkout') { #increment items.localuse my $localuse_count = $item->localuse; $localuse_count++; - $item->localuse( $localuse_count )->store; + $item->localuse($localuse_count)->store; } + # Fix for bug 7494: optional checkout-time fallback search for a book if ( $issuingimpossible->{'UNKNOWN_BARCODE'} --- a/misc/maintenance/update_localuse_from_statistics.pl +++ a/misc/maintenance/update_localuse_from_statistics.pl @@ -25,8 +25,7 @@ use C4::Context; use Koha::Items; use Koha::Statistics; use Getopt::Long qw( GetOptions ); -use Pod::Usage qw( pod2usage ); - +use Pod::Usage qw( pod2usage ); sub usage { pod2usage( -verbose => 2 ); @@ -40,20 +39,20 @@ sub update_localuse { my $items = Koha::Items->search(); # Loop through each item and update it with statistics info - while( my $item = $items->next ){ - my $itemnumber = $item->itemnumber; + while ( my $item = $items->next ) { + my $itemnumber = $item->itemnumber; - my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count; - $item->localuse( $localuse_count ); - $item->store; + my $localuse_count = Koha::Statistics->search( { itemnumber => $itemnumber, type => 'localuse' } )->count; + $item->localuse($localuse_count); + $item->store; - print "Updated item $itemnumber with localuse statistics info.\n"; + print "Updated item $itemnumber with localuse statistics info.\n"; } } -my ( $help ); +my ($help); my $result = GetOptions( - 'help|h' => \$help, + 'help|h' => \$help, ); usage() if $help; --- a/t/db_dependent/Circulation.t +++ a/t/db_dependent/Circulation.t @@ -6290,7 +6290,7 @@ subtest 'Tests for RecordLocalUseOnReturn' => sub { plan tests => 5; - t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 0); + t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', 0 ); my $item = $builder->build_sample_item(); my $item_2 = $builder->build_sample_item( @@ -6303,25 +6303,28 @@ subtest 'Tests for RecordLocalUseOnReturn' => sub { my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef ); is_deeply( \@return, - [ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ], "RecordLocalUSeOnReturn is off, no local use recorded"); + [ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ], + "RecordLocalUSeOnReturn is off, no local use recorded" + ); AddReturn( $item_2->barcode, $item_2->homebranch ); - $item_2->discard_changes; # refresh - is( $item_2->localuse, undef , 'Without RecordLocalUseOnReturn no localuse is recorded.'); + $item_2->discard_changes; # refresh + is( $item_2->localuse, undef, 'Without RecordLocalUseOnReturn no localuse is recorded.' ); - t::lib::Mocks::mock_preference('RecordLocalUseOnReturn', 1); + t::lib::Mocks::mock_preference( 'RecordLocalUseOnReturn', 1 ); my @return2 = AddReturn( $item->barcode, $item->homebranch, 0, undef ); is_deeply( \@return2, - [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1 }, undef, {} ], "Local use is recorded"); + [ 0, { NotIssued => $item->barcode, withdrawn => 1, LocalUse => 1 }, undef, {} ], "Local use is recorded" + ); AddReturn( $item_2->barcode, $item_2->homebranch ); - $item_2->discard_changes; # refresh - is( $item_2->localuse, 1 , 'With RecordLocalUseOnReturn localuse is recorded.'); + $item_2->discard_changes; # refresh + is( $item_2->localuse, 1, 'With RecordLocalUseOnReturn localuse is recorded.' ); AddReturn( $item_2->barcode, $item_2->homebranch ); - $item_2->discard_changes; # refresh - is( $item_2->localuse, 2 , 'With RecordLocalUseOnReturn localuse is recorded.'); + $item_2->discard_changes; # refresh + is( $item_2->localuse, 2, 'With RecordLocalUseOnReturn localuse is recorded.' ); }; subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub { --