Implementacion agregar abono a escritura

This commit is contained in:
Juan Pablo Vial
2024-02-14 13:54:01 -03:00
parent 338f290539
commit 1621d6fe30
8 changed files with 257 additions and 11 deletions

View File

@ -47,15 +47,19 @@ class EstadoVenta extends Ideal\Repository
public function fetchByVenta(int $venta_id): array
{
$query = "SELECT * FROM `{$this->getTable()}` WHERE `venta` = ?";
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('venta = ?');
return $this->fetchMany($query, [$venta_id]);
}
public function fetchCurrentByVenta(int $venta_id): Model\Venta\EstadoVenta
{
$query = "SELECT a.*
FROM `{$this->getTable()}` a
JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `{$this->getTable()}` GROUP BY `venta`) e0 ON e0.`id` = a.`id`
WHERE a.`venta` = ?";
$query = $this->connection->getQueryBuilder()
->select('a.*')
->from("{$this->getTable()} a")
->joined("JOIN (SELECT MAX(id) AS id, venta FROM {$this->getTable()} GROUP BY venta) ev0 ON ev0.id = a.id")
->where('a.venta = ?');
return $this->fetchOne($query, [$venta_id]);
}
}