IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[V_PDV_CUPOM_NAO_FISCAL_FORMA_PGTOS]'))
	DROP VIEW [dbo].[V_PDV_CUPOM_NAO_FISCAL_FORMA_PGTOS]

GO
   
CREATE VIEW [dbo].[V_PDV_CUPOM_NAO_FISCAL_FORMA_PGTOS]    
AS
 
 SELECT PDV_CUPOM_NAO_FISCAL.CD_EMP,
    PDV_CUPOM_NAO_FISCAL.CD_FILIAL,
    PDV_CUPOM_NAO_FISCAL.CD_CX,
    PDV_CUPOM_NAO_FISCAL.CD_CTR,
    'DINHEIRO' AS DS_MEIO_PGTO,
    PDV_CUPOM_NAO_FISCAL.VLR_DINH AS VLR_FORMA_PAGTO
   FROM PDV_CUPOM_NAO_FISCAL
  WHERE PDV_CUPOM_NAO_FISCAL.VLR_DINH > 0 AND PDV_CUPOM_NAO_FISCAL.ST_CUPOM = 0
UNION ALL
 SELECT PDV_CUPOM_NAO_FISCAL.CD_EMP,
    PDV_CUPOM_NAO_FISCAL.CD_FILIAL,
    PDV_CUPOM_NAO_FISCAL.CD_CX,
    PDV_CUPOM_NAO_FISCAL.CD_CTR,
    'CHEQUES' AS DS_MEIO_PGTO,
    PDV_CUPOM_NAO_FISCAL.VLR_CHQS AS VLR_FORMA_PAGTO
   FROM PDV_CUPOM_NAO_FISCAL
  WHERE PDV_CUPOM_NAO_FISCAL.VLR_CHQS > 0 AND PDV_CUPOM_NAO_FISCAL.ST_CUPOM = 0
UNION ALL
 SELECT PDV_CUPOM_NAO_FISCAL.CD_EMP,
    PDV_CUPOM_NAO_FISCAL.CD_FILIAL,
    PDV_CUPOM_NAO_FISCAL.CD_CX,
    PDV_CUPOM_NAO_FISCAL.CD_CTR,
    'CARTAO' AS DS_MEIO_PGTO,
    PDV_CUPOM_NAO_FISCAL.VLR_CARTAO AS VLR_FORMA_PAGTO
   FROM PDV_CUPOM_NAO_FISCAL
  WHERE PDV_CUPOM_NAO_FISCAL.VLR_CARTAO > 0 AND PDV_CUPOM_NAO_FISCAL.ST_CUPOM = 0



