Bug 35167: Make 'effective_not_for_loan_status' fallback to 0 if itype has it undef

This patch makes the effective not for loan status be set the item value
if not defined at itype level.

To test:
1. Apply the regressions tests patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/items.t
=> FAIL: Tests fail!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
(cherry picked from commit b9ea3eb988)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Tomas Cohen Arazi 2023-10-26 14:58:40 -03:00 committed by Fridolin Somers
parent d37fbdb665
commit 34d08324fc
1 changed files with 4 additions and 1 deletions

View File

@ -1444,7 +1444,10 @@ sub to_api {
my $overrides = {};
$overrides->{effective_item_type_id} = $self->effective_itemtype;
$overrides->{effective_not_for_loan_status} = $self->notforloan ? $self->notforloan : $self->itemtype->notforloan;
my $itype_notforloan = $self->itemtype->notforloan;
$overrides->{effective_not_for_loan_status} =
( defined $itype_notforloan && !$self->notforloan ) ? $itype_notforloan : $self->notforloan;
return { %$response, %$overrides };
}