Bugzilla – Attachment 58672 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.24 KB, created by
Jonathan Druart
on 2017-01-09 08:05:23 UTC
(
hide
)
Description:
Bug 16413: Change prototype of GetSoonestRenewDate
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-01-09 08:05:23 UTC
Size:
5.24 KB
patch
obsolete
>From 6849a48c64926d6ac9a521743645662b74f31ba5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 9 Jan 2017 09:03:15 +0100 >Subject: [PATCH] Bug 16413: Change prototype of GetSoonestRenewDate > >Same change as previous patch for the GetSoonestRenewDate subroutine. > >Test plan: >Make sure this change does not introduce regressions on bug 7413. >--- > C4/Circulation.pm | 28 ++++++++++++---------------- > circ/renew.pl | 7 +++++-- > t/db_dependent/Circulation.t | 8 +++++--- > 3 files changed, 22 insertions(+), 21 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index aa3dba3..a8d3ef4 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2968,14 +2968,15 @@ sub GetRenewCount { > > =head2 GetSoonestRenewDate > >- $NoRenewalBeforeThisDate = &GetSoonestRenewDate($borrowernumber, $itemnumber); >+ $NoRenewalBeforeThisDate = &GetSoonestRenewDate( { patron => $patron, item => $item } ); > > 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<$patron> is the patron who currently has the item on loan. > >-C<$itemnumber> is the number of the item to renew. >+C<$item> is the item to renew. >+ >+C<$issue> is the issue to renew. > > C<$GetSoonestRenewDate> returns the DateTime of the soonest possible > renew date, based on the value "No renewal before" of the applicable >@@ -2986,20 +2987,15 @@ cannot be found. > =cut > > sub GetSoonestRenewDate { >- my ( $borrowernumber, $itemnumber ) = @_; >- >- my $dbh = C4::Context->dbh; >- >- my $item = GetItem($itemnumber) or return; >- my $itemissue = GetItemIssue($itemnumber) or return; >+ my ( $params ) = @_; > >- $borrowernumber ||= $itemissue->{borrowernumber}; >- my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) >- or return; >+ my $patron = $params->{patron} or return; >+ my $item = $params->{item} or return; >+ my $issue = $params->{issue} or return; > >- my $branchcode = _GetCircControlBranch( $item, $borrower ); >+ my $branchcode = _GetCircControlBranch( $item, $patron ); > my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( >- { categorycode => $borrower->{categorycode}, >+ { categorycode => $patron->{categorycode}, > itemtype => $item->{itype}, > branchcode => $branchcode > } >@@ -3012,7 +3008,7 @@ sub GetSoonestRenewDate { > and $issuing_rule->norenewalbefore ne "" ) > { > my $soonestrenewal = >- $itemissue->{date_due}->clone() >+ $issue->{date_due}->clone() > ->subtract( > $issuing_rule->lengthunit => $issuing_rule->norenewalbefore ); > >diff --git a/circ/renew.pl b/circ/renew.pl >index 1afb6d2a..32e80ff 100755 >--- a/circ/renew.pl >+++ b/circ/renew.pl >@@ -78,8 +78,11 @@ if ($barcode) { > > if ( $error && ($error eq 'too_soon' or $error eq 'auto_too_soon') ) { > $soonest_renew_date = C4::Circulation::GetSoonestRenewDate( >- $borrower->borrowernumber(), >- $item->itemnumber(), >+ { >+ patron => $borrower->unblessed, >+ item => $item->unblessed, >+ issue => $issue->unblessed, >+ } > ); > } > if ( $error && ( $error eq 'auto_too_late' ) ) { >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index faa8fcc..a61bd76 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -520,9 +520,11 @@ 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); > t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact_time' ); > is( >- GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), >+ GetSoonestRenewDate( { patron => $renewing_borrower, item => $item, issue => $itemissue, } ), > $datedue->clone->add( days => -7 ), > 'Bug 14395: Renewals permitted 7 days before due date, as expected' > ); >@@ -531,7 +533,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > # Test 'date' setting for syspref NoRenewalBeforePrecision > t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' ); > is( >- GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), >+ GetSoonestRenewDate( { patron => $renewing_borrower, item => $item, issue => $itemissue, } ), > $datedue->clone->add( days => -7 )->truncate( to => 'day' ), > 'Bug 14395: Renewals permitted 7 days before due date, as expected' > ); >@@ -699,7 +701,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > > LostItem( $itemnumber, 1 ); > >- my $item = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber); >+ $item = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber); > ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); > > my $total_due = $dbh->selectrow_array( >-- >2.1.4
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