

		select 
		cll_v.id as voucher_id,
		cll_v.code as voucher_code,
		cll_v.date as date_voucher,
		cll_c.code,
		cll_c.description,
		cll_c.amount as valor,
		coalesce(sum(cll_vl.value_paid),0.00) capital_pagado,
		coalesce(sum(cll_vl.penalty_agreement),0.00) interes_convenio,
		coalesce(sum(cll_vl.to_paid),0.00) valor_pagado
		from cll_vouchers_line cll_vl
		inner join cll_vouchers cll_v on cll_v.id = cll_vl.vouchers_id
		inner join cll_collection cll_c on cll_c.id = cll_vl.collection_id
		where cll_vl.collection_dividend_id in(
			select distinct cdl.id from cll_vouchers_line cvl
			inner join cll_dividend_line cdl 
			on cdl.id = cvl.collection_dividend_id
			where agreement_id = 2761
		)
		and cll_vl.collection_dividend_id is not null
		--and cll_v.code = '001019/026199'
		group by cll_v.id,cll_v.code,cll_v.date, cll_vl.collection_dividend_id, cll_c.code, cll_c.description,cll_c.amount
		order by cll_vl.collection_dividend_id
