7631_testToMaster_2426 #2634
|
@ -1,22 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_checkBooked`(
|
|
||||||
vSelf INT
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Comprueba si una entrada está contabilizada,
|
|
||||||
* y si lo está retorna un throw.
|
|
||||||
*
|
|
||||||
* @param vSelf Id de entrada
|
|
||||||
*/
|
|
||||||
DECLARE vIsBooked BOOL;
|
|
||||||
|
|
||||||
SELECT isBooked INTO vIsBooked
|
|
||||||
FROM `entry`
|
|
||||||
WHERE id = vSelf;
|
|
||||||
|
|
||||||
IF vIsBooked AND NOT IFNULL(@isModeInventory, FALSE) THEN
|
|
||||||
CALL util.throw('Entry is already booked');
|
|
||||||
END IF;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_isEditable`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Comprueba si una entrada se puede actualizar
|
||||||
|
* si no se puede retorna un throw.
|
||||||
|
*
|
||||||
|
* @param vSelf Id de entrada
|
||||||
|
*/
|
||||||
|
DECLARE vIsEditable BOOL;
|
||||||
|
|
||||||
|
SELECT e.isBooked INTO vIsEditable
|
||||||
|
FROM `entry` e
|
||||||
|
JOIN entryType et ON et.code = e.typeFk
|
||||||
|
WHERE NOT et.isInformal
|
||||||
|
AND e.id = vSelf;
|
||||||
|
|
||||||
|
IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
|
||||||
|
CALL util.throw('Entry is not editable');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeDelete`
|
||||||
BEFORE DELETE ON `buy`
|
BEFORE DELETE ON `buy`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
CALL entry_checkBooked(OLD.entryFk);
|
CALL entry_isEditable(OLD.entryFk);
|
||||||
IF OLD.printedStickers <> 0 THEN
|
IF OLD.printedStickers <> 0 THEN
|
||||||
CALL util.throw("it is not possible to delete buys with printed labels ");
|
CALL util.throw("it is not possible to delete buys with printed labels ");
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -15,7 +15,7 @@ trig: BEGIN
|
||||||
LEAVE trig;
|
LEAVE trig;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL entry_checkBooked(NEW.entryFk);
|
CALL entry_isEditable(NEW.entryFk);
|
||||||
IF NEW.printedStickers <> 0 THEN
|
IF NEW.printedStickers <> 0 THEN
|
||||||
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
|
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -13,7 +13,7 @@ trig:BEGIN
|
||||||
LEAVE trig;
|
LEAVE trig;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL entry_checkBooked(OLD.entryFk);
|
CALL entry_isEditable(OLD.entryFk);
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
SELECT defaultEntry INTO vDefaultEntry
|
SELECT defaultEntry INTO vDefaultEntry
|
||||||
|
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete`
|
||||||
BEFORE DELETE ON `entry`
|
BEFORE DELETE ON `entry`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
CALL entry_checkBooked(OLD.id);
|
CALL entry_isEditable(OLD.id);
|
||||||
DELETE FROM buy WHERE entryFk = OLD.id;
|
DELETE FROM buy WHERE entryFk = OLD.id;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -9,7 +9,7 @@ BEGIN
|
||||||
DECLARE vTotalBuy INT;
|
DECLARE vTotalBuy INT;
|
||||||
|
|
||||||
IF NEW.isBooked = OLD.isBooked THEN
|
IF NEW.isBooked = OLD.isBooked THEN
|
||||||
CALL entry_checkBooked(OLD.id);
|
CALL entry_isEditable(OLD.id);
|
||||||
ELSE
|
ELSE
|
||||||
IF NEW.isBooked THEN
|
IF NEW.isBooked THEN
|
||||||
SELECT COUNT(*) INTO vTotalBuy
|
SELECT COUNT(*) INTO vTotalBuy
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate,changedModel,`action`);
|
Loading…
Reference in New Issue