From 82be6509c4e3956d834989ba0a2baf636e0b15fa Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 6 Jun 2009 14:26:18 -0500 Subject: [PATCH] bug 3299: fix setting renewal due date explicitly When renewing a loan from the patron details page, setting the renewal due date now works again. Broken by patch for bug 2770. Signed-off-by: Galen Charlton --- C4/Circulation.pm | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index b60440642f..c9830fe1f6 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1957,22 +1957,6 @@ sub AddRenewal { my $branch = (@_) ? shift : $item->{homebranch}; # opac-renew doesn't send branch my $datedue = shift; my $lastreneweddate = shift; - - # If the due date wasn't specified, calculate it by adding the - # book's loan length to today's date. - unless ($datedue && $datedue->output('iso')) { - - my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return undef; - my $loanlength = GetLoanLength( - $borrower->{'categorycode'}, - (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'} , - $item->{homebranch} # item's homebranch determines loanlength OR do we want the branch specified by the AddRenewal argument? - ); - #FIXME -- use circControl? - $datedue = CalcDateDue(C4::Dates->new(),$loanlength,$branch,$borrower); # this branch is the transactional branch. - # The question of whether to use item's homebranch calendar is open. - } - # $lastreneweddate defaults to today. unless (defined $lastreneweddate) { $lastreneweddate = strftime( "%Y-%m-%d", localtime ); @@ -1990,21 +1974,22 @@ sub AddRenewal { $sth->finish; # If the due date wasn't specified, calculate it by adding the - # book's loan length to due's date. - unless (@_ and $datedue = shift and $datedue->output('iso')) { + # book's loan length to today's date or the current due date + # based on the value of the RenewalPeriodBase syspref. + unless ($datedue && $datedue->output('iso')) { my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return undef; my $loanlength = GetLoanLength( $borrower->{'categorycode'}, (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'} , - $item->{homebranch} # item's homebranch determines loanlength OR do we want the branch specified by the AddRenewal argument? + $item->{homebranch} # item's homebranch determines loanlength OR do we want the branch specified by the AddRenewal argument? ); $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ? C4::Dates->new($issuedata->{date_due}, 'iso') : C4::Dates->new(); #FIXME -- use circControl? - $datedue = CalcDateDue($datedue,$loanlength,$branch); # this branch is the transactional branch. + $datedue = CalcDateDue($datedue,$loanlength,$branch,$borrower); # this branch is the transactional branch. # The question of whether to use item's homebranch calendar is open. } -- 2.39.5