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

@ -0,0 +1,36 @@
<?php
namespace Incoviba\Service\Venta;
use Incoviba\Repository;
use Incoviba\Model;
class Precio
{
public function __construct(protected Repository\Venta\Precio $precioRepository, protected Repository\Venta\EstadoPrecio $estadoPrecioRepository) {}
public function getByProyecto(int $proyecto_id): array
{
$precios = $this->precioRepository->fetchByProyecto($proyecto_id);
foreach ($precios as &$precio) {
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
}
return $precios;
}
public function getVigenteByUnidad(int $unidad_id): Model\Venta\Precio
{
$precio = $this->precioRepository->fetchVigenteByUnidad($unidad_id);
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
return $precio;
}
public function getByUnidad(int $unidad_id): array
{
$precios = $this->precioRepository->fetchByUnidad($unidad_id);
foreach ($precios as &$precio) {
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
}
return $precios;
}
}