From 17a1e5dfda0d59957223a13965c95b031cc83810 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 13 Dec 2021 17:27:42 +0000 Subject: [PATCH] Bug 29476: (follow-up) Fix return, add precision test Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit e5949e32a5f1bfc8b2fc45abf74ba1beeb734885) Signed-off-by: Andrew Fuerste-Henry --- C4/Circulation.pm | 2 +- t/db_dependent/Circulation.t | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 4d89924eab..a8daa0f96a 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -3279,7 +3279,7 @@ sub GetSoonestRenewDate { return $soonestrenewal if $now < $soonestrenewal; } elsif ( $itemissue->auto_renew && $patron->autorenew_checkouts ) { # Checkouts with auto-renewing fall back to due date - my $soonestrenewal = return dt_from_string( $itemissue->date_due ); + my $soonestrenewal = dt_from_string( $itemissue->date_due ); if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' and $issuing_rule->{lengthunit} eq 'days' ) { diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index fd8024a3ca..da92680c7b 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -4958,7 +4958,7 @@ subtest "SendCirculationAlert" => sub { }; subtest "GetSoonestRenewDate tests" => sub { - plan tests => 4; + plan tests => 5; Koha::CirculationRules->set_rule( { categorycode => undef, @@ -5008,7 +5008,14 @@ subtest "GetSoonestRenewDate tests" => sub { 'Checkouts without auto-renewal can be renewed immediately if no norenewalbefore' ); + t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' ); $issue->auto_renew(1)->store; + is( + GetSoonestRenewDate( $patron->id, $item->itemnumber ), + $datedue->clone->truncate( to => 'day' ), + 'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore' + ); + t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact' ); is( GetSoonestRenewDate( $patron->id, $item->itemnumber ), $datedue, -- 2.39.5