From 577f48286559d3e9f92b2beeb0abd4ebe5535556 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Wed, 17 May 2017 16:26:11 +0000 Subject: [PATCH] Bug 18606: Fix issues to pass tests --- Koha/RotatingCollection.pm | 17 ++++++++++++----- circ/returns.pl | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Koha/RotatingCollection.pm b/Koha/RotatingCollection.pm index 42a97cd..165e080 100644 --- a/Koha/RotatingCollection.pm +++ b/Koha/RotatingCollection.pm @@ -23,6 +23,7 @@ use Carp; use Koha::Database; use Koha::Exceptions; +use Koha::Holds; use Koha::Items; use Koha::RotatingCollection::Trackings; @@ -62,7 +63,8 @@ $collection->add_item( $itemnumber ); throws Koha::Exceptions::MissingParameter - Koha::Exceptions::WrongParameter + Koha::Exceptions::DuplicateObject + Koha::Exceptions::ObjectNotFound =cut @@ -74,6 +76,8 @@ sub add_item { Koha::Exceptions::DuplicateObject->throw if Koha::RotatingCollection::Trackings->search( { itemnumber => $itemnumber } )->count; + Koha::Exceptions::ObjectNotFound->throw if not Koha::Items->find( $itemnumber ); + my $col_tracking = Koha::RotatingCollection::Tracking->new( { colId => $self->colId, @@ -126,10 +130,13 @@ sub transfer { $self->colBranchcode( $branchcode )->store; - for ( my $item = $self->items ) { - my ( $status ) = C4::Reserves::CheckReserves( $item->itemnumber ); - my @transfers = C4::Circulation::GetTransfers( $item->itemnumber ); - C4::Circulation::transferbook( $branchcode, $item->barcode, my $ignore_reserves = 1 ) unless ( $status eq 'Waiting' || @transfers ); + my $items = $self->items; + while ( my $item = $items->next ) { + my $holds = Koha::Holds->search( { + itemnumber => $item->itemnumber, + found => 'W', + } ); + C4::Circulation::transferbook( $branchcode, $item->barcode, my $ignore_reserves = 1 ) unless ( $holds->count || $item->get_transfer ); } } diff --git a/circ/returns.pl b/circ/returns.pl index fd3b529..a6843dd 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -645,7 +645,9 @@ $itemnumber = GetItemnumberFromBarcode( $barcode ); if ( $itemnumber ) { my $item = Koha::Items->find( $itemnumber ); my $holdingBranch = $item->holdingbranch; - my $collectionBranch = $item->rotating_collection->colBranchcode; + my $collection = $item->rotating_collection; + my $collectionBranch; + $collectionBranch = $collection->colBranchcode if $collection; if ( $holdingBranch and $collectionBranch and ( $holdingBranch ne $collectionBranch ) ) { $template->param( collectionItemNeedsTransferred => 1, -- 2.1.4