From 3587400ea7a90517ccd184d2e60668e0e0d1c5db Mon Sep 17 00:00:00 2001 From: Nahuel Angelinetti Date: Fri, 6 Mar 2009 11:38:03 +0100 Subject: [PATCH] change the date calc, to set the date_due to date_due+loanlength. At the moment when you renew a document the date_due calculated is now+loanlength, but it's a bad thing, It should be date_due+loanlength. This patch do change Circulation.pm to use the date_due as renew base and add the loanlength to get the new date_due after renewal. Signed-off-by: Henri-Damien LAURENT Signed-off-by: Galen Charlton --- C4/Circulation.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 200bdd2b15..465913ebf1 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2131,6 +2131,22 @@ sub AddRenewal { my $issuedata = $sth->fetchrow_hashref; $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')) { + + 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($issuedata->{date_due}, 'iso'),$loanlength,$branch); # this branch is the transactional branch. + # The question of whether to use item's homebranch calendar is open. + } + # Update the issues record to have the new due date, and a new count # of how many times it has been renewed. my $renews = $issuedata->{'renewals'} + 1; -- 2.39.5