DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_calcCatalogFull`(vSelf INT)
BEGIN
/**
 * Gets the availability and prices for the given items
 * using the order parameters.
 *
 * @param vSelf The order id
 * @table tmp.item(itemFk)
 * @return tmp.ticketCalculateItem
 * @return tmp.ticketComponentPrice
 * @return tmp.ticketComponent
 * @return tmp.ticketLot
 * @return tmp.zoneGetShipped
 */
	DECLARE vDate DATE;
	DECLARE vAddress INT;
	DECLARE vAgencyMode INT;
	DECLARE vCurrencyFk INT;

	SELECT date_send, address_id, agency_id, currencyFk
		INTO vDate, vAddress, vAgencyMode, vCurrencyFk
		FROM `order`
		WHERE id = vSelf;

	CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, vCurrencyFk, FALSE);

	IF account.myUser_getName() = 'visitor' THEN
		UPDATE tmp.ticketCalculateItem
			SET price = NULL;
		UPDATE tmp.ticketComponent
			SET cost = 0;
		UPDATE tmp.ticketComponentPrice
			SET price = 0, priceKg = NULL;
	END IF;
END$$
DELIMITER ;
