Bug 30167: Use returned renewal date rather than fetching
authorNick Clemens <nick@bywatersolutions.com>
Wed, 23 Feb 2022 16:09:07 +0000 (16:09 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 5 May 2022 00:29:23 +0000 (14:29 -1000)
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 <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
circ/renew.pl
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt
opac/opac-user.pl
svc/checkouts

index 97b6317..36a8489 100755 (executable)
@@ -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(
index 45f1432..b74499d 100644 (file)
                                                                 [% END %]
                                                             )</span>
                                                         [% ELSIF ( ISSUE.too_soon ) %]
-                                                            <span class="usr-msg no-renewal-before">No renewal before [% ISSUE.soonestrenewdate | html %]</span>
+                                                            <span class="usr-msg no-renewal-before">No renewal before [% ISSUE.soonestrenewdate | $KohaDates  as_due_date => 1 %]</span>
                                                             <span class="renewals">(
                                                                 [% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining
                                                                 [% IF Koha.Preference('UnseenRenewals') && ISSUE.unseenallowed %]
index 5bc84c5..ed3d4e0 100755 (executable)
@@ -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;
             }
         }
 
index 07e95c3..0dfcaf1 100755 (executable)
@@ -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
         }
       )