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

(-)a/Koha/Item.pm (-7 / +6 lines)
Lines 1737-1745 sub to_api { Link Here
1737
1737
1738
    $overrides->{effective_item_type_id} = $self->effective_itemtype;
1738
    $overrides->{effective_item_type_id} = $self->effective_itemtype;
1739
1739
1740
    my $itype_notforloan = $self->itemtype->notforloan;
1740
    $overrides->{effective_not_for_loan_status} = $self->effective_notforloan;
1741
    $overrides->{effective_not_for_loan_status} =
1742
        ( defined $itype_notforloan && !$self->notforloan ) ? $itype_notforloan : $self->notforloan;
1743
1741
1744
    return { %$response, %$overrides };
1742
    return { %$response, %$overrides };
1745
}
1743
}
Lines 1835-1851 sub item_type { Link Here
1835
    return shift->itemtype;
1833
    return shift->itemtype;
1836
}
1834
}
1837
1835
1838
=head3 not_for_loan
1836
=head3 effective_not_for_loan_status
1839
1837
1840
  my $nfl = $item->not_for_loan;
1838
  my $nfl = $item->effective_not_for_loan_status;
1841
1839
1842
Returns the effective not for loan status of the item
1840
Returns the effective not for loan status of the item
1843
1841
1844
=cut
1842
=cut
1845
1843
1846
sub not_for_loan {
1844
sub effective_not_for_loan_status {
1847
    my ($self) = @_;
1845
    my ($self) = @_;
1848
    return $self->notforloan ? $self->notforloan : $self->itemtype->notforloan;
1846
    my $itype_notforloan = $self->itemtype->notforloan;
1847
    return ( defined($itype_notforloan) && !$self->notforloan ) ? $itype_notforloan : $self->notforloan;
1849
}
1848
}
1850
1849
1851
=head3 orders
1850
=head3 orders
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc (-2 / +2 lines)
Lines 43-51 Link Here
43
    [% END %]
43
    [% END %]
44
[% END %]
44
[% END %]
45
45
46
[% IF ( item.not_for_loan ) %]
46
[% IF ( item.effective_not_for_loan_status ) %]
47
    [% SET itemavailable = 0 %]
47
    [% SET itemavailable = 0 %]
48
    [% notforloan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.not_for_loan ) %]
48
    [% notforloan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.effective_not_for_loan_status ) %]
49
    [% IF notforloan_description %]
49
    [% IF notforloan_description %]
50
        <span class="item-status notforloan">[% notforloan_description | html %]</span>
50
        <span class="item-status notforloan">[% notforloan_description | html %]</span>
51
    [% ELSE %]
51
    [% ELSE %]
(-)a/t/db_dependent/Koha/Item.t (-11 / +10 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use utf8;
21
use utf8;
22
22
23
use Test::More tests => 36;
23
use Test::More tests => 35;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 2747-2753 subtest 'check_booking tests' => sub { Link Here
2747
    $schema->storage->txn_rollback;
2747
    $schema->storage->txn_rollback;
2748
};
2748
};
2749
2749
2750
subtest 'not_for_loan() tests' => sub {
2750
subtest 'effective_not_for_loan_status() tests' => sub {
2751
2751
2752
    plan tests => 5;
2752
    plan tests => 5;
2753
2753
Lines 2769-2782 subtest 'not_for_loan() tests' => sub { Link Here
2769
    note("item-level_itypes: 0");
2769
    note("item-level_itypes: 0");
2770
2770
2771
    is(
2771
    is(
2772
        $item->not_for_loan, $item->notforloan,
2772
        $item->effective_not_for_loan_status, $item->notforloan,
2773
        '->not_for_loan returns item specific notforloan value when defined and non-zero'
2773
        '->effective_not_for_loan_status returns item specific notforloan value when defined and non-zero'
2774
    );
2774
    );
2775
2775
2776
    $item->notforloan(0)->store();
2776
    $item->notforloan(0)->store();
2777
    is(
2777
    is(
2778
        $item->not_for_loan, $biblio_itype->notforloan,
2778
        $item->effective_not_for_loan_status, $biblio_itype->notforloan,
2779
        '->not_for_loan returns biblio level itype notforloan value when item notforloan is 0'
2779
        '->effective_not_for_loan_status returns biblio level itype notforloan value when item notforloan is 0'
2780
    );
2780
    );
2781
2781
2782
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
2782
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
Lines 2784-2797 subtest 'not_for_loan() tests' => sub { Link Here
2784
2784
2785
    $item->notforloan(1)->store();
2785
    $item->notforloan(1)->store();
2786
    is(
2786
    is(
2787
        $item->not_for_loan, $item->notforloan,
2787
        $item->effective_not_for_loan_status, $item->notforloan,
2788
        '->not_for_loan returns item specific notforloan value when defined and non-zero'
2788
        '->effective_not_for_loan_status returns item specific notforloan value when defined and non-zero'
2789
    );
2789
    );
2790
2790
2791
    $item->notforloan(0)->store();
2791
    $item->notforloan(0)->store();
2792
    is(
2792
    is(
2793
        $item->not_for_loan, $item_itype->notforloan,
2793
        $item->effective_not_for_loan_status, $item_itype->notforloan,
2794
        '->not_for_loan returns biblio level itype notforloan value when item notforloan is 0'
2794
        '->effective_not_for_loan_status returns biblio level itype notforloan value when item notforloan is 0'
2795
    );
2795
    );
2796
2796
2797
    $schema->storage->txn_rollback;
2797
    $schema->storage->txn_rollback;
2798
- 

Return to bug 28762