From f8b5c5029a619b4667a0550201771042ca6946e4 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 18 Mar 2024 10:06:25 +0000 Subject: [PATCH] Bug 16122: Tidy changed code blocks Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- 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(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 1fc1226d51..11f689d18c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2159,11 +2159,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'; } } diff --git a/circ/circulation.pl b/circ/circulation.pl index f5c82fdef6..76b2fc99d9 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -380,8 +380,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'} diff --git a/misc/maintenance/update_localuse_from_statistics.pl b/misc/maintenance/update_localuse_from_statistics.pl index 5da3b79e3c..ac8ef0d92a 100755 --- a/misc/maintenance/update_localuse_from_statistics.pl +++ b/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; diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 8524012db9..307db1d8a9 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -6345,7 +6345,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( @@ -6358,25 +6358,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 { -- 2.39.5