42 lines
1.0 KiB
SQL
42 lines
1.0 KiB
SQL
|
|
DROP procedure IF EXISTS `hedera`.`catalog_calcFromMyAddress`;
|
|
DELIMITER $$
|
|
CREATE DEFINER=`root`@`%` 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;
|
|
|
|
CALL vn.ticketCalculate(vDelivery, vAddress, vAgencyMode);
|
|
|
|
DROP TEMPORARY TABLE tmp.item;
|
|
END$$
|
|
DELIMITER ;
|