2024-06-18

This commit is contained in:
Juan Pablo Vial
2024-06-18 22:41:03 -04:00
parent 6169089475
commit 390e79ad6d
60 changed files with 3162 additions and 155 deletions

View File

@ -0,0 +1,32 @@
<?php
namespace Incoviba\Controller\API\Ventas;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Incoviba\Controller\API\withJson;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Common\Implement;
use Incoviba\Service;
class Facturas extends Controller
{
use withJson;
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Factura $facturaService): ResponseInterface
{
$data = $request->getParsedBody();
$output = [
'input' => $data,
'factura' => null,
'saved' => false
];
try {
$output['factura'] = $facturaService->add($data);
$output['saved'] = true;
} catch (Implement\Exception\EmptyResult) {
$output['error'] = 'No se pudo agregar la factura';
return $this->withJson($response, $output, 400);
}
return $this->withJson($response, $output);
}
}