Implemented repository mapper, and venta show

This commit is contained in:
Juan Pablo Vial
2023-08-08 23:53:49 -04:00
parent ef30ae67d2
commit 59825259b6
111 changed files with 2766 additions and 612 deletions

View File

@ -1,7 +1,9 @@
<?php
namespace Incoviba\Service;
use Incoviba\Common\Implement;
use Incoviba\Repository;
use Incoviba\Model;
class Venta
{
@ -10,6 +12,16 @@ class Venta
protected Repository\Venta\EstadoVenta $estadoVentaRepository
) {}
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]));
}
public function getByProyecto(int $proyecto_id): array
{
$ventas = $this->ventaRepository->fetchByProyecto($proyecto_id);
@ -19,4 +31,11 @@ class Venta
}
return $ventas;
}
public function getByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Model\Venta
{
$venta = $this->ventaRepository->fetchByProyectoAndUnidad($proyecto_nombre, $unidad_descripcion);
$venta->addFactory('estados', ['callable' => [$this->estadoVentaRepository, 'fetchByVenta'], 'args' => [$venta->id]]);
$venta->addFactory('currentEstado', ['callable' => [$this->estadoVentaRepository, 'fetchCurrentByVenta'], 'args' => [$venta->id]]);
return $venta;
}
}