From 175182f064ffb51ee3504a528db1f7f06a443a77 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 23 Feb 2022 16:09:07 +0000 Subject: [PATCH] Bug 30167: Use returned renewal date rather than fetching This patch updates the three scripts that fetched the soonest renewal date to use the return from CanBookBeRenewed To test: 1 - Set a circulation rule with a 'no renewal before' set to 3, loan length set to 5 2 - Check out an item to a patron that uses this rule 3 - Verify the checkouts for the patron show the correct 'No renewal before' date 4 - Sign in to the patron's opac account 5 - Verify the item shows it cannot be renewed, and shows the correct date 6 - Go to Circulation->Renew 7 - Attempt to renew using barcode 8 - Confirm error shows the soonest renewal date Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Fridolin Somers --- circ/renew.pl | 10 ++++------ koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt | 2 +- opac/opac-user.pl | 11 +++-------- svc/checkouts | 6 +++--- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/circ/renew.pl b/circ/renew.pl index 97b6317067..36a848919e 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -23,7 +23,7 @@ use CGI qw ( -utf8 ); use C4::Context; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); -use C4::Circulation qw( barcodedecode CanBookBeRenewed GetSoonestRenewDate GetLatestAutoRenewDate AddRenewal ); +use C4::Circulation qw( barcodedecode CanBookBeRenewed GetLatestAutoRenewDate AddRenewal ); use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Database; use Koha::BiblioFrameworks; @@ -67,7 +67,8 @@ if ($barcode) { if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) { my $can_renew; - ( $can_renew, $error ) = + my $info; + ( $can_renew, $error, $info ) = CanBookBeRenewed( $borrower->borrowernumber(), $item->itemnumber(), $override_limit ); @@ -82,10 +83,7 @@ if ($barcode) { } if ( $error && ($error eq 'too_soon' or $error eq 'auto_too_soon') ) { - $soonest_renew_date = C4::Circulation::GetSoonestRenewDate( - $borrower->borrowernumber(), - $item->itemnumber(), - ); + $soonest_renew_date = $info; } if ( $error && ( $error eq 'auto_too_late' ) ) { $latest_auto_renew_date = C4::Circulation::GetLatestAutoRenewDate( diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 45f1432659..b74499d45e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -407,7 +407,7 @@ [% END %] ) [% ELSIF ( ISSUE.too_soon ) %] - No renewal before [% ISSUE.soonestrenewdate | html %] + No renewal before [% ISSUE.soonestrenewdate | $KohaDates as_due_date => 1 %] ( [% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %] diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 5bc84c5b3f..ed3d4e0513 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -27,7 +27,7 @@ use C4::Koha qw( GetNormalizedISBN GetNormalizedUPC ); -use C4::Circulation qw( CanBookBeRenewed GetRenewCount GetIssuingCharges GetSoonestRenewDate ); +use C4::Circulation qw( CanBookBeRenewed GetRenewCount GetIssuingCharges ); use C4::External::BakerTaylor qw( image_url link_url ); use C4::Reserves qw( GetReserveStatus ); use C4::Members; @@ -223,7 +223,7 @@ if ( $pending_checkouts->count ) { # Useless test $issue->{rentalfines} = $rental_fines->total_outstanding; # check if item is renewable - my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} ); + my ($status,$renewerror,$info) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} ); ( $issue->{'renewcount'}, $issue->{'renewsallowed'}, @@ -254,12 +254,7 @@ if ( $pending_checkouts->count ) { # Useless test if ( $renewerror eq 'too_soon' ) { $issue->{'too_soon'} = 1; - $issue->{'soonestrenewdate'} = output_pref( - C4::Circulation::GetSoonestRenewDate( - $issue->{borrowernumber}, - $issue->{itemnumber} - ) - ); + $issue->{'soonestrenewdate'} = $info; } } diff --git a/svc/checkouts b/svc/checkouts index 07e95c301a..0dfcaf1f91 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -23,7 +23,7 @@ use CGI; use JSON qw(to_json); use C4::Auth qw(check_cookie_auth haspermission); -use C4::Circulation qw(GetIssuingCharges CanBookBeRenewed GetRenewCount GetSoonestRenewDate); +use C4::Circulation qw(GetIssuingCharges CanBookBeRenewed GetRenewCount ); use C4::Overdues qw(GetFine); use C4::Context; @@ -154,13 +154,13 @@ while ( my $c = $sth->fetchrow_hashref() ) { my ($charge) = GetIssuingCharges( $c->{itemnumber}, $c->{borrowernumber} ); my $fine = GetFine( $c->{itemnumber}, $c->{borrowernumber} ); - my ( $can_renew, $can_renew_error ) = + my ( $can_renew, $can_renew_error, $info ) = CanBookBeRenewed( $c->{borrowernumber}, $c->{itemnumber} ); my $can_renew_date = $can_renew_error && $can_renew_error eq 'too_soon' ? output_pref( { - dt => GetSoonestRenewDate( $c->{borrowernumber}, $c->{itemnumber} ), + dt => $info, as_due_date => 1 } ) -- 2.39.5