Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6379-fixDriverRouteEmail
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-02-09 14:01:24 +01:00
commit 1be1990936
4 changed files with 115 additions and 23 deletions

View File

@ -1,6 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`( CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`(
vAccount VARCHAR(20) vAccount VARCHAR(20)
) )
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC DETERMINISTIC
@ -18,41 +18,41 @@ BEGIN
CONCAT('ES', CONCAT('ES',
RIGHT( RIGHT(
CONCAT(0, CONCAT(0,
98-MOD( 98-MOD(
CONCAT( CONCAT(
MOD( MOD(
CONCAT( CONCAT(
MOD( MOD(
CONCAT( CONCAT(
MOD( MOD(
SUBSTRING(vAccount, 1, 8), SUBSTRING(vAccount, 1, 8),
97 97
), ),
SUBSTRING(vAccount,9,8) SUBSTRING(vAccount,9,8)
), ),
97 97
), ),
SUBSTRING( SUBSTRING(
CONCAT(vAccount, 142800), CONCAT(vAccount, 142800),
17, 17,
8 8
) )
), ),
97 97
), ),
SUBSTRING( SUBSTRING(
CONCAT(vAccount, 142800), CONCAT(vAccount, 142800),
25, 25,
2 2
) )
), ),
97 97
) )
), ),
2 2
) )
) INTO vIban; ) INTO vIban;
RETURN vIban; RETURN vIban;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1 +0,0 @@
REVOKE EXECUTE ON FUNCTION vn2008.red FROM hrBoss, salesPerson;

View File

@ -1 +1,60 @@
REVOKE EXECUTE ON FUNCTION vn2008.cc_to_iban FROM hr, financial; DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`(
vAccount VARCHAR(20)
)
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
BEGIN
/**
* Calcula y genera el código IBAN correspondiente
* a un número de cuenta bancaria español.
*
* @param vAccount Número de cuenta bancaria
* @return vIban Código IBAN de 4 caracteres.
*/
DECLARE vIban VARCHAR(4);
SELECT
CONCAT('ES',
RIGHT(
CONCAT(0,
98-MOD(
CONCAT(
MOD(
CONCAT(
MOD(
CONCAT(
MOD(
SUBSTRING(vAccount, 1, 8),
97
),
SUBSTRING(vAccount,9,8)
),
97
),
SUBSTRING(
CONCAT(vAccount, 142800),
17,
8
)
),
97
),
SUBSTRING(
CONCAT(vAccount, 142800),
25,
2
)
),
97
)
),
2
)
) INTO vIban;
RETURN vIban;
END$$
DELIMITER ;
GRANT EXECUTE ON FUNCTION util.accountNumberToIban TO hr, financial;

View File

@ -0,0 +1,34 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`intrastat_estimateNet`(
vSelf INT,
vStems INT
)
RETURNS double
DETERMINISTIC
BEGIN
/**
* Calcula un valor neto estimado en función de
* datos históricos de facturas intrastat.
*
* @param vSelf Id de intrastat
* @param vStems Número de unidades
* @return vNet
*/
DECLARE vNet DOUBLE;
SELECT ROUND(vStems / (SUM(average) / COUNT(average)), 2) INTO vNet
FROM (
SELECT *, stems / net average
FROM invoiceInIntrastat
WHERE intrastatFk = vSelf
AND net
AND stems > 0
ORDER BY dated DESC
LIMIT 20
) sub;
RETURN vNet/2;
END$$
DELIMITER ;
GRANT EXECUTE ON FUNCTION vn.intrastat_estimateNet TO administrative;