ALTER  PROCEDURE [dbo].[sp_cobExcedentesSel]
(
@rut as int
)
AS
BEGIN

  SELECT seleccion,
		CONVERT(NVARCHAR(20),fechamov,103) AS fechamov,
		saldo AS monto, 
		CASE tipo WHEN 1 THEN 'Anticipo' WHEN 2 THEN 'Excedente' END AS origen, 
		rut, 
		id_anticipo AS id, 
		-1 AS id_origen,
		tipo,
		numero as Serie,
		CASE centralizado
		WHEN 'n' THEN 'NO CONTABILIZADO'
		WHEN 's' THEN (SELECT CASE tipocontable WHEN 1 THEN 'I' WHEN 2 THEN 'E' WHEN 3 THEN 'T' END AS tipocontable) + '/' + CONVERT(VARCHAR(25),comprocontable)
		END AS Centralizado
     FROM cobAnticipos
     WHERE saldo > 0 
     AND rut = @rut  
END