
Create PROCEDURE [dbo].[sp_api1_cobpagoDocumentosRead]
(
    @rut VARCHAR(12) = ''
)
as 
begin
select E.rutcte, 
        s.tipondcto, 
        s.ndocumento,
        s.fechapago, 
      --  FORMAT(e.fecven,'dd-mm-yyyy'), 
        case E.codsii 
            when 33 then 'FEL' 
            when 34 then 'FEX' 
        end as tipoDocto,
		s.monto,
		s.totpag,
		e.url

from cobPagoDocumentos as S
        inner join venEncabezado as E on s.tipondcto=E.codsii and S.ndocumento = E.numinv
		inner join conctacte  as C on c.rutcte = E.rutcte
									
WHERE E.rutcte = @rut 
end
