salix/db/routines/hedera/procedures/catalog_calcFromMyAddress.sql

40 lines
1.0 KiB
MySQL
Raw Permalink Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
BEGIN
/**
* Gets the available items list.
*
* @param vDelivery Delivery date
* @param vAddress Address id
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
DECLARE vAgencyMode INT;
SELECT a.agencyModeFk
INTO vAgencyMode
FROM myClient c
JOIN vn.address a ON a.clientFk = c.id
WHERE a.id = vAddress;
CALL vn.available_calc(vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT c.item_id itemFk
FROM `cache`.available c
JOIN tmp.availableCalc a ON a.calcFk = c.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
2024-03-25 13:56:12 +00:00
CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode, FALSE);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;