2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_calcCatalog`(
|
|
|
|
vSelf INT,
|
|
|
|
vLanded DATE,
|
|
|
|
vAddressFk INT,
|
|
|
|
vAgencyModeFk INT)
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Calculates available and price for a single item.
|
|
|
|
*
|
|
|
|
* @param vItemFk The item id
|
|
|
|
* @return List of available lots
|
|
|
|
*/
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
|
|
|
CREATE TEMPORARY TABLE tmp.item
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT vSelf itemFk;
|
|
|
|
|
2024-03-25 13:56:12 +00:00
|
|
|
CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
SELECT l.warehouseFk, w.name warehouse,
|
|
|
|
p.`grouping`, p.price, p.rate, l.available
|
|
|
|
FROM tmp.ticketLot l
|
|
|
|
JOIN tmp.ticketComponentPrice p ON p.warehouseFk = l.warehouseFk
|
|
|
|
JOIN vn.warehouse w ON w.id = p.warehouseFk
|
|
|
|
ORDER BY warehouseFk, `grouping`;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
tmp.ticketCalculateItem,
|
|
|
|
tmp.ticketComponentPrice,
|
|
|
|
tmp.ticketComponent,
|
|
|
|
tmp.ticketLot,
|
2024-02-15 11:48:17 +00:00
|
|
|
tmp.zoneGetShipped,
|
|
|
|
tmp.item;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|