refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale #3057

Merged
guillermo merged 9 commits from 6824-itemShelvingSaleNoDelete into dev 2024-10-07 05:50:49 +00:00
1 changed files with 22 additions and 10 deletions
Showing only changes of commit 62bd2ae03b - Show all commits

View File

@ -2,14 +2,26 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete`
BEFORE DELETE ON `itemShelving` BEFORE DELETE ON `itemShelving`
FOR EACH ROW FOR EACH ROW
INSERT INTO vn.itemShelvingLog(itemShelvingFk, BEGIN
workerFk, DECLARE vItemShelvingSaleExists BOOL;
accion,
shelvingFk, SELECT COUNT(*) INTO vItemShelvingSaleExists
guillermo marked this conversation as resolved Outdated

itemShelvingSale esta es la part que no cal fer, sino canviar en itemShelvingSale a un Fk restrict

itemShelvingSale esta es la part que no cal fer, sino canviar en itemShelvingSale a un Fk restrict
itemFk) FROM itemShelvingSale
VALUES( OLD.id, WHERE itemShelvingFk = OLD.id;
account.myUser_getId(),
'ELIMINADO', IF vItemShelvingSaleExists AND @canDeleteItemShelvingSale IS NULL THEN
OLD.shelvingFk, CALL util.throw('Cannot delete item shelving with item shelving sale');
OLD.itemFk)$$ END IF;
INSERT INTO vn.itemShelvingLog(itemShelvingFk,
workerFk,
accion,
shelvingFk,
itemFk)
VALUES( OLD.id,
account.myUser_getId(),
'ELIMINADO',
OLD.shelvingFk,
OLD.itemFk);
END$$
DELIMITER ; DELIMITER ;