ALTER VIEW [dbo].[_SAIPAVTA]
AS
SELECT     dbo.SAIPAVTA.NroUnico, dbo.SAIPAVTA.TipoFac, dbo.SAIPAVTA.NumeroD, dbo.SAIPAVTA.TipoPag, dbo.SAIPAVTA.CodPago, dbo.SAIPAVTA.Descrip, 
                      dbo.SAIPAVTA.Monto, (CASE WHEN PROPINA = 0 THEN safact.factor ELSE PROPINA END) AS Propina, dbo.SAIPAVTA.Impuesto, dbo.SAIPAVTA.RetencT, 
                      dbo.SAIPAVTA.Descrip1, dbo.SAIPAVTA.CODSUCU, dbo.SAIPAVTA.CEDULA, dbo.SAIPAVTA.TELEFONO, dbo.SAIPAVTA.BANCO, dbo.SAIPAVTA.REFERENCIA
FROM         dbo.SAIPAVTA LEFT OUTER JOIN
                      dbo.SAFACT ON dbo.SAIPAVTA.TipoFac = dbo.SAFACT.TipoFac AND dbo.SAIPAVTA.NumeroD = dbo.SAFACT.NumeroD
WHERE     (dbo.SAIPAVTA.TipoFac IN ('A', 'B'))
GO


