Bugzilla – Attachment 131048 Details for
Bug 30168
Use checkout object in GetSoonestRenewDate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30168: Use checkout object in GetSoonestRenewDate
Bug-30168-Use-checkout-object-in-GetSoonestRenewDa.patch (text/plain), 5.83 KB, created by
Nick Clemens
on 2022-02-23 16:52:59 UTC
(
hide
)
Description:
Bug 30168: Use checkout object in GetSoonestRenewDate
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2022-02-23 16:52:59 UTC
Size:
5.83 KB
patch
obsolete
>From 919adf70815c693b7aa07977568ca807666547a9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 23 Feb 2022 16:25:21 +0000 >Subject: [PATCH] Bug 30168: Use checkout object in GetSoonestRenewDate > >--- > C4/Circulation.pm | 29 ++++++++++------------------- > t/db_dependent/Circulation.t | 10 +++++----- > 2 files changed, 15 insertions(+), 24 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 9c5e60dc72..26e176d99c 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2871,7 +2871,7 @@ sub CanBookBeRenewed { > > return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found > return ( 0, $auto_renew, $soonest ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; >- $soonest = GetSoonestRenewDate($borrowernumber, $itemnumber); >+ $soonest = GetSoonestRenewDate($issue); > if ( $soonest > dt_from_string() ){ > return (0, "too_soon", $soonest ) unless $override_limit; > } >@@ -3151,14 +3151,11 @@ sub GetRenewCount { > > =head2 GetSoonestRenewDate > >- $NoRenewalBeforeThisDate = &GetSoonestRenewDate($borrowernumber, $itemnumber); >+ $NoRenewalBeforeThisDate = &GetSoonestRenewDate($issue); > > Find out the soonest possible renew date of a borrowed item. > >-C<$borrowernumber> is the borrower number of the patron who currently >-has the item on loan. >- >-C<$itemnumber> is the number of the item to renew. >+C<$checkout> is the checkout object to renew. > > C<$GetSoonestRenewDate> returns the DateTime of the soonest possible > renew date, based on the value "No renewal before" of the applicable >@@ -3169,16 +3166,10 @@ cannot be found. > =cut > > sub GetSoonestRenewDate { >- my ( $borrowernumber, $itemnumber ) = @_; >+ my ( $checkout ) = @_; > >- my $dbh = C4::Context->dbh; >- >- my $item = Koha::Items->find($itemnumber) or return; >- my $itemissue = $item->checkout or return; >- >- $borrowernumber ||= $itemissue->borrowernumber; >- my $patron = Koha::Patrons->find( $borrowernumber ) >- or return; >+ my $item = $checkout->item or return; >+ my $patron = $checkout->patron or return; > > my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); > my $issuing_rule = Koha::CirculationRules->get_effective_rules( >@@ -3198,7 +3189,7 @@ sub GetSoonestRenewDate { > and $issuing_rule->{norenewalbefore} ne "" ) > { > my $soonestrenewal = >- dt_from_string( $itemissue->date_due )->subtract( >+ dt_from_string( $checkout->date_due )->subtract( > $issuing_rule->{lengthunit} => $issuing_rule->{norenewalbefore} ); > > if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' >@@ -3207,9 +3198,9 @@ sub GetSoonestRenewDate { > $soonestrenewal->truncate( to => 'day' ); > } > return $soonestrenewal if $now < $soonestrenewal; >- } elsif ( $itemissue->auto_renew && $patron->autorenew_checkouts ) { >+ } elsif ( $checkout->auto_renew && $patron->autorenew_checkouts ) { > # Checkouts with auto-renewing fall back to due date >- my $soonestrenewal = dt_from_string( $itemissue->date_due ); >+ my $soonestrenewal = dt_from_string( $checkout->date_due ); > if ( C4::Context->preference('NoRenewalBeforePrecision') eq 'date' > and $issuing_rule->{lengthunit} eq 'days' ) > { >@@ -4333,7 +4324,7 @@ sub _CanBookBeAutoRenewed { > > if ( defined $issuing_rule->{norenewalbefore} > and $issuing_rule->{norenewalbefore} ne "" ) { >- my $soonest = GetSoonestRenewDate($patron->id, $item->id); >+ my $soonest = GetSoonestRenewDate($issue); > if ( $soonest > dt_from_string()) { > return ( "auto_too_soon", $soonest ); > } else { >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index eed9b42dea..e5cf7cc56d 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -4984,7 +4984,7 @@ subtest "GetSoonestRenewDate tests" => sub { > # Test 'exact time' setting for syspref NoRenewalBeforePrecision > t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact_time' ); > is( >- GetSoonestRenewDate( $patron->id, $item->itemnumber ), >+ GetSoonestRenewDate( $issue ), > $datedue->clone->add( days => -7 ), > 'Bug 14395: Renewals permitted 7 days before due date, as expected' > ); >@@ -4993,7 +4993,7 @@ subtest "GetSoonestRenewDate tests" => sub { > # Test 'date' setting for syspref NoRenewalBeforePrecision > t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' ); > is( >- GetSoonestRenewDate( $patron->id, $item->itemnumber ), >+ GetSoonestRenewDate( $issue ), > $datedue->clone->add( days => -7 )->truncate( to => 'day' ), > 'Bug 14395: Renewals permitted 7 days before due date, as expected' > ); >@@ -5010,7 +5010,7 @@ subtest "GetSoonestRenewDate tests" => sub { > ); > > is( >- GetSoonestRenewDate( $patron->id, $item->itemnumber ), >+ GetSoonestRenewDate( $issue ), > dt_from_string, > 'Checkouts without auto-renewal can be renewed immediately if no norenewalbefore' > ); >@@ -5018,13 +5018,13 @@ subtest "GetSoonestRenewDate tests" => sub { > t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' ); > $issue->auto_renew(1)->store; > is( >- GetSoonestRenewDate( $patron->id, $item->itemnumber ), >+ GetSoonestRenewDate( $issue ), > $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 ), >+ GetSoonestRenewDate( $issue ), > $datedue, > 'Checkouts with auto-renewal can be renewed earliest on due date if no renewalbefore' > ); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30168
:
131048
|
131049
|
134603
|
140969
|
141554
|
141555