From 2255d42abdb45955e82634a7b6fe1e1af0242361 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 13 Dec 2022 14:24:13 +0000 Subject: [PATCH] Bug 32456: Preserve date accessioned if a date is not explicitly passed To test: 1 - Edit an item record to have a blank date accessioned 2 - Save the record as marcxml from the detail page 3 - Edit the item to have an accession date 4 - Stage and import the file - matching in KohaBiblio and replacing items 5 - Import the file 6 - Confirm the date accessioned is cleared 7 - Apply patch 8 - Provide an accession date for the item 9 - Stage and import the file again 10 - Confirm the date remained 11 - Edit the item to remove the date 12 - Confirm you can manually blank the field Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- C4/Items.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C4/Items.pm b/C4/Items.pm index 9d443bb6ec..de776d5dfe 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -307,6 +307,11 @@ sub ModItemFromMarc { # to prevent it being blanked by set_or_blank $item->{onloan} = $item_object->onloan if( $item_object->onloan && !defined $item->{onloan} ); + # When importing and replacing items we should not remove the dateacquired so we should set it + # to the existing value + $item->{dateaccessioned} = $item_object->dateaccessioned + if ( $item_object->dateaccessioned && !defined $item->{dateaccessioned} ); + 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