IF OBJECT_ID('V_MAPARESUMO') IS NOT NULL 
	DROP VIEW V_MAPARESUMO 
GO 

CREATE  VIEW V_MAPARESUMO
AS
SELECT	RESUMO.CD_EMP,RESUMO.CD_FILIAL,RESUMO.CD_CTR,RESUMO.DT_ECF,RESUMO.CD_CX,RESUMO.DT_CAD,RESUMO.DT_CAD AS HR_CAD
        ,RESUMO.CONT_RED_Z,RESUMO.CONT_ORD_OP_INI,RESUMO.CONT_ORD_OP_FIN,RESUMO.CONT_REINICIO AS CONT_REINICIO_OP
        ,RESUMO.VLR_GT_INI,RESUMO.VLR_GT_FIN,RESUMO.VLR_VEND_BRUTA,RESUMO.VLR_DESC,RESUMO.VLR_CANC,RESUMO.VLR_CONTAB
        ,RESUMO.VLR_ICMS,RESUMO.VLR_ISENTAS,RESUMO.VLR_N_TRIB,RESUMO.VLR_BASE_ICMS_SUBS
        ,RESUMO.VLR_ISSQN,RESUMO.VLR_DESC_ISSQN,RESUMO.VLR_CANCEL_ISSQN
        ,ALIQUOTAS.TX_ICMS,ALIQUOTAS.BASE_CALC,COALESCE(ALIQUOTAS.TIPO_IMPOSTO, 0) AS TIPO_IMPOSTO
        ,ROUND(ALIQUOTAS.BASE_CALC * ALIQUOTAS.TX_ICMS / 100,2) AS VLR_TX_ICMS
FROM	PDV_MAPA_RESUMO RESUMO 
LEFT	JOIN PDV_MAPA_RESUMO_CPL ALIQUOTAS
ON      RESUMO.CD_EMP = ALIQUOTAS.CD_EMP 
AND     RESUMO.CD_FILIAL = ALIQUOTAS.CD_FILIAL 
AND     RESUMO.CD_CTR = ALIQUOTAS.CD_CTR