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

(-)a/Koha/Item.pm (+14 lines)
Lines 38-43 use Koha::Checkouts; Link Here
38
use Koha::CirculationRules;
38
use Koha::CirculationRules;
39
use Koha::Item::Transfer::Limits;
39
use Koha::Item::Transfer::Limits;
40
use Koha::Item::Transfers;
40
use Koha::Item::Transfers;
41
use Koha::ItemTypes;
41
use Koha::Patrons;
42
use Koha::Patrons;
42
use Koha::Plugins;
43
use Koha::Plugins;
43
use Koha::Libraries;
44
use Koha::Libraries;
Lines 819-824 sub to_api_mapping { Link Here
819
    };
820
    };
820
}
821
}
821
822
823
=head3 itemtype
824
825
    my $itemtype = $item->itemtype({ effective => 1 });
826
827
    Returns Koha object for (effective) itemtype
828
829
=cut
830
831
sub itemtype {
832
    my ( $self, $params ) = @_;
833
    return Koha::ItemTypes->find( $params->{effective} ?  $self->effective_itemtype : $self->itype ); # no FK
834
}
835
822
=head2 Internal methods
836
=head2 Internal methods
823
837
824
=head3 _after_item_action_hooks
838
=head3 _after_item_action_hooks
(-)a/t/db_dependent/Koha/Item.t (-2 / +20 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 6;
22
use Test::More tests => 7;
23
23
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Circulation;
25
use C4::Circulation;
Lines 500-503 subtest 'renewal_branchcode' => sub { Link Here
500
    is( $item->renewal_branchcode, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item");
500
    is( $item->renewal_branchcode, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item");
501
    is( $item->renewal_branchcode({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed");
501
    is( $item->renewal_branchcode({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed");
502
502
503
    $schema->storage->txn_rollback;
504
};
505
506
subtest 'Tests for itemtype' => sub {
507
    plan tests => 4;
508
    $schema->storage->txn_begin;
509
510
    my $biblio = $builder->build_sample_biblio;
511
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
512
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, itype => $itemtype->itemtype });
513
514
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
515
    is( $item->itemtype({ effective => 1 })->itemtype, $item->itype, 'Pref enabled, effective parameter' );
516
    is( $item->itemtype->itemtype, $item->itype, 'Pref enabled, no parameter' );
517
    t::lib::Mocks::mock_preference('item-level_itypes', 0);
518
    is( $item->itemtype({ effective => 1 })->itemtype, $biblio->biblioitem->itemtype, 'Pref disabled, effective parameter' );
519
    is( $item->itemtype->itemtype, $item->itype, 'Pref disabled, no parameter' );
520
521
    $schema->storage->txn_rollback;
503
};
522
};
504
- 

Return to bug 20469