ALTER PROCEDURE [dbo].[sp_finCartola]
(
@id_misbancos int,
@agno int,
@mes int,
@conciliado int = -1 --TODOS
)
AS
SET NOCOUNT ON;

BEGIN

    SELECT        finCartola.id, finCartola.fecha, finCartola.tipoConcepto, finCartola.concepto, finCartola.descripcion, finCartola.numDocumento, finCartola.rut, finCartola.monto, 
                         finCartola.tipoCompro, finCartola.numCompro, finCartola.fecCompro, finCartola.contabilizado, finCartola.id_rendicion, 
                         COALESCE (dbo.MontoRendicionCartola(finCartola.id_rendicion), finCartola.monto) AS monto_rendicion, 
						 COALESCE (conCtacte.nomcte,'CLIENTE NO EXISTE EN MAESTRO') as nomcte,
						 flujo,
						 case when finCartola.conciliado = 1 then 'Si'
	                     --when finCartola.conciliado = 0  then 'No'
						 else 'No'
						 end as conciliado,
						 finCartola.idAnticipo
    FROM            finCartola LEFT OUTER JOIN
                         conCtacte ON finCartola.rut = conCtacte.rutcte
    WHERE id_MisBancos = @id_misBancos
    AND mes = @mes
    AND agno = @agno
	AND (finCartola.conciliado = @conciliado or @conciliado = -1)
    ORDER BY fecha,id

END