feat: refs #7024 Added entry_checkBooked #2201
|
@ -0,0 +1,22 @@
|
|||
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 THEN
|
||||
CALL util.throw('Entry is already booked');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeDelete`
|
|||
BEFORE DELETE ON `buy`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL entry_checkBooked(OLD.entryFk);
|
||||
IF OLD.printedStickers <> 0 THEN
|
||||
CALL util.throw("it is not possible to delete buys with printed labels ");
|
||||
END IF;
|
||||
|
|
|
@ -15,6 +15,7 @@ trig: BEGIN
|
|||
LEAVE trig;
|
||||
END IF;
|
||||
|
||||
CALL entry_checkBooked(NEW.entryFk);
|
||||
IF NEW.printedStickers <> 0 THEN
|
||||
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
|
||||
END IF;
|
||||
|
|
|
@ -13,6 +13,7 @@ trig:BEGIN
|
|||
LEAVE trig;
|
||||
END IF;
|
||||
|
||||
CALL entry_checkBooked(OLD.entryFk);
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
SELECT defaultEntry INTO vDefaultEntry
|
||||
|
|
|
@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete`
|
|||
BEFORE DELETE ON `entry`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL entry_checkBooked(OLD.id);
|
||||
DELETE FROM buy WHERE entryFk = OLD.id;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -7,8 +7,9 @@ BEGIN
|
|||
DECLARE vPrintedCount INT;
|
||||
DECLARE vHasDistinctWarehouses BOOL;
|
||||
|
||||
CALL entry_checkBooked(OLD.id);
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
|
||||
IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
|
||||
|
||||
IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
|
||||
|
|
Loading…
Reference in New Issue