From f22dc034772b034baffbe9a6bb8c7fafdae9b034 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 29 Feb 2024 20:48:25 +0000 Subject: [PATCH] Bug 35950: Move AddReturn call into circulation.pl There should be no change in beahavior. Following the test plan from Bug 35840. To test: 1. APPLY PATCH, restart_all 2. Turn on RecordLocalUseOnReturn 3. Create a Statistical patron. 4. Check an item out to a regular patron. 5. Check the item out to a Statistical patron. 6. This should trigger a return and you will see 2 entries in the statistics table, one for localuse and one for a return. 7. Try checking out an item to the Stats patron that is NOT checked out. 8. You should only see 1 entry, localuse, in the statistics table. Signed-off-by: Andrew Fuerste Henry --- C4/Circulation.pm | 11 +---------- circ/circulation.pl | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 08de40f85ed..2b50847a48c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -835,18 +835,9 @@ sub CanBookBeIssued { } ); my $block_lost_return = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; - my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = - AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ) if $item_object->onloan; ModDateLastSeen( $item_object->itemnumber, $block_lost_return ); # FIXME Move to Koha::Item return ( - { - STATS => 1, - CHECKEDIN => $stats_return, - MESSAGES => $stats_messages, - ITEM => $stats_iteminformation, - BORROWER => $stats_borrower, - }, - {} + { STATS => 1, }, {} ); } diff --git a/circ/circulation.pl b/circ/circulation.pl index a6a30ce288f..788e073bc2e 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -34,7 +34,7 @@ use Try::Tiny; use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); use C4::Auth qw( get_session get_template_and_user ); use C4::Koha; -use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue ); +use C4::Circulation qw( barcodedecode CanBookBeIssued AddIssue AddReturn ); use C4::Members; use C4::Biblio qw( TransformMarcToKoha ); use C4::Search qw( new_record_from_zebra ); @@ -355,6 +355,20 @@ if (@$barcodes && $op eq 'cud-checkout') { $biblio = $item->biblio; } + if ( $issuingimpossible->{'STATS'} ) { + my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = + AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ) + if $item->onloan; + + $template->param( + STATS => 1, + CHECKEDIN => $stats_return, + MESSAGES => $stats_messages, + ITEM => $stats_iteminformation, + BORROWER => $stats_borrower, + ); + }; + # Fix for bug 7494: optional checkout-time fallback search for a book if ( $issuingimpossible->{'UNKNOWN_BARCODE'} -- 2.30.2