2024-10-22 10:02:04 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`(
|
|
|
|
vItemFk INT,
|
2024-10-24 05:31:26 +00:00
|
|
|
vWarehouseFk INT,
|
2024-10-22 10:02:04 +00:00
|
|
|
vDated DATE
|
|
|
|
)
|
|
|
|
RETURNS int(11)
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Calcula las últimas compras realizadas hasta una fecha.
|
|
|
|
*
|
|
|
|
* @param vItemFk Id del artículo
|
|
|
|
* @param vWarehouseFk Id del almacén
|
|
|
|
* @param vDated Compras hasta fecha
|
|
|
|
* @return Id de compra
|
|
|
|
*/
|
|
|
|
DECLARE vBuyFk INT;
|
|
|
|
|
|
|
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated);
|
|
|
|
|
|
|
|
SELECT buyFk INTO vBuyFk
|
|
|
|
FROM tmp.buyUltimate;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS
|
|
|
|
tmp.buyUltimate,
|
|
|
|
tmp.buyUltimateFromInterval;
|
|
|
|
|
|
|
|
RETURN vBuyFk;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|