2023-07-24 20:55:26 -04:00
|
|
|
<?php
|
|
|
|
namespace Incoviba\Service\Ventas;
|
|
|
|
|
|
|
|
use Incoviba\Repository;
|
2023-07-28 16:22:20 -04:00
|
|
|
use Incoviba\Model;
|
2023-07-24 20:55:26 -04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2023-07-28 16:22:20 -04:00
|
|
|
public function getByUnidad(int $unidad_id): Model\Venta\Precio
|
|
|
|
{
|
|
|
|
$precio = $this->precioRepository->fetchByUnidad($unidad_id);
|
|
|
|
$precio->estados = $this->estadoPrecioRepository->fetchByPrecio($precio->id);
|
|
|
|
$precio->current = $this->estadoPrecioRepository->fetchCurrentByPrecio($precio->id);
|
|
|
|
return $precio;
|
|
|
|
}
|
2023-07-24 20:55:26 -04:00
|
|
|
}
|