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
Showing only changes of commit ae999f780e - Show all commits

View File

@ -220,6 +220,15 @@ BEGIN
vEntryFk
FROM tInventory;
-- Eliminamos artículos que no estén en el inventario sin compra o venta
DELETE i.id 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 item i
JOIN tInventory i2 ON i2.itemFk = i.id