Browse Source

Bug 12583: DelItem prototype - prefer hashref

To delete an item, only the itemnumber should be mandatory. The DelItem
routine can retrieve the biblionumber from the itemnumber.

Test plan:
Verify that t/db_dependent/Items/DelItem.t passes

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
MM-OPAC/theme_dep
Jonathan Druart 8 years ago
committed by Tomas Cohen Arazi
parent
commit
ba81cdcdb2
  1. 7
      C4/Acquisition.pm
  2. 18
      C4/Items.pm
  3. 2
      t/db_dependent/Items.t

7
C4/Acquisition.pm

@ -1861,7 +1861,12 @@ sub DelOrder {
$sth->execute( $bibnum, $ordernumber );
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
foreach my $itemnumber (@itemnumbers){
C4::Items::DelItem( $bibnum, $itemnumber );
C4::Items::DelItem(
{
biblionumber => $bibnum,
itemnumber => $itemnumber
}
);
}
return;
}

18
C4/Items.pm

@ -632,14 +632,21 @@ sub ModDateLastSeen {
=head2 DelItem
DelItem( $biblionumber, $itemnumber );
DelItem({ itemnumber => $itemnumber, [ biblionumber => $biblionumber ] } );
Exported function (core API) for deleting an item record in Koha.
=cut
sub DelItem {
my ( $biblionumber, $itemnumber ) = @_;
my ( $params ) = @_;
my $itemnumber = $params->{itemnumber};
my $biblionumber = $params->{biblionumber};
unless ($biblionumber) {
$biblionumber = C4::Biblio::GetBiblionumberFromItemnumber($itemnumber);
}
# FIXME check the item has no current issues
_koha_delete_item( $itemnumber );
@ -2287,7 +2294,12 @@ sub DelItemCheck {
} elsif ($countanalytics > 0){
$error = "linked_analytics";
} else {
DelItem($biblionumber, $itemnumber);
DelItem(
{
biblionumber => $biblionumber,
itemnumber => $itemnumber
}
);
return 1;
}
}

2
t/db_dependent/Items.t

@ -58,7 +58,7 @@ subtest 'General Add, Get and Del tests' => sub {
cmp_ok($moditem->{'barcode'}, '==', '987654321', 'Modified item barcode successfully to: '.$moditem->{'barcode'} . '.');
# Delete item.
DelItem($bibnum, $itemnumber);
DelItem({ biblionumber => $bibnum, itemnumber => $itemnumber });
my $getdeleted = GetItem($itemnumber);
is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected.");

Loading…
Cancel
Save