diff --git a/app/src/Service/Venta.php b/app/src/Service/Venta.php index d0ead13..468024b 100644 --- a/app/src/Service/Venta.php +++ b/app/src/Service/Venta.php @@ -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 { - $ventas = $this->ventaRepository->fetchByUnidad($unidad, $tipo); - return array_map([$this, 'process'], $ventas); + 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 { - return $this->process($this->ventaRepository->fetchByUnidadId($unidad_id)); + 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 { diff --git a/app/src/Service/Venta/Unidad.php b/app/src/Service/Venta/Unidad.php index 39fce4e..9b39433 100644 --- a/app/src/Service/Venta/Unidad.php +++ b/app/src/Service/Venta/Unidad.php @@ -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 { - return $this->process($this->unidadRepository->fetchById($unidad_id)); + try { + return $this->process($this->unidadRepository->fetchById($unidad_id)); + } catch (EmptyResult $exception) { + throw new Read(__CLASS__, $exception); + } } public function getByVenta(int $venta_id): array {