From 9b2d032d1e519393edca80692b1e4718d1e4114a 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 Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer (cherry picked from commit 834bff631784cc9788e66b7baad6067a5df7cffc) Signed-off-by: Fridolin Somers --- C4/Circulation.pm | 15 +-------------- circ/circulation.pl | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 1de9b54873..522ac9d768 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -836,21 +836,8 @@ sub CanBookBeIssued { } ); my $block_lost_return = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0; - my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ); - ( $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, - }, - {} - ); + return ( { STATS => 1, }, {} ); } if ( $patron->gonenoaddress && $patron->gonenoaddress == 1 ) { diff --git a/circ/circulation.pl b/circ/circulation.pl index 87d977d72b..3b5aee2f52 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 ); @@ -354,6 +354,21 @@ if (@$barcodes) { $biblio = $item->biblio; } + if ( $issuingimpossible->{'STATS'} ) { + $template->param( STATS => 1 ); + + if ( $item->onloan ) { + my ( $stats_return, $stats_messages, $stats_iteminformation, $stats_borrower ) = + AddReturn( $item->barcode, C4::Context->userenv->{'branch'}, undef, undef, 1 ); + + $template->param( + 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.39.5