From 9f4b2881a0d8a3d4a00b951a732704bc9a3741cc 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 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c2edf81f94..3e32a0f24b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2753,7 +2753,7 @@ sub CanBookBeRenewed { my $patron = $issue->patron or return; - # override_limit will override anything else except on_reserve + # override_limit will override anything else except on_reserve or too_soon unless ( $override_limit ){ my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); my $issuing_rule = Koha::CirculationRules->get_effective_rules( @@ -2795,6 +2795,9 @@ sub CanBookBeRenewed { branchcode => $branchcode, issue => $issue }); + return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon' && $cron; + # cron wants 'too_soon' over 'on_reserve' for performance and to avoid + # extra notices being sent. Cron also implies no override return ( 0, $auto_renew ) if $auto_renew =~ 'auto_account_expired'; return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_late'; return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_much_oweing'; @@ -2858,13 +2861,9 @@ 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; # '' when no hold was found - 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 + return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; return ( 0, "auto_renew" ) if $auto_renew eq "ok" && !$override_limit; # 0 if auto-renewal should not succeed -- 2.20.1