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 <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2018-03-23 09:34:46 +01:00 committed by Jonathan Druart
parent 6fc6715350
commit 8d8dc55241
1 changed files with 7 additions and 11 deletions

View File

@ -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"){