
IF OBJECT_ID('UFD_EST_PROD_TBL_DESC_CONV_COMMERCE') IS NOT NULL
BEGIN
	DROP FUNCTION [dbo].[UFD_EST_PROD_TBL_DESC_CONV_COMMERCE]
END
GO

CREATE FUNCTION UFD_EST_PROD_TBL_DESC_CONV_COMMERCE(@CD_EMP INT, @CD_FILIAL INT, @CD_PROD INT, @CD_CLI INT, @CD_CONV INT, @IS_RECEITA INT, @LIBERA_VD_CONV INT, @CD_FRM_PGTO INT)
RETURNS @RETURN_REC 
TABLE(
	CD_TBL_DESC 		INT,
	TP_DESC 			INT,
	FLAG_DESC_FIX 		INT,
	PERC_DESC			MONEY,
	PERC_DESC_MAX		MONEY,
	TP_NIVEL			INT,
	LIBERA_VD_CONV      INT,
	EXCLUE_OFERTA       INT,
	QT_MAX              INT
)
AS 
BEGIN
	
	INSERT INTO @RETURN_REC
	SELECT
		CD_TBL_DESC
		,TP_DESC
		,FLAG_DESC_FIX
		,PERC_DESC
		,PERC_DESC_MAX
		,TP_NIVEL
		,LIBERA_VD_CONV
		,EXCLUE_OFERTA
		,QT_MAX
	FROM
		UFD_EST_PROD_TBL_DESC_CONV (@CD_EMP, @CD_FILIAL, @CD_PROD, @CD_CLI, @CD_CONV, @IS_RECEITA, @LIBERA_VD_CONV, @CD_FRM_PGTO, 0,0)
	RETURN
END