From 013036838a62f0e162c5334357bae2be847547f1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Jul 2014 15:09:31 +0200 Subject: [PATCH] Bug 12555: Call DelItem on cancelling a receipt On cancelling a receipt, the items should be deleted using the C4::Items::DelItem subroutine in order to update zebra and sent the items in the deleteditems table. The entries in aqorders_items will automatically deleted by the DBMS (on delete cascade). Test plan: 0/ Set the AcqCreateItem pref to "on receiving" 1/ Create an order with some items 2/ Receive the items 3/ Note the itemnumber in the items table 4/ Cancel the receipt 5/ Verify the itemnumbers are present in the deleteditems table and the items have been deleted. Signed-off-by: Chris Cormack --- C4/Acquisition.pm | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index f9e8c49..c07fcd7 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1605,21 +1605,13 @@ sub _cancel_items_receipt { $parent_ordernumber ||= $ordernumber; my @itemnumbers = GetItemnumbersFromOrder($ordernumber); - if(C4::Context->preference('AcqCreateItem') eq 'receiving') { - # Remove items that were created at receipt - my $query = qq{ - DELETE FROM items, aqorders_items - USING items, aqorders_items - WHERE items.itemnumber = ? AND aqorders_items.itemnumber = ? - }; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare($query); - foreach my $itemnumber (@itemnumbers) { - $sth->execute($itemnumber, $itemnumber); + foreach my $itemnumber (@itemnumbers) { + if(C4::Context->preference('AcqCreateItem') eq 'receiving') { + # Remove items that were created at receipt + C4::Items::DelItem({ itemnumber => $itemnumber }); } - } else { - # Update items - foreach my $itemnumber (@itemnumbers) { + else { + # Update items ModItemOrder($itemnumber, $parent_ordernumber); } } -- 2.1.0