-- >>> consulta los convenios
DELIMITER $$
DROP VIEW IF EXISTS cConvenios;
CREATE VIEW cConvenios
(clave, predio, periodo, valor, pagado, deuda)
AS
	SELECT c.clave, CONCAT('PREDIO: ', descifrar(p.predio), ', LOTE: ', descifrar(p.lote), ', CALLE: ', descifrar(p.calle), ' ', descifrar(p.exterior)),
	CONCAT(fechas(c.inicio, 2), ' A ', fechas(c.fin, 2)), c.valor, pagado_convenio(c.id), (c.valor - pagado_convenio(c.id))
	FROM convenios AS c
	INNER JOIN predios AS p ON c.predio = p.id
	WHERE (c.valor - pagado_convenio(c.id)) > 1 ORDER BY descifrar(p.lote);
$$
