From 74f6b9a48d1ebddeafe60a95c7bc4b7f1ec93895 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 (cherry picked from commit 2255d42abdb45955e82634a7b6fe1e1af0242361) Signed-off-by: Jacob O'Mara (cherry picked from commit 655cd366e0fdc33512cfc546301854cc67a6a03a) Signed-off-by: Lucas Gass --- C4/Items.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C4/Items.pm b/C4/Items.pm index 0f540e0786..c2ae579e4c 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