Files
oficial/app/src/Controller/API/Ventas/Facturas.php

33 lines
997 B
PHP
Raw Normal View History

2024-06-18 22:41:03 -04:00
<?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,
2025-01-17 00:04:34 -03:00
'success' => false
2024-06-18 22:41:03 -04:00
];
try {
$output['factura'] = $facturaService->add($data);
2025-01-17 00:04:34 -03:00
$output['success'] = true;
2024-06-18 22:41:03 -04:00
} catch (Implement\Exception\EmptyResult) {
$output['error'] = 'No se pudo agregar la factura';
return $this->withJson($response, $output, 400);
}
return $this->withJson($response, $output);
}
}