Throw Read

This commit is contained in:
Juan Pablo Vial
2025-04-21 19:40:10 -04:00
parent 993e4ff3b8
commit f7af93b815
2 changed files with 34 additions and 4 deletions

View File

@ -69,14 +69,35 @@ class Venta extends Service
$venta = $this->ventaRepository->fetchByProyectoAndUnidad($proyecto_nombre, $unidad_descripcion);
return $this->process($venta);
}
/**
* @param string $unidad
* @param string $tipo
* @return array
* @throws Read
*/
public function getByUnidad(string $unidad, string $tipo): array
{
try {
$ventas = $this->ventaRepository->fetchByUnidad($unidad, $tipo);
return array_map([$this, 'process'], $ventas);
} catch (Implement\Exception\EmptyResult $exception) {
throw new Read(__CLASS__, $exception);
}
}
/**
* @param int $unidad_id
* @return Model\Venta
* @throws Read
*/
public function getByUnidadId(int $unidad_id): Model\Venta
{
try {
return $this->process($this->ventaRepository->fetchByUnidadId($unidad_id));
} catch (Implement\Exception\EmptyResult $exception) {
throw new Read(__CLASS__, $exception);
}
}
public function getByPropietario(string $propietario): array
{

View File

@ -16,9 +16,18 @@ class Unidad
protected Precio $precioService
) {}
/**
* @param int $unidad_id
* @return Model\Venta\Unidad
* @throws Read
*/
public function getById(int $unidad_id): Model\Venta\Unidad
{
try {
return $this->process($this->unidadRepository->fetchById($unidad_id));
} catch (EmptyResult $exception) {
throw new Read(__CLASS__, $exception);
}
}
public function getByVenta(int $venta_id): array
{