Search
This commit is contained in:
@ -23,26 +23,56 @@ class Venta
|
||||
|
||||
public function getById(int $venta_id): Model\Venta
|
||||
{
|
||||
return ($this->ventaRepository->fetchById($venta_id))
|
||||
->addFactory('estados', (new Implement\Repository\Factory())
|
||||
->setCallable([$this->estadoVentaRepository, 'fetchByVenta'])
|
||||
->setArgs([$venta_id]))
|
||||
->addFactory('currentEstado', (new Implement\Repository\Factory())
|
||||
->setCallable([$this->estadoVentaRepository, 'fetchCurrentByVenta'])
|
||||
->setArgs([$venta_id]));
|
||||
return $this->process($this->ventaRepository->fetchById($venta_id));
|
||||
}
|
||||
public function getByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$ventas = $this->ventaRepository->fetchByProyecto($proyecto_id);
|
||||
foreach ($ventas as &$venta) {
|
||||
$venta->estados = $this->estadoVentaRepository->fetchByVenta($venta->id);
|
||||
$venta->currentEstado = $this->estadoVentaRepository->fetchCurrentByVenta($venta->id);
|
||||
$venta = $this->process($venta);
|
||||
}
|
||||
return $ventas;
|
||||
}
|
||||
public function getActivaByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$ventas = $this->ventaRepository->fetchActivaByProyecto($proyecto_id);
|
||||
foreach ($ventas as &$venta) {
|
||||
$venta = $this->process($venta);
|
||||
}
|
||||
return $ventas;
|
||||
}
|
||||
public function getByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Model\Venta
|
||||
{
|
||||
$venta = $this->ventaRepository->fetchByProyectoAndUnidad($proyecto_nombre, $unidad_descripcion);
|
||||
return $this->process($venta);
|
||||
}
|
||||
public function getByUnidad(string $unidad, string $tipo): array
|
||||
{
|
||||
$ventas = $this->ventaRepository->fetchByUnidad($unidad, $tipo);
|
||||
foreach ($ventas as &$venta) {
|
||||
$venta = $this->process($venta);
|
||||
}
|
||||
return $ventas;
|
||||
}
|
||||
public function getByPropietario(string $propietario): array
|
||||
{
|
||||
$ventas = $this->ventaRepository->fetchByPropietario($propietario);
|
||||
foreach ($ventas as &$venta) {
|
||||
$venta = $this->process($venta);
|
||||
}
|
||||
return $ventas;
|
||||
}
|
||||
public function getByPrecio(string $precio): array
|
||||
{
|
||||
$ventas = $this->ventaRepository->fetchByPrecio($precio);
|
||||
foreach ($ventas as &$venta) {
|
||||
$venta = $this->process($venta);
|
||||
}
|
||||
return $ventas;
|
||||
}
|
||||
|
||||
protected function process(Model\Venta $venta): Model\Venta
|
||||
{
|
||||
$venta->addFactory('estados', (new Implement\Repository\Factory())->setCallable([$this->estadoVentaRepository, 'fetchByVenta'])->setArgs([$venta->id]));
|
||||
$venta->addFactory('currentEstado', (new Implement\Repository\Factory())->setCallable([$this->estadoVentaRepository, 'fetchCurrentByVenta'])->setArgs([$venta->id]));
|
||||
return $venta;
|
||||
|
Reference in New Issue
Block a user