@@ -, +, @@ --- Koha/Biblio.pm | 7 ++++--- Koha/Biblios.pm | 4 +++- Koha/Item.pm | 11 ++++++----- t/db_dependent/Koha/Biblios.t | 4 +++- 4 files changed, 16 insertions(+), 10 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -255,11 +255,12 @@ sub can_be_transferred { =head3 pickup_locations - my $pickup_locations = $biblio->pickup_locations( {patron => $patron } ); + my $pickup_locations = $biblio->pickup_locations( { patron => $patron } ); Returns a Koha::Libraries set of possible pickup locations for this biblio's items, -according to patron's home library (if patron is defined and holds are allowed -only from hold groups) and if item can be transferred to each pickup location. +according to patron's home library and if item can be transferred to each pickup location. + +Patron is a required parameter. =cut --- a/Koha/Biblios.pm +++ a/Koha/Biblios.pm @@ -40,7 +40,9 @@ Koha::Biblios - Koha Biblio object set class my $biblios = Koha::Biblios->search(...); my $pickup_locations = $biblios->pickup_locations({ patron => $patron }); -For a given resultset, it returns all the pickup locations +For a given resultset, it returns all the pickup locations. + +Patron is a required parameter. =cut --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -736,25 +736,26 @@ sub can_be_transferred { $pickup_locations = $item->pickup_locations( {patron => $patron } ) -Returns possible pickup locations for this item, according to patron's home library (if patron is defined and holds are allowed only from hold groups) +Returns possible pickup locations for this item, according to patron's home library and if item can be transferred to each pickup location. +Patron parameter is required. + =cut sub pickup_locations { my ($self, $params) = @_; my $patron = $params->{patron}; + # FIXME We should throw an exception if not passed my $circ_control_branch = C4::Reserves::GetReservesControlBranch( $self->unblessed(), $patron->unblessed ); my $branchitemrule = C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype ); - if(defined $patron) { - return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_local_hold_group' && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} ); - return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_home_library' && $self->home_branch->branchcode ne $patron->branchcode; - } + return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_local_hold_group' && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} ); + return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_home_library' && $self->home_branch->branchcode ne $patron->branchcode; my $pickup_libraries = Koha::Libraries->search(); if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup') { --- a/t/db_dependent/Koha/Biblios.t +++ a/t/db_dependent/Koha/Biblios.t @@ -278,6 +278,8 @@ subtest 'pickup_locations() tests' => sub { my $item_2_1 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber }); my $item_2_2 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber }); + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); + my $biblios = Koha::Biblios->search( { biblionumber => [ $biblio_1->biblionumber, $biblio_2->biblionumber ] @@ -298,7 +300,7 @@ subtest 'pickup_locations() tests' => sub { ]; my $pickup_locations_ids = [ - $biblios->pickup_locations->_resultset->get_column('branchcode')->all + $biblios->pickup_locations({ patron => $patron })->_resultset->get_column('branchcode')->all ]; is_deeply( --