Compare commits
3 Commits
beb73ba6df
...
74c6347367
| Author | SHA1 | Date | |
|---|---|---|---|
| 74c6347367 | |||
| 5ea300837e | |||
| 71309e13a0 |
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +239,11 @@ class Reservation extends Common\Ideal\Repository
|
||||
$exceptions[] = new Common\Implement\Exception\EmptyResult('No cancelled reservations', $exception);
|
||||
}
|
||||
if (count($reservations) === 0) {
|
||||
throw new Common\Implement\Exception\EmptyResult('No rejected nor cancelled reservations', last($exceptions));
|
||||
$exception = null;
|
||||
if (count($exceptions) > 0) {
|
||||
$exception = last($exceptions);
|
||||
}
|
||||
throw new Common\Implement\Exception\EmptyResult('No rejected nor cancelled reservations', $exception);
|
||||
}
|
||||
return $reservations;
|
||||
}
|
||||
|
||||
@ -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');
|
||||
|
||||
Reference in New Issue
Block a user