Bugzilla – Attachment 65406 Details for
Bug 16413
Prototype for GetLatestAutoRenewDate and GetSoonestRenewDate should be changed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16413: Change prototype of GetSoonestRenewDate
Bug-16413-Change-prototype-of-GetSoonestRenewDate.patch (text/plain), 5.29 KB, created by
Jonathan Druart
on 2017-08-01 18:14:12 UTC
(
hide
)
Description:
Bug 16413: Change prototype of GetSoonestRenewDate
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-08-01 18:14:12 UTC
Size:
5.29 KB
patch
obsolete
>From fdf12ee1064cce6d30eee6b3715ccc4457d6a94c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 1 Aug 2017 14:55:08 -0300 >Subject: [PATCH] Bug 16413: Change prototype of GetSoonestRenewDate > >Same change as previous patch for the GetSoonestRenewDate subroutine. > >This is not finished, 2 other calls could not be updated (performance >issue). They may be later, when objects will be used in svc/checkouts >and opac-user.pl >--- > C4/Circulation.pm | 16 ++++++++-------- > circ/renew.pl | 6 +++--- > t/db_dependent/Circulation.t | 9 +++++---- > 3 files changed, 16 insertions(+), 15 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index af0c715a1d..5a4e93f01c 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2458,7 +2458,7 @@ C<$borrower> is a hashref to borrower. Only {branchcode} is used. > =cut > > sub _GetCircControlBranch { >- my ($item, $borrower) = @_; >+ my ($item, $borrower) = @_; # Only branchcode is used for $borrower > my $circcontrol = C4::Context->preference('CircControl'); > my $branch; > >@@ -2967,7 +2967,7 @@ sub GetRenewCount { > > =head2 GetSoonestRenewDate > >- $NoRenewalBeforeThisDate = &GetSoonestRenewDate( { patron => $patron, item => $item } ); >+$NoRenewalBeforeThisDate = &GetSoonestRenewDate( { patron => $patron, checkout => $checkout, item => $item } ); > > Find out the soonest possible renew date of a borrowed item. > >@@ -2975,7 +2975,7 @@ C<$patron> is the patron who currently has the item on loan. > > C<$item> is the item to renew. > >-C<$issue> is the issue to renew. >+C<$checkout> is the checkout to renew. > > C<$GetSoonestRenewDate> returns the DateTime of the soonest possible > renew date, based on the value "No renewal before" of the applicable >@@ -2988,11 +2988,11 @@ cannot be found. > sub GetSoonestRenewDate { > my ( $params ) = @_; > >- my $patron = $params->{patron} or return; >- my $item = $params->{item} or return; >- my $issue = $params->{issue} or return; >+ my $patron = $params->{patron} or return; >+ my $item = $params->{item} or return; >+ my $checkout = $params->{checkout} or return; > >- my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); >+ my $branchcode = _GetCircControlBranch( $item->unblessed, { branchcode => $patron->branchcode } ); > my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( > { categorycode => $patron->categorycode, > itemtype => $item->effective_itemtype, >@@ -3007,7 +3007,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' >diff --git a/circ/renew.pl b/circ/renew.pl >index cfff2d76e4..8fdf3889a0 100755 >--- a/circ/renew.pl >+++ b/circ/renew.pl >@@ -81,9 +81,9 @@ if ($barcode) { > if ( $error && ($error eq 'too_soon' or $error eq 'auto_too_soon') ) { > $soonest_renew_date = C4::Circulation::GetSoonestRenewDate( > { >- patron => $borrower->unblessed, >- item => $item->unblessed, >- issue => $issue->unblessed, >+ patron => $borrower, >+ item => $item, >+ issue => $issue, > } > ); > } >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index f84d0cbb0a..e84c68c788 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -536,11 +536,12 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > > # Bug 14395 > # Test 'exact time' setting for syspref NoRenewalBeforePrecision >- my $item = C4::Items::GetItem( $itemnumber ); >- my $itemissue = C4::Circulation::GetItemIssue($itemnumber); >+ my $item_obj = Koha::Items->find( $itemnumber ); >+ my $issue_obj = Koha::Checkouts->find( { itemnumber => $itemnumber } ); >+ my $renewing_borrower_obj = Koha::Patrons->find( $renewing_borrowernumber ); > t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact_time' ); > is( >- GetSoonestRenewDate( { patron => $renewing_borrower, item => $item, issue => $itemissue, } ), >+ GetSoonestRenewDate( { patron => $renewing_borrower_obj, item => $item_obj, issue => $issue_obj, } ), > $datedue->clone->add( days => -7 ), > 'Bug 14395: Renewals permitted 7 days before due date, as expected' > ); >@@ -549,7 +550,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > # Test 'date' setting for syspref NoRenewalBeforePrecision > t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' ); > is( >- GetSoonestRenewDate( { patron => $renewing_borrower, item => $item, issue => $itemissue, } ), >+ GetSoonestRenewDate( { patron => $renewing_borrower_obj, item => $item_obj, issue => $issue_obj, } ), > $datedue->clone->add( days => -7 )->truncate( to => 'day' ), > 'Bug 14395: Renewals permitted 7 days before due date, as expected' > ); >-- >2.11.0
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 16413
:
51100
|
51101
|
58671
|
58672
|
61514
|
61515
|
65405
| 65406