/****** Object:  View [dbo].[V_PAINEL_NFE_EST_NF_ENT_DANFE_CONFIRMACAO_RECBTO_ANALITICO]    Script Date: 03/10/2018 11:00:00 ******/ 
IF EXISTS (SELECT * 
           FROM   SYS.VIEWS 
           WHERE  OBJECT_ID = 
      Object_id(N'[dbo].[V_PAINEL_NFE_EST_NF_ENT_DANFE_CONFIRMACAO_RECBTO_ANALITICO]')) 
  DROP VIEW [dbo].[V_PAINEL_NFE_EST_NF_ENT_DANFE_CONFIRMACAO_RECBTO_ANALITICO] 

GO 

--SELECT * FROM V_PAINEL_NFE_EST_NF_ENT_DANFE_CONFIRMACAO_RECBTO_ANALITICO 
CREATE VIEW V_PAINEL_NFE_EST_NF_ENT_DANFE_CONFIRMACAO_RECBTO_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_CONFIRMACAO_RECBTO.DT_CAD AS data,
	   DS_TP as ClassificacaoFornecedor
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_CONFIRMACAO_RECBTO ON EST_NF_ENT_DANFE_PROVISORIO.CD_CTR = EST_NF_ENT_DANFE_PROVISORIO_CONFIRMACAO_RECBTO.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
INNER JOIN PG_TP_FORN ON
PG_FORN.CD_TP_FORN = PG_TP_FORN.CD_TP_FORN