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 <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Nick Clemens 2022-02-23 16:09:07 +00:00 committed by Fridolin Somers
parent 4cf759259f
commit 175182f064
4 changed files with 11 additions and 18 deletions

View File

@ -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(

View File

@ -407,7 +407,7 @@
[% 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 %]

View File

@ -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;
}
}

View File

@ -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
}
)