refs #5890 feat:trigger
This commit is contained in:
parent
9698c049fc
commit
6db1696094
|
@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_ad
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Guarda la ubicación para el contenido de una colección
|
* Reserva cantidades con ubicaciones para el contenido de una colección
|
||||||
*
|
*
|
||||||
* @param vCollectionFk Identificador de collection
|
* @param vCollectionFk Identificador de collection
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_INSERT`
|
|
||||||
AFTER INSERT ON `itemShelving`
|
|
||||||
FOR EACH ROW
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
INSERT INTO vn.itemShelvingLog(
|
|
||||||
itemShelvingFk,
|
|
||||||
workerFk,
|
|
||||||
accion,
|
|
||||||
itemFk,
|
|
||||||
shelvingFk,
|
|
||||||
visible,
|
|
||||||
`grouping`,
|
|
||||||
packing,
|
|
||||||
available)
|
|
||||||
VALUES( NEW.id,
|
|
||||||
NEW.userFk,
|
|
||||||
'CREA REGISTRO',
|
|
||||||
NEW.itemFk,
|
|
||||||
NEW.shelvingFk,
|
|
||||||
NEW.visible,
|
|
||||||
NEW.`grouping`,
|
|
||||||
NEW.packing,
|
|
||||||
NEW.available);
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,16 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_UPDATE`
|
|
||||||
AFTER UPDATE ON `itemShelving`
|
|
||||||
FOR EACH ROW
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO itemShelvingLog
|
|
||||||
SET itemShelvingFk = NEW.id,
|
|
||||||
workerFk = account.myUser_getId(),
|
|
||||||
accion = 'CAMBIO',
|
|
||||||
itemFk = NEW.itemFk,
|
|
||||||
shelvingFk = NEW.shelvingFk,
|
|
||||||
visible = NEW.visible,
|
|
||||||
`grouping` = NEW.`grouping`,
|
|
||||||
packing = NEW.packing;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,10 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_BEFORE_INSERT`
|
|
||||||
BEFORE INSERT ON `itemShelving`
|
|
||||||
FOR EACH ROW
|
|
||||||
BEGIN
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
|
||||||
SET NEW.userFk = account.myUser_getId();
|
|
||||||
SET NEW.available = NEW.visible;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,15 +1,19 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_INSERT`
|
||||||
AFTER INSERT ON `itemShelving`
|
AFTER INSERT ON `itemShelving`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
INSERT INTO vn.itemShelvingLog( itemShelvingFk,
|
BEGIN
|
||||||
|
|
||||||
|
INSERT INTO vn.itemShelvingLog(
|
||||||
|
itemShelvingFk,
|
||||||
workerFk,
|
workerFk,
|
||||||
accion,
|
accion,
|
||||||
itemFk,
|
itemFk,
|
||||||
shelvingFk,
|
shelvingFk,
|
||||||
visible,
|
visible,
|
||||||
`grouping`,
|
`grouping`,
|
||||||
packing)
|
packing,
|
||||||
|
available)
|
||||||
VALUES( NEW.id,
|
VALUES( NEW.id,
|
||||||
NEW.userFk,
|
NEW.userFk,
|
||||||
'CREA REGISTRO',
|
'CREA REGISTRO',
|
||||||
|
@ -17,6 +21,7 @@ INSERT INTO vn.itemShelvingLog( itemShelvingFk,
|
||||||
NEW.shelvingFk,
|
NEW.shelvingFk,
|
||||||
NEW.visible,
|
NEW.visible,
|
||||||
NEW.`grouping`,
|
NEW.`grouping`,
|
||||||
NEW.packing
|
NEW.packing,
|
||||||
)$$
|
NEW.available);
|
||||||
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -1,8 +1,9 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate`
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_UPDATE`
|
||||||
AFTER UPDATE ON `itemShelving`
|
AFTER UPDATE ON `itemShelving`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
INSERT INTO itemShelvingLog
|
BEGIN
|
||||||
|
INSERT INTO itemShelvingLog
|
||||||
SET itemShelvingFk = NEW.id,
|
SET itemShelvingFk = NEW.id,
|
||||||
workerFk = account.myUser_getId(),
|
workerFk = account.myUser_getId(),
|
||||||
accion = 'CAMBIO',
|
accion = 'CAMBIO',
|
||||||
|
@ -10,5 +11,8 @@ INSERT INTO itemShelvingLog
|
||||||
shelvingFk = NEW.shelvingFk,
|
shelvingFk = NEW.shelvingFk,
|
||||||
visible = NEW.visible,
|
visible = NEW.visible,
|
||||||
`grouping` = NEW.`grouping`,
|
`grouping` = NEW.`grouping`,
|
||||||
packing = NEW.packing$$
|
packing = NEW.packing,
|
||||||
|
available = NEW.available;
|
||||||
|
|
||||||
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeIn
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
SET NEW.userFk = account.myUser_getId();
|
SET NEW.userFk = account.myUser_getId();
|
||||||
|
SET NEW.available = NEW.visible;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,9 +3,15 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeUp
|
||||||
BEFORE UPDATE ON `itemShelving`
|
BEFORE UPDATE ON `itemShelving`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
IF NEW.userFk IS NULL THEN
|
IF NEW.userFk IS NULL THEN
|
||||||
SET NEW.userFk = account.myUser_getId();
|
SET NEW.userFk = account.myUser_getId();
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF (NEW.visible <> OLD.visible) THEN
|
||||||
|
SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0);
|
||||||
|
END IF;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue