2024-06-05 13:44:11 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_isEditable`(
|
2024-06-05 13:44:11 +00:00
|
|
|
vSelf INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Comprueba si una entrada se puede actualizar
|
|
|
|
* si no se puede retorna un throw.
|
|
|
|
*
|
|
|
|
* @param vSelf Id de entrada
|
|
|
|
*/
|
2024-10-25 14:15:13 +00:00
|
|
|
DECLARE vIsNotEditable BOOL;
|
2024-06-05 13:44:11 +00:00
|
|
|
|
2024-10-25 14:15:13 +00:00
|
|
|
SELECT (e.typeFk IS NULL OR NOT et.isInformal) INTO vIsNotEditable
|
2024-06-05 13:44:11 +00:00
|
|
|
FROM `entry` e
|
2024-10-25 14:15:13 +00:00
|
|
|
LEFT JOIN entryType et ON et.code = e.typeFk
|
|
|
|
WHERE e.id = vSelf
|
|
|
|
AND e.isBooked;
|
2024-06-05 13:44:11 +00:00
|
|
|
|
2024-10-25 14:15:13 +00:00
|
|
|
IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
|
|
|
|
CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable'));
|
|
|
|
END IF;
|
2024-06-05 13:44:11 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|