From 8d8dc552418dc0a95c8baadcfc524382e76d971c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 23 Mar 2018 09:34:46 +0100 Subject: [PATCH] Bug 19974: (QA follow-up) Move lost logic to else branch If an error is raised for the barcode, we should not try to perform the lost logic succeeding it. Futhermore there is no need to go to GetMarcFromKohaField etc. if we just use the output of ModItemFromMarc. Note: It seems unnecessary to clear $itemnumber, but I can understand the anxiety about passing it to the template with op=additem. So just leaving it here. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- cataloguing/additem.pl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index bd394c387f..802e908f01 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -687,20 +687,16 @@ if ($op eq "additem") { # check that the barcode don't exist already my $addedolditem = TransformMarcToKoha($itemtosave); my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'}); - my $item = GetItem( $itemnumber ); if ($exist_itemnumber && $exist_itemnumber != $itemnumber) { push @errors,"barcode_not_unique"; } else { - ModItemFromMarc($itemtosave,$biblionumber,$itemnumber); - $itemnumber=""; - } - my $olditemlost = $item->{'itemlost'}; - - my ($lost_tag,$lost_subfield) = GetMarcFromKohaField("items.itemlost",''); - - my $newitemlost = $itemtosave->subfield( $lost_tag, $lost_subfield ); - if (($olditemlost eq '0' or $olditemlost eq '' ) and $newitemlost ge '1'){ - LostItem( $item->{itemnumber} ); + my $item = GetItem( $itemnumber ); + my $newitem = ModItemFromMarc($itemtosave, $biblionumber, $itemnumber); + $itemnumber = q{}; + my $olditemlost = $item->{itemlost}; + my $newitemlost = $newitem->{itemlost}; + LostItem( $item->{itemnumber} ) + if $newitemlost && $newitemlost ge '1' && !$olditemlost; } $nextop="additem"; } elsif ($op eq "delinkitem"){ -- 2.39.5