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

25 lines
603 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`clientTaxArea`(vClientId INT, vCompanyId INT)
RETURNS varchar(25) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
NOT DETERMINISTIC
READS SQL DATA
BEGIN
/**
* Devuelve el area de un cliente,
* intracomunitario, extracomunitario o nacional.
*
* @param vClient Id del cliente
* @param vCompanyFk Compañia desde la que se factura
* @return Código de area
*/
DECLARE vTaxArea VARCHAR(25);
SELECT addressTaxArea(defaultAddressFk, vCompanyId)
INTO vTaxArea
FROM client
WHERE id = vClientId;
RETURN vTaxArea;
END$$
DELIMITER ;