From 6cd5f3b2fc8a6759c4eece974c933308b1662556 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 11 Aug 2023 14:20:48 +0000 Subject: [PATCH] Bug 25393: Auto renewals logic reimplementation: Check if it's too soon for a manual renewal even if 'Automatic renewals' is enabled Allow for a manual renewal even if it's too soon for an automatic renewal Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- C4/Circulation.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index b2bbabbc05..4c6b10af17 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3100,13 +3100,24 @@ sub CanBookBeRenewed { } } - return ( 0, $auto_renew, { soonest_renew_date => $soonest } ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; + if($auto_renew =~ 'too_soon'){ + + # If its cron, tell it it's too soon for a an auto renewal + return ( 0, $auto_renew, { soonest_renew_date => $soonest } ) if $cron; + + # Check if it's too soon for a manual renewal + my $soonestManual = GetSoonestRenewDate( $patron, $issue ); + if($soonestManual > dt_from_string()){ + return (0, "too_soon", { soonest_renew_date => $soonestManual } ) unless $override_limit; + } + } + $soonest = GetSoonestRenewDate($patron, $issue); if ( $soonest > dt_from_string() ){ return (0, "too_soon", { soonest_renew_date => $soonest } ) unless $override_limit; } - return ( 0, "auto_renew" ) if $auto_renew eq "ok" && !$override_limit; # 0 if auto-renewal should not succeed + return ( 1, "auto_renew" ) if $auto_renew eq "ok" || $auto_renew eq "auto_too_soon" && !$override_limit; # 0 if auto-renewal should not succeed return ( 1, undef ); } -- 2.39.5