From fdefef14445bc8d680496ae9f52f221983db2ec5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 22 Jul 2024 16:32:34 +0100 Subject: [PATCH] Bug 28762: Rename not_for_loan as effective_not_for_loan_status This patch updates the method name to follow current conventions. Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize --- Koha/Item.pm | 13 ++++++------- .../prog/en/includes/item-status.inc | 4 ++-- t/db_dependent/Koha/Item.t | 18 +++++++++--------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index ed573d1b6a..64c18e47f4 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1737,9 +1737,7 @@ sub to_api { $overrides->{effective_item_type_id} = $self->effective_itemtype; - my $itype_notforloan = $self->itemtype->notforloan; - $overrides->{effective_not_for_loan_status} = - ( defined $itype_notforloan && !$self->notforloan ) ? $itype_notforloan : $self->notforloan; + $overrides->{effective_not_for_loan_status} = $self->effective_not_for_loan_status; return { %$response, %$overrides }; } @@ -1835,17 +1833,18 @@ sub item_type { return shift->itemtype; } -=head3 not_for_loan +=head3 effective_not_for_loan_status - my $nfl = $item->not_for_loan; + my $nfl = $item->effective_not_for_loan_status; Returns the effective not for loan status of the item =cut -sub not_for_loan { +sub effective_not_for_loan_status { my ($self) = @_; - return $self->notforloan ? $self->notforloan : $self->itemtype->notforloan; + my $itype_notforloan = $self->itemtype->notforloan; + return ( defined($itype_notforloan) && !$self->notforloan ) ? $itype_notforloan : $self->notforloan; } =head3 orders diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc index 75ce267927..a5dca17ec9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/item-status.inc @@ -43,9 +43,9 @@ [% END %] [% END %] -[% IF ( item.not_for_loan ) %] +[% IF ( item.effective_not_for_loan_status ) %] [% SET itemavailable = 0 %] - [% notforloan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.not_for_loan ) %] + [% notforloan_description = AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.effective_not_for_loan_status ) %] [% IF notforloan_description %] [% notforloan_description | html %] [% ELSE %] diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index c6ec27b880..d1d85dac72 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -2747,7 +2747,7 @@ subtest 'check_booking tests' => sub { $schema->storage->txn_rollback; }; -subtest 'not_for_loan() tests' => sub { +subtest 'effective_not_for_loan_status() tests' => sub { plan tests => 5; @@ -2769,14 +2769,14 @@ subtest 'not_for_loan() tests' => sub { note("item-level_itypes: 0"); is( - $item->not_for_loan, $item->notforloan, - '->not_for_loan returns item specific notforloan value when defined and non-zero' + $item->effective_not_for_loan_status, $item->notforloan, + '->effective_not_for_loan_status returns item specific notforloan value when defined and non-zero' ); $item->notforloan(0)->store(); is( - $item->not_for_loan, $biblio_itype->notforloan, - '->not_for_loan returns biblio level itype notforloan value when item notforloan is 0' + $item->effective_not_for_loan_status, $biblio_itype->notforloan, + '->effective_not_for_loan_status returns biblio level itype notforloan value when item notforloan is 0' ); t::lib::Mocks::mock_preference( 'item-level_itypes', 1 ); @@ -2784,14 +2784,14 @@ subtest 'not_for_loan() tests' => sub { $item->notforloan(1)->store(); is( - $item->not_for_loan, $item->notforloan, - '->not_for_loan returns item specific notforloan value when defined and non-zero' + $item->effective_not_for_loan_status, $item->notforloan, + '->effective_not_for_loan_status returns item specific notforloan value when defined and non-zero' ); $item->notforloan(0)->store(); is( - $item->not_for_loan, $item_itype->notforloan, - '->not_for_loan returns biblio level itype notforloan value when item notforloan is 0' + $item->effective_not_for_loan_status, $item_itype->notforloan, + '->effective_not_for_loan_status returns biblio level itype notforloan value when item notforloan is 0' ); $schema->storage->txn_rollback; -- 2.39.5