From c1568b5616ce020b8cc1d516a77362244eff5be9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 9 Jan 2018 14:29:50 -0300 Subject: [PATCH] Bug 19943: Remove itemtype vs itype confusion in CanBookBeIssued Just a preliminary step to clean the code a bit in CanBookBeIssued. The effective item type is already set from GetItem and we do not need to deal with that again. --- C4/Circulation.pm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a2a9e7bc53..88c0687d1b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -683,7 +683,7 @@ sub CanBookBeIssued { my $item = GetItem(undef, $barcode ); my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); my $biblioitem = GetBiblioItemData($item->{biblioitemnumber}); - $item->{'itemtype'}=$item->{'itype'}; + my $effective_itemtype = $item->{itype}; # GetItem deals with that my $dbh = C4::Context->dbh; # MANDATORY CHECKS - unless item exists, nothing else matters @@ -703,8 +703,7 @@ sub CanBookBeIssued { my $issuedate = $now->clone(); my $branch = _GetCircControlBranch($item,$borrower); - my $itype = ( C4::Context->preference('item-level_itypes') ) ? $item->{'itype'} : $biblioitem->{'itemtype'}; - $duedate = CalcDateDue( $issuedate, $itype, $branch, $borrower ); + $duedate = CalcDateDue( $issuedate, $effective_itemtype, $branch, $borrower ); # Offline circ calls AddIssue directly, doesn't run through here # So issuingimpossible should be ok. @@ -729,7 +728,7 @@ sub CanBookBeIssued { branch => C4::Context->userenv->{'branch'}, type => 'localuse', itemnumber => $item->{'itemnumber'}, - itemtype => $item->{'itype'}, + itemtype => $effective_itemtype, borrowernumber => $borrower->{'borrowernumber'}, ccode => $item->{'ccode'}} ); @@ -941,20 +940,20 @@ sub CanBookBeIssued { if ($notforloan->{'notforloan'}) { if (!C4::Context->preference("AllowNotForLoanOverride")) { $issuingimpossible{NOT_FOR_LOAN} = 1; - $issuingimpossible{itemtype_notforloan} = $item->{'itype'}; + $issuingimpossible{itemtype_notforloan} = $effective_itemtype; } else { $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; - $needsconfirmation{itemtype_notforloan} = $item->{'itype'}; + $needsconfirmation{itemtype_notforloan} = $effective_itemtype; } } } elsif ($biblioitem->{'notforloan'} == 1){ if (!C4::Context->preference("AllowNotForLoanOverride")) { $issuingimpossible{NOT_FOR_LOAN} = 1; - $issuingimpossible{itemtype_notforloan} = $biblioitem->{'itemtype'}; + $issuingimpossible{itemtype_notforloan} = $effective_itemtype; } else { $needsconfirmation{NOT_FOR_LOAN_FORCING} = 1; - $needsconfirmation{itemtype_notforloan} = $biblioitem->{'itemtype'}; + $needsconfirmation{itemtype_notforloan} = $effective_itemtype; } } } -- 2.11.0