WIP: feat: refs #7377 Delete items #2625

Closed
guillermo wants to merge 2 commits from 7377-deleteItems into dev
1 changed files with 9 additions and 0 deletions

View File

@ -220,6 +220,15 @@ BEGIN
vEntryFk vEntryFk
FROM tInventory; FROM tInventory;
-- Eliminamos artículos que no estén en el inventario sin compra o venta
DELETE i.* FROM item i
LEFT JOIN tInventory ti ON ti.itemFk = i.id
LEFT JOIN sale s ON s.itemFk = i.id
LEFT JOIN buy b ON b.itemFk = i.id
WHERE ti.itemFk IS NULL
AND s.id IS NULL
AND b.id IS NULL;
-- Update the 'lastUsed' field of the item -- Update the 'lastUsed' field of the item
UPDATE item i UPDATE item i
JOIN tInventory i2 ON i2.itemFk = i.id JOIN tInventory i2 ON i2.itemFk = i.id