IF OBJECT_ID('V_PAINEL_NFE_EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO_ANALITICO') IS NOT NULL
	 DROP VIEW	V_PAINEL_NFE_EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO_ANALITICO
GO
--SELECT * FROM V_PAINEL_NFE_EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO_ANALITICO	WITH (NOLOCK)
CREATE VIEW V_PAINEL_NFE_EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO_ANALITICO  AS
SELECT
	EST_NF_ENT_DANFE_PROVISORIO.CD_FILIAL as filialOrigemId,
	EST_NF_ENT_DANFE_PROVISORIO.CD_FORN as fornecedorId,
	RZ_FORN as fornecedorNome,
	EST_NF_ENT_DANFE_PROVISORIO.CD_CTR as codigoControle,
	EST_NF_ENT_DANFE_PROVISORIO.NR_NF as numeroNfe,
	EST_NF_ENT_DANFE_PROVISORIO.NR_AUTORIZADOR as autorizador,
	EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO.DT_CAD as data,
	ERROS_VALIDACAO as erroValidacao,
	VERSAO AS versaoIntefaceNfe,
	EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO.VERSAO_APLIC as versaoAplicativo
FROM
	EST_NF_ENT_DANFE_PROVISORIO INNER JOIN PG_FORN ON
	EST_NF_ENT_DANFE_PROVISORIO.CD_EMP = PG_FORN.CD_EMP AND
	EST_NF_ENT_DANFE_PROVISORIO.CD_FORN = PG_FORN.CD_FORN
	INNER JOIN EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO ON
	EST_NF_ENT_DANFE_PROVISORIO.CD_CTR = EST_NF_ENT_DANFE_PROVISORIO_ERROS_VALIDACAO.CD_CTR 
	INNER JOIN EST_NF_ENT_DANFE_PROVISORIO_PENDENTE ON
	EST_NF_ENT_DANFE_PROVISORIO.CD_CTR = EST_NF_ENT_DANFE_PROVISORIO_PENDENTE.CD_CTR