@@ -, +, @@ - Take Koha::Item as parameter instead of HASHref of an item --- C4/Circulation.pm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -879,7 +879,7 @@ sub CanBookBeIssued { my $patron = Koha::Patrons->find( $issue->borrowernumber ); - my ( $can_be_returned, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); + my ( $can_be_returned, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); unless ( $can_be_returned ) { $issuingimpossible{RETURN_IMPOSSIBLE} = 1; @@ -1131,7 +1131,7 @@ Check whether the item can be returned to the provided branch =over 4 -=item C<$item> is a hash of item information as returned Koha::Items->find->unblessed (Temporary, should be a Koha::Item instead) +=item C<$item> is a Koha::Item object =item C<$branch> is the branchcode where the return is taking place @@ -1158,15 +1158,15 @@ sub CanBookBeReturned { my $message; # identify all cases where return is forbidden - if ($allowreturntobranch eq 'homebranch' && $branch ne $item->{'homebranch'}) { + if ($allowreturntobranch eq 'homebranch' && $branch ne $item->homebranch) { $allowed = 0; - $message = $item->{'homebranch'}; - } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->{'holdingbranch'}) { + $message = $item->homebranch; + } elsif ($allowreturntobranch eq 'holdingbranch' && $branch ne $item->holdingbranch) { $allowed = 0; - $message = $item->{'holdingbranch'}; - } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->{'homebranch'} && $branch ne $item->{'holdingbranch'}) { + $message = $item->holdingbranch; + } elsif ($allowreturntobranch eq 'homeorholdingbranch' && $branch ne $item->homebranch && $branch ne $item->holdingbranch) { $allowed = 0; - $message = $item->{'homebranch'}; # FIXME: choice of homebranch is arbitrary + $message = $item->homebranch; # FIXME: choice of homebranch is arbitrary } return ($allowed, $message); @@ -1379,7 +1379,7 @@ sub AddIssue { if ( $actualissue and not $switch_onsite_checkout ) { # This book is currently on loan, but not to the person # who wants to borrow it now. mark it returned before issuing to the new borrower - my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} ); + my ( $allowed, $message ) = CanBookBeReturned( $item_object, C4::Context->userenv->{branch} ); return unless $allowed; AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} ); } @@ -1953,7 +1953,8 @@ sub AddReturn { } # check if the return is allowed at this branch - my ($returnallowed, $message) = CanBookBeReturned($item->unblessed, $branch); + my ($returnallowed, $message) = CanBookBeReturned($item, $branch); + unless ($returnallowed){ $messages->{'Wrongbranch'} = { Wrongbranch => $branch, --