Mostrar alertas en inicio

This commit is contained in:
2023-10-19 18:20:37 -03:00
parent c2a3192b32
commit 02e1f3e091
25 changed files with 915 additions and 225 deletions

View File

@ -60,4 +60,44 @@ class Pago extends Ideal\Repository
{
return $this->update($model, ['valor', 'banco', 'tipo', 'identificador', 'fecha', 'uf', 'pagador', 'asociado'], $new_data);
}
public function fetchByVenta(int $venta_id): array
{
$query = "SELECT a.*
FROM (
SELECT a.*, venta.id AS venta_id, 'cuota' AS fuente
FROM pago a
JOIN cuota ON cuota.pago = a.id
JOIN venta ON venta.pie = cuota.pie
UNION ALL
SELECT a.*, venta.id AS venta_id, 'reajuste' AS fuente
FROM pago a
JOIN pie ON pie.reajuste = a.id
JOIN venta ON venta.pie = pie.id
UNION ALL
SELECT a.*, venta.id AS venta_id, 'credito' AS fuente
FROM pago a
JOIN credito ON credito.pago = a.id
JOIN venta ON venta.credito = credito.id
UNION ALL
SELECT a.*, venta.id AS venta_id, 'escritura' AS fuente
FROM pago a
JOIN escritura ON escritura.pago = a.id
JOIN venta ON venta.escritura = escritura.id
UNION ALL
SELECT a.*, venta.id AS venta_id, 'subsidio' AS fuente
FROM pago a
JOIN subsidio ON subsidio.subsidio = a.id
JOIN venta ON venta.subsidio = subsidio.id
UNION ALL
SELECT a.*, venta.id AS venta_id, 'ahorro' AS fuente
FROM pago a
JOIN subsidio ON subsidio.pago = a.id
JOIN venta ON venta.subsidio = subsidio.id
) a
JOIN (SELECT e1.* FROM estado_pago e1 JOIN (SELECT MAX(id) AS id, pago FROM estado_pago GROUP BY pago) e0 ON e0.id = e1.id) ep ON ep.pago = a.id
JOIN tipo_estado_pago tep ON tep.id = ep.estado
WHERE venta_id = ?";
return $this->fetchMany($query, [$venta_id]);
}
}