From 55cc21278798b6b5706050eaf377b5eb3f569bcb Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 14 Jan 2022 19:59:30 +0000 Subject: [PATCH] Bug 29719: Do not clear onloan value when not passed in MARC We blank the field to prevent users from setting it during import, but this has the affect of blanking it in the DB. This patch replaces the onloan field when not passed in to 'ModItemFromMARC' to preserve the value To test: 1 - Check an item out to a paron 2 - Export the item using Tools->Export data 3 - Stage the record for import 4 - Match on 999c and replace items 5 - Import the batch 6 - View the record and note item is checked out and Available 7 - In the DB note the onloan value is now null 8 - Check in the item 9 - Apply patch 10 - Repeat 1-5 11 - View the record and note item is checked out 12 - In the DB note the onloan value matches the due date Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- C4/Items.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/C4/Items.pm b/C4/Items.pm index a2bb4011a4..9808fadd1f 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -303,6 +303,10 @@ sub ModItemFromMarc { my $item_object = Koha::Items->find($itemnumber); my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); + # When importing items we blank this column, we need to set it to the existing value + # to prevent it being blanked by set_or_blank + $item->{onloan} = $item_object->onloan if( $item_object->onloan && !defined $item->{onloan} ); + my ( $perm_loc_tag, $perm_loc_subfield ) = C4::Biblio::GetMarcFromKohaField( "items.permanent_location" ); my $has_permanent_location = defined $perm_loc_tag && defined $item_marc->subfield( $perm_loc_tag, $perm_loc_subfield ); -- 2.39.5