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

(-)a/Koha/Item.pm (-4 / +4 lines)
Lines 822-836 sub to_api_mapping { Link Here
822
822
823
=head3 itemtype
823
=head3 itemtype
824
824
825
    my $itemtype = $item->itemtype({ effective => 1 });
825
    my $itemtype = $item->itemtype;
826
826
827
    Returns Koha object for (effective) itemtype
827
    Returns Koha object for effective itemtype
828
828
829
=cut
829
=cut
830
830
831
sub itemtype {
831
sub itemtype {
832
    my ( $self, $params ) = @_;
832
    my ( $self ) = @_;
833
    return Koha::ItemTypes->find( $params->{effective} ?  $self->effective_itemtype : $self->itype ); # no FK
833
    return Koha::ItemTypes->find( $self->effective_itemtype );
834
}
834
}
835
835
836
=head2 Internal methods
836
=head2 Internal methods
(-)a/t/db_dependent/Koha/Item.t (-6 / +3 lines)
Lines 504-510 subtest 'renewal_branchcode' => sub { Link Here
504
};
504
};
505
505
506
subtest 'Tests for itemtype' => sub {
506
subtest 'Tests for itemtype' => sub {
507
    plan tests => 4;
507
    plan tests => 2;
508
    $schema->storage->txn_begin;
508
    $schema->storage->txn_begin;
509
509
510
    my $biblio = $builder->build_sample_biblio;
510
    my $biblio = $builder->build_sample_biblio;
Lines 512-522 subtest 'Tests for itemtype' => sub { Link Here
512
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, itype => $itemtype->itemtype });
512
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, itype => $itemtype->itemtype });
513
513
514
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
514
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
515
    is( $item->itemtype({ effective => 1 })->itemtype, $item->itype, 'Pref enabled, effective parameter' );
515
    is( $item->itemtype->itemtype, $item->itype, 'Pref enabled' );
516
    is( $item->itemtype->itemtype, $item->itype, 'Pref enabled, no parameter' );
517
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
516
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
518
    is( $item->itemtype({ effective => 1 })->itemtype, $biblio->biblioitem->itemtype, 'Pref disabled, effective parameter' );
517
    is( $item->itemtype->itemtype, $biblio->biblioitem->itemtype, 'Pref disabled' );
519
    is( $item->itemtype->itemtype, $item->itype, 'Pref disabled, no parameter' );
520
518
521
    $schema->storage->txn_rollback;
519
    $schema->storage->txn_rollback;
522
};
520
};
523
- 

Return to bug 20469