View | Details | Raw Unified | Return to bug 33447
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-2 / +7 lines)
Lines 38-43 use Koha::Biblioitems; Link Here
38
use Koha::Cache::Memory::Lite;
38
use Koha::Cache::Memory::Lite;
39
use Koha::Checkouts;
39
use Koha::Checkouts;
40
use Koha::CirculationRules;
40
use Koha::CirculationRules;
41
use Koha::Exceptions;
41
use Koha::Item::Transfer::Limits;
42
use Koha::Item::Transfer::Limits;
42
use Koha::Items;
43
use Koha::Items;
43
use Koha::Libraries;
44
use Koha::Libraries;
Lines 255-272 sub can_be_transferred { Link Here
255
256
256
=head3 pickup_locations
257
=head3 pickup_locations
257
258
258
    my $pickup_locations = $biblio->pickup_locations( { patron => $patron } );
259
    my $pickup_locations = $biblio->pickup_locations({ patron => $patron });
259
260
260
Returns a Koha::Libraries set of possible pickup locations for this biblio's items,
261
Returns a Koha::Libraries set of possible pickup locations for this biblio's items,
261
according to patron's home library and if item can be transferred to each pickup location.
262
according to patron's home library and if item can be transferred to each pickup location.
262
263
263
Patron is a required parameter.
264
Throws a I<Koha::Exceptions::MissingParameter> exception if the B<mandatory> parameter I<patron>
265
is not passed.
264
266
265
=cut
267
=cut
266
268
267
sub pickup_locations {
269
sub pickup_locations {
268
    my ( $self, $params ) = @_;
270
    my ( $self, $params ) = @_;
269
271
272
    Koha::Exceptions::MissingParameter->throw( parameter => 'patron' )
273
      unless exists $params->{patron};
274
270
    my $patron = $params->{patron};
275
    my $patron = $params->{patron};
271
276
272
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
277
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance();
(-)a/Koha/Biblios.pm (-1 / +5 lines)
Lines 42-54 Koha::Biblios - Koha Biblio object set class Link Here
42
42
43
For a given resultset, it returns all the pickup locations.
43
For a given resultset, it returns all the pickup locations.
44
44
45
Patron is a required parameter.
45
Throws a I<Koha::Exceptions::MissingParameter> exception if the B<mandatory> parameter I<patron>
46
is not passed.
46
47
47
=cut
48
=cut
48
49
49
sub pickup_locations {
50
sub pickup_locations {
50
    my ( $self, $params ) = @_;
51
    my ( $self, $params ) = @_;
51
52
53
    Koha::Exceptions::MissingParameter->throw( parameter => 'patron' )
54
      unless exists $params->{patron};
55
52
    my $patron = $params->{patron};
56
    my $patron = $params->{patron};
53
57
54
    my @pickup_locations;
58
    my @pickup_locations;
(-)a/Koha/Item.pm (-3 / +7 lines)
Lines 36-41 use Koha::Biblio::ItemGroups; Link Here
36
use Koha::Checkouts;
36
use Koha::Checkouts;
37
use Koha::CirculationRules;
37
use Koha::CirculationRules;
38
use Koha::CoverImages;
38
use Koha::CoverImages;
39
use Koha::Exceptions;
39
use Koha::Exceptions::Checkin;
40
use Koha::Exceptions::Checkin;
40
use Koha::Exceptions::Item::Bundle;
41
use Koha::Exceptions::Item::Bundle;
41
use Koha::Exceptions::Item::Transfer;
42
use Koha::Exceptions::Item::Transfer;
Lines 734-753 sub can_be_transferred { Link Here
734
735
735
=head3 pickup_locations
736
=head3 pickup_locations
736
737
737
$pickup_locations = $item->pickup_locations( {patron => $patron } )
738
    my $pickup_locations = $item->pickup_locations({ patron => $patron })
738
739
739
Returns possible pickup locations for this item, according to patron's home library
740
Returns possible pickup locations for this item, according to patron's home library
740
and if item can be transferred to each pickup location.
741
and if item can be transferred to each pickup location.
741
742
742
Patron parameter is required.
743
Throws a I<Koha::Exceptions::MissingParameter> exception if the B<mandatory> parameter I<patron>
744
is not passed.
743
745
744
=cut
746
=cut
745
747
746
sub pickup_locations {
748
sub pickup_locations {
747
    my ($self, $params) = @_;
749
    my ($self, $params) = @_;
748
750
751
    Koha::Exceptions::MissingParameter->throw( parameter => 'patron' )
752
      unless exists $params->{patron};
753
749
    my $patron = $params->{patron};
754
    my $patron = $params->{patron};
750
    # FIXME We should throw an exception if not passed
751
755
752
    my $circ_control_branch =
756
    my $circ_control_branch =
753
      C4::Reserves::GetReservesControlBranch( $self->unblessed(), $patron->unblessed );
757
      C4::Reserves::GetReservesControlBranch( $self->unblessed(), $patron->unblessed );
(-)a/t/db_dependent/Koha/Biblio.t (-2 / +11 lines)
Lines 18-23 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 23; # +1
20
use Test::More tests => 23; # +1
21
use Test::Exception;
21
use Test::Warn;
22
use Test::Warn;
22
23
23
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc );
24
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc );
Lines 214-221 subtest 'is_serial() tests' => sub { Link Here
214
    $schema->storage->txn_rollback;
215
    $schema->storage->txn_rollback;
215
};
216
};
216
217
217
subtest 'pickup_locations' => sub {
218
subtest 'pickup_locations() tests' => sub {
218
    plan tests => 9;
219
220
    plan tests => 11;
219
221
220
    $schema->storage->txn_begin;
222
    $schema->storage->txn_begin;
221
223
Lines 357-362 subtest 'pickup_locations' => sub { Link Here
357
    my $biblio1  = $builder->build_sample_biblio({ title => '1' });
359
    my $biblio1  = $builder->build_sample_biblio({ title => '1' });
358
    my $biblio2  = $builder->build_sample_biblio({ title => '2' });
360
    my $biblio2  = $builder->build_sample_biblio({ title => '2' });
359
361
362
    throws_ok
363
      { $biblio1->pickup_locations }
364
      'Koha::Exceptions::MissingParameter',
365
      'Exception thrown on missing parameter';
366
367
    is( $@->parameter, 'patron', 'Exception param correctly set' );
368
360
    my $item1_1  = $builder->build_sample_item({
369
    my $item1_1  = $builder->build_sample_item({
361
        biblionumber     => $biblio1->biblionumber,
370
        biblionumber     => $biblio1->biblionumber,
362
        homebranch       => $library1->branchcode,
371
        homebranch       => $library1->branchcode,
(-)a/t/db_dependent/Koha/Biblios.t (-1 / +8 lines)
Lines 234-240 $schema->storage->txn_rollback; Link Here
234
234
235
subtest 'pickup_locations() tests' => sub {
235
subtest 'pickup_locations() tests' => sub {
236
236
237
    plan tests => 1;
237
    plan tests => 3;
238
238
239
    $schema->storage->txn_begin;
239
    $schema->storage->txn_begin;
240
240
Lines 286-291 subtest 'pickup_locations() tests' => sub { Link Here
286
        }
286
        }
287
    );
287
    );
288
288
289
    throws_ok
290
      { $biblios->pickup_locations }
291
      'Koha::Exceptions::MissingParameter',
292
      'Exception thrown on missing parameter';
293
294
    is( $@->parameter, 'patron', 'Exception param correctly set' );
295
289
    my $library_ids = [
296
    my $library_ids = [
290
        Koha::Libraries->search(
297
        Koha::Libraries->search(
291
            {
298
            {
(-)a/t/db_dependent/Koha/Item.t (-3 / +9 lines)
Lines 443-450 subtest "as_marc_field() tests" => sub { Link Here
443
    Koha::Caches->get_instance->clear_from_cache( "MarcStructure-1-" );
443
    Koha::Caches->get_instance->clear_from_cache( "MarcStructure-1-" );
444
};
444
};
445
445
446
subtest 'pickup_locations' => sub {
446
subtest 'pickup_locations() tests' => sub {
447
    plan tests => 66;
447
448
    plan tests => 68;
448
449
449
    $schema->storage->txn_begin;
450
    $schema->storage->txn_begin;
450
451
Lines 496-501 subtest 'pickup_locations' => sub { Link Here
496
        }
497
        }
497
    );
498
    );
498
499
500
    throws_ok
501
      { $item1->pickup_locations }
502
      'Koha::Exceptions::MissingParameter',
503
      'Exception thrown on missing parameter';
504
505
    is( $@->parameter, 'patron', 'Exception param correctly set' );
499
506
500
    my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library1->branchcode, firstname => '1' } } );
507
    my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library1->branchcode, firstname => '1' } } );
501
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
508
    my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } );
502
- 

Return to bug 33447