From 7c335eb6218c00ee92a721914c63499411a19ee3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 4 Sep 2008 12:23:46 -0500 Subject: [PATCH] bug 2582 [1/2]: don't set issuedate during renewal Changed so that issues.issuedate is never modified during a renewal, since that column records the original date of the loan. Changed the name and interpretation of the $issuedate parameter of AddRenewal() to $lastreneweddate, allowing (e.g.) offline circulation to set the date of the renewal without changing the issue date. As a result of the original bug, issues.issuedate can be set to NULL for loans that were renewed via the OPAC, self checkout, or the staff interface when explicitly renewing a loan. Loans that were renewed by checking the item out to the same patron will have the issue date changed to the date of the last renewal. Signed-off-by: Galen Charlton Signed-off-by: Chris Cormack --- C4/Circulation.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index c9830fe1f6..d460957f33 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1957,6 +1957,22 @@ 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); # 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 ); -- 2.20.1