52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
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;
|
|
|
|
class Escrituras
|
|
{
|
|
use withJson;
|
|
|
|
public function add(ServerRequestInterface $request, ResponseInterface $response,
|
|
Service\Venta\Escritura $escrituraService, int $venta_id): ResponseInterface
|
|
{
|
|
$body = $request->getParsedBody();
|
|
$output = [
|
|
'venta_id' => $venta_id,
|
|
'input' => $body,
|
|
'escritura' => null,
|
|
'status' => false
|
|
];
|
|
try {
|
|
$output['escritura'] = $escrituraService->add($venta_id, $body);
|
|
$output['status'] = true;
|
|
} catch (EmptyResult) {}
|
|
return $this->withJson($response, $output);
|
|
}
|
|
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
|
Service\Venta\Escritura $escrituraService,
|
|
int $venta_id): ResponseInterface
|
|
{
|
|
$body = $request->getParsedBody();
|
|
$output = [
|
|
'venta_id' => $venta_id,
|
|
'input' => $body,
|
|
'success' => false
|
|
];
|
|
try {
|
|
$escrituraService->edit($venta_id, $body);
|
|
$output['success'] = true;
|
|
} catch (Read|Update|EmptyResult) {}
|
|
return $this->withJson($response, $output);
|
|
}
|
|
}
|