Merge pull request 'feat: validar caracteres invocieIn.supplierref #6931' (!2090) from 6931-Líneas-en-referencias-de-invoiceIn.supplierRef into dev
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
Reviewed-on: #2090 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
e54d2d1162
|
@ -0,0 +1,15 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`checkPrintableChars`(
|
||||||
|
vString VARCHAR(255)
|
||||||
|
) RETURNS tinyint(1)
|
||||||
|
DETERMINISTIC
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Validates whether the input string contains only printable characters
|
||||||
|
* and Spanish special characters (such as ¡, ÿ, etc.).
|
||||||
|
*
|
||||||
|
* @vString string to check
|
||||||
|
*/
|
||||||
|
RETURN vString REGEXP '^[ -~¡-ÿ]*$';
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -9,6 +9,10 @@ BEGIN
|
||||||
DECLARE vActive TINYINT;
|
DECLARE vActive TINYINT;
|
||||||
DECLARE vWithholdingSageFk INT;
|
DECLARE vWithholdingSageFk INT;
|
||||||
|
|
||||||
|
IF NOT util.checkPrintableChars(NEW.supplierRef) THEN
|
||||||
|
CALL util.throw('The invoiceIn reference contains invalid characters');
|
||||||
|
END IF;
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
SELECT withholdingSageFk INTO vWithholdingSageFk
|
SELECT withholdingSageFk INTO vWithholdingSageFk
|
||||||
|
|
|
@ -3,9 +3,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat
|
||||||
BEFORE UPDATE ON `invoiceIn`
|
BEFORE UPDATE ON `invoiceIn`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
DECLARE vWithholdingSageFk INT;
|
DECLARE vWithholdingSageFk INT;
|
||||||
|
|
||||||
|
IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
|
||||||
|
CALL util.throw('The invoiceIn reference contains invalid characters');
|
||||||
|
END IF;
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
IF (SELECT COUNT(*) FROM vn.invoiceIn
|
IF (SELECT COUNT(*) FROM vn.invoiceIn
|
||||||
|
|
Loading…
Reference in New Issue