2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`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
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
tmp.addressCompany,
|
|
|
|
tmp.addressTaxArea;
|
|
|
|
|
|
|
|
RETURN vTaxArea;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|