From e54ecc81508281be6344608c087d580a4a1d7d50 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 26 Oct 2023 14:58:40 -0300 Subject: [PATCH] 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 Signed-off-by: Lucas Gass Signed-off-by: Marcel de Rooy (cherry picked from commit b9ea3eb988b116ffc912fad9315533c7774a3754) Signed-off-by: Fridolin Somers (cherry picked from commit 34d08324fcc20c8c83bbbb87f0f1eff0481638f5) Signed-off-by: Matt Blenkinsop --- Koha/Item.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 9dd7c26db4..128161435f 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1447,7 +1447,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 }; } -- 2.39.5