salix/db/routines/vn/functions/addressTaxArea.sql

31 lines
861 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`addressTaxArea`(vAddresId INT, vCompanyId INT)
RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
BEGIN
/**
* Devuelve el area de un Consignatario,
* intracomunitario, extracomunitario, nacional o recargo de equivalencia.
* Asumimos que no tenemos ninguna empresa
*
* @param vAddresId Id del Consignatario
* @param vCompanyId Compañia desde la que se factura
* @return Código de area
*/
DECLARE vTaxArea VARCHAR(25);
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany
SELECT vAddresId addressFk, vCompanyId companyFk;
CALL vn.addressTaxArea();
SELECT areaFk INTO vTaxArea FROM tmp.addressTaxArea;
2024-03-27 07:30:45 +00:00
DROP TEMPORARY TABLE
tmp.addressCompany,
tmp.addressTaxArea;
RETURN vTaxArea;
END$$
DELIMITER ;