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

(-)a/Koha/Biblio.pm (+16 lines)
Lines 33-38 use base qw(Koha::Object); Link Here
33
use Koha::Acquisition::Orders;
33
use Koha::Acquisition::Orders;
34
use Koha::ArticleRequests;
34
use Koha::ArticleRequests;
35
use Koha::Biblio::Metadatas;
35
use Koha::Biblio::Metadatas;
36
use Koha::Biblio::ItemGroups;
36
use Koha::Biblioitems;
37
use Koha::Biblioitems;
37
use Koha::Checkouts;
38
use Koha::Checkouts;
38
use Koha::CirculationRules;
39
use Koha::CirculationRules;
Lines 118-123 sub active_orders { Link Here
118
    return $self->orders->search({ datecancellationprinted => undef });
119
    return $self->orders->search({ datecancellationprinted => undef });
119
}
120
}
120
121
122
=head3 item_groups
123
124
my $item_groups = $biblio->item_groups();
125
126
Returns a Koha::Biblio::ItemGroups object
127
128
=cut
129
130
sub item_groups {
131
    my ( $self ) = @_;
132
133
    my $item_groups = $self->_result->item_groups;
134
    return Koha::Biblio::ItemGroups->_new_from_dbic($item_groups);
135
}
136
121
=head3 can_article_request
137
=head3 can_article_request
122
138
123
my $bool = $biblio->can_article_request( $borrower );
139
my $bool = $biblio->can_article_request( $borrower );
(-)a/Koha/Item.pm (-4 / +26 lines)
Lines 31-52 use C4::ClassSource qw( GetClassSort ); Link Here
31
use C4::Log qw( logaction );
31
use C4::Log qw( logaction );
32
32
33
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
33
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
34
use Koha::Biblio::ItemGroups;
34
use Koha::Checkouts;
35
use Koha::Checkouts;
35
use Koha::CirculationRules;
36
use Koha::CirculationRules;
36
use Koha::CoverImages;
37
use Koha::CoverImages;
37
use Koha::SearchEngine::Indexer;
38
use Koha::Exceptions::Item::Transfer;
38
use Koha::Exceptions::Item::Transfer;
39
use Koha::Item::Attributes;
39
use Koha::Item::Transfer::Limits;
40
use Koha::Item::Transfer::Limits;
40
use Koha::Item::Transfers;
41
use Koha::Item::Transfers;
41
use Koha::Item::Attributes;
42
use Koha::ItemTypes;
42
use Koha::ItemTypes;
43
use Koha::Libraries;
43
use Koha::Patrons;
44
use Koha::Patrons;
44
use Koha::Plugins;
45
use Koha::Plugins;
45
use Koha::Libraries;
46
use Koha::Result::Boolean;
47
use Koha::SearchEngine::Indexer;
46
use Koha::StockRotationItem;
48
use Koha::StockRotationItem;
47
use Koha::StockRotationRotas;
49
use Koha::StockRotationRotas;
48
use Koha::TrackedLinks;
50
use Koha::TrackedLinks;
49
use Koha::Result::Boolean;
50
51
51
use base qw(Koha::Object);
52
use base qw(Koha::Object);
52
53
Lines 412-417 sub checkout { Link Here
412
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
413
    return Koha::Checkout->_new_from_dbic( $checkout_rs );
413
}
414
}
414
415
416
=head3 item_group
417
418
my $item_group = $item->item_group;
419
420
Return the item group for this item
421
422
=cut
423
424
sub item_group {
425
    my ( $self ) = @_;
426
427
    my $item_group_item = $self->_result->item_group_item;
428
    return unless $item_group_item;
429
430
    my $item_group_rs = $item_group_item->item_group;
431
    return unless $item_group_rs;
432
433
    my $item_group = Koha::Biblio::ItemGroup->_new_from_dbic( $item_group_rs );
434
    return $item_group;
435
}
436
415
=head3 holds
437
=head3 holds
416
438
417
my $holds = $item->holds();
439
my $holds = $item->holds();
(-)a/t/db_dependent/Koha/Biblio.t (-1 / +28 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 21; # +1
20
use Test::More tests => 22; # +1
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc );
23
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc );
Lines 1026-1031 subtest 'Recalls tests' => sub { Link Here
1026
    $schema->storage->txn_rollback;
1026
    $schema->storage->txn_rollback;
1027
};
1027
};
1028
1028
1029
subtest 'item_groups() tests' => sub {
1030
1031
    plan tests => 6;
1032
1033
    $schema->storage->txn_begin;
1034
1035
    my $biblio = $builder->build_sample_biblio();
1036
1037
    my @item_groups = $biblio->item_groups->as_list;
1038
    is( scalar(@item_groups), 0, 'Got zero item groups');
1039
1040
    my $item_group_1 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1041
1042
    @item_groups = $biblio->item_groups->as_list;
1043
    is( scalar(@item_groups), 1, 'Got one item group');
1044
    is( $item_groups[0]->id, $item_group_1->id, 'Got correct item group');
1045
1046
    my $item_group_2 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1047
1048
    @item_groups = $biblio->item_groups->as_list;
1049
    is( scalar(@item_groups), 2, 'Got two item groups');
1050
    is( $item_groups[0]->id, $item_group_1->id, 'Got correct item group 1');
1051
    is( $item_groups[1]->id, $item_group_2->id, 'Got correct item group 2');
1052
1053
    $schema->storage->txn_rollback;
1054
};
1055
1029
sub component_record1 {
1056
sub component_record1 {
1030
    my $marc = MARC::Record->new;
1057
    my $marc = MARC::Record->new;
1031
    $marc->append_fields(
1058
    $marc->append_fields(
(-)a/t/db_dependent/Koha/Item.t (-1 / +25 lines)
Lines 1496-1498 subtest 'Notforloan tests' => sub { Link Here
1496
1496
1497
    $schema->storage->txn_rollback;
1497
    $schema->storage->txn_rollback;
1498
};
1498
};
1499
- 
1499
1500
subtest 'item_group() tests' => sub {
1501
1502
    plan tests => 4;
1503
1504
    $schema->storage->txn_begin;
1505
1506
    my $biblio = $builder->build_sample_biblio();
1507
    my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1508
    my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber });
1509
1510
    is( $item_1->item_group, undef, 'Item 1 has no item group');
1511
    is( $item_2->item_group, undef, 'Item 2 has no item group');
1512
1513
    my $item_group_1 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1514
    my $item_group_2 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store();
1515
1516
    $item_group_1->add_item({ item_id => $item_1->id });
1517
    $item_group_2->add_item({ item_id => $item_2->id });
1518
1519
    is( $item_1->item_group->id, $item_group_1->id, 'Got item group 1 correctly' );
1520
    is( $item_2->item_group->id, $item_group_2->id, 'Got item group 2 correctly' );
1521
1522
    $schema->storage->txn_rollback;
1523
};

Return to bug 24857