Ventas->Listado->Ventas

This commit is contained in:
Juan Pablo Vial
2023-07-28 16:22:20 -04:00
parent 38383f5295
commit ef30ae67d2
52 changed files with 1496 additions and 17 deletions

View File

@ -1,6 +1,7 @@
<?php
namespace Incoviba\Repository\Venta;
use DateTimeInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Define;
use Incoviba\Model;
@ -52,4 +53,22 @@ WHERE ptu.`proyecto` = ? AND tep.`descripcion` = 'vigente'
ORDER BY tu.`orden`, ptu.`nombre`, `unidad`.`subtipo`, LPAD(`unidad`.`descripcion`, 4, '0')";
return $this->fetchMany($query, [$proyecto_id]);
}
public function fetchByUnidad(int $unidad_id): Define\Model
{
$query = "SELECT a.*
FROM `{$this->getTable()}` a
JOIN (SELECT e1.* FROM `estado_precio` e1 JOIN (SELECT MAX(`id`) AS 'id', `precio` FROM `estado_precio` GROUP BY `precio`) e0 ON e0.`id` = e1.`id`) ep ON ep.`precio` = a.`id`
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
WHERE `unidad` = ? AND tep.`descripcion` = 'vigente'";
return $this->fetchOne($query, [$unidad_id]);
}
public function fetchByUnidadAndDate(int $unidad_id, string $date_time): Define\Model
{
$query = "SELECT a.*
FROM `{$this->getTable()}` a
JOIN (SELECT e1.* FROM `estado_precio` e1 JOIN (SELECT MAX(`id`) AS 'id', `precio` FROM `estado_precio` GROUP BY `precio`) e0 ON e0.`id` = e1.`id`) ep ON ep.`precio` = a.`id`
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
WHERE `unidad` = ? AND ep.`fecha` <= ? AND tep.`descripcion` = 'vigente'";
return $this->fetchOne($query, [$unidad_id, $date_time]);
}
}