From 62d746e5fe182ede37abcb0cd081d38ebf7ff704 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 --- C4/Circulation.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 6f11e3f541..d321f42b7c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3080,13 +3080,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.30.2