From 8307855f449422fbefdd843e1004ef75ac4b4635 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 15 Dec 2016 11:57:27 +0000 Subject: [PATCH] Bug 17781 - Improper branchcode set during renewal For no discernable reason, when AddIssue calls AddRenewal, it passes the branchcode generated from _GetCircControlBranch. Assume _GetCircControlBranch is set to return items.homebranch. So: 1) If an item owned by LibraryA is checked out at LibraryB, the statistic line branchcode will be LibraryB 2) If an item is renewed via the ajax datatables renewal function, the statistic line branchcode will be LibraryB the 3) If an item is renewed via scanning the item into the checkout again, statistic line branchcode will be *LibraryA* This is clearly improper behavior. The renewal is taking place at LibraryB, so the branchcode passed to AddRenewal should be LibraryB, the logged in library. This also jives with the documentation for the subroutine. Test Plan: 1) Set CircControl to "the library the item is from" aka ( ItemHomeLibrary ) 2) Set HomeOrHoldingBranch to 'The library the items is from" ( aka homebranch ) 3) Create item with homebranch of LibraryA and holdingbranch of LibraryB 4) Set the logged in library to LibraryB 4) Check the item out to a patron at LibraryB 5) Note the statistics line has a branchcode of LibraryB 6) Check the item out again to trigger a renewal, renew the item 7) Note the statistic line has a branchcode of LibraryA! 8) Apply this patch 9) Repeat step 6 10) Note the statistics line has a branchcode of LibraryB! --- C4/Circulation.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index b505031..f59a81d 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1299,12 +1299,13 @@ sub AddIssue { my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); # check if we just renew the issue. - if ( $actualissue->{borrowernumber} eq $borrower->{'borrowernumber'} - and not $switch_onsite_checkout ) { + if ( $actualissue->{borrowernumber} eq $borrower->{borrowernumber} + and not $switch_onsite_checkout ) + { $datedue = AddRenewal( - $borrower->{'borrowernumber'}, - $item->{'itemnumber'}, - $branch, + $borrower->{borrowernumber}, + $item->{itemnumber}, + C4::Context->userenv ? C4::Context->userenv->{branch} : $branch, $datedue, $issuedate, # here interpreted as the renewal date ); -- 2.1.4