From 7cf4c9c0326053fa1573ba8141cde03fddeef55a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sat, 13 Nov 2021 14:43:36 +0000 Subject: [PATCH] Bug 29474: Return too_soon before checking renewals This patch allows us to avoid checking reserves when the issue is too_soon and we are running the cron Code is covered by existing tests To test: 1 - prove -v t/db_dependent/Circulation.t --- C4/Circulation.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c2edf81f94..c0de8b0d06 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2800,6 +2800,8 @@ sub CanBookBeRenewed { return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_much_oweing'; } + return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon' && $cron;#$auto_renew ne "no" && $auto_renew ne "ok"; + my ( $resfound, $resrec, $possible_reserves ) = C4::Reserves::CheckReserves($itemnumber); # If next hold is non priority, then check if any hold with priority (non_priority = 0) exists for the same biblionumber. @@ -2858,10 +2860,10 @@ sub CanBookBeRenewed { } } } - if( $cron ) { #The cron wants to return 'too_soon' over 'on_reserve' - return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; - return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found - } else { # For other purposes we want 'on_reserve' before 'too_soon' + + return ( 0, "on_reserve" ) if $resfound && $cron; # '' when no hold was found + + unless ( $cron ) { # For other purposes we want 'on_reserve' before 'too_soon' return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; } -- 2.20.1