Edit fecha escritura
This commit is contained in:
38
app/src/Controller/API/Ventas/Escrituras.php
Normal file
38
app/src/Controller/API/Ventas/Escrituras.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Ventas;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Escrituras
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta $ventaService, Repository\Venta\EstadoVenta $estadoVentaRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'venta_id' => $venta_id,
|
||||
'input' => $body,
|
||||
'edited' => false
|
||||
];
|
||||
try {
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$estado = $venta->currentEstado();
|
||||
if (!in_array($estado->tipoEstadoVenta->descripcion, ['escriturando', 'firmado por inmobiliaria'])) {
|
||||
throw new EmptyResult('');
|
||||
}
|
||||
$body['fecha'] = (new DateTimeImmutable($body['fecha']))->format('Y-m-d');
|
||||
$estadoVentaRepository->edit($estado, $body);
|
||||
$output['edited'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
16
app/src/Controller/Ventas/Escrituras.php
Normal file
16
app/src/Controller/Ventas/Escrituras.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Escrituras
|
||||
{
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.escrituras.show', compact('venta'));
|
||||
}
|
||||
}
|
17
app/src/Controller/Ventas/Estados.php
Normal file
17
app/src/Controller/Ventas/Estados.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Estados
|
||||
{
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
View $view, Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.estado', compact('venta'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user