@@ -, +, @@ --- C4/Circulation.pm | 16 ++++++++-------- circ/renew.pl | 6 +++--- t/db_dependent/Circulation.t | 9 +++++---- 3 files changed, 16 insertions(+), 15 deletions(-) --- a/C4/Circulation.pm +++ a/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' --- a/circ/renew.pl +++ a/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, } ); } --- a/t/db_dependent/Circulation.t +++ a/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' ); --