From 0aa2cf1d7cc12fb70404b25f0bf2ef8d556ddf72 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 Content-Type: text/plain; charset=utf-8 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 --- cataloguing/additem.pl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index bd394c3..802e908 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.1.4