diff --git a/app/src/Controller/API/Ventas/Escrituras.php b/app/src/Controller/API/Ventas/Escrituras.php index 200c472..1c8b5a1 100644 --- a/app/src/Controller/API/Ventas/Escrituras.php +++ b/app/src/Controller/API/Ventas/Escrituras.php @@ -4,8 +4,11 @@ namespace Incoviba\Controller\API\Ventas; use DateTimeImmutable; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Log\LoggerInterface; use Incoviba\Common\Implement\Exception\EmptyResult; use Incoviba\Controller\API\withJson; +use Incoviba\Exception\ServiceAction\Read; +use Incoviba\Exception\ServiceAction\Update; use Incoviba\Repository; use Incoviba\Service; @@ -42,7 +45,7 @@ class Escrituras try { $escrituraService->edit($venta_id, $body); $output['success'] = true; - } catch (EmptyResult) {} + } catch (Read|Update|EmptyResult) {} return $this->withJson($response, $output); } } diff --git a/app/src/Service/Venta/Escritura.php b/app/src/Service/Venta/Escritura.php index 7b12632..f1739ac 100644 --- a/app/src/Service/Venta/Escritura.php +++ b/app/src/Service/Venta/Escritura.php @@ -4,6 +4,8 @@ namespace Incoviba\Service\Venta; use Exception; use DateTimeImmutable; use DateMalformedStringException; +use Incoviba\Exception\ServiceAction\Read; +use Incoviba\Exception\ServiceAction\Update; use Psr\Log\LoggerInterface; use Incoviba\Common\Ideal; use Incoviba\Common\Implement\Exception\EmptyResult; @@ -56,13 +58,15 @@ class Escritura extends Ideal\Service /** * @throws EmptyResult + * @throws Read + * @throws Update */ public function edit(int $venta_id, array $data): Model\Venta\Escritura { $venta = $this->ventaService->getById($venta_id); $estado = $venta->currentEstado(); if (!in_array($estado->tipoEstadoVenta->descripcion, ['escriturando', 'firmado por inmobiliaria'])) { - throw new EmptyResult(''); + throw new Update(__CLASS__); } try { $data['fecha'] = (new DateTimeImmutable($data['fecha']))->format('Y-m-d');