Listado proyectos

This commit is contained in:
2023-10-13 10:45:21 -03:00
parent 0d558b7980
commit c2a3192b32
26 changed files with 612 additions and 58 deletions

View File

@ -4,11 +4,13 @@ namespace Incoviba\Controller\API\Ventas;
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 Cierres
{
use withJson;
public function proyecto(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Cierre $service): ResponseInterface
{
$body = $request->getBody();
@ -20,8 +22,7 @@ class Cierres
$output['cierres'] = $cierres;
$output['total'] = count($cierres);
} catch (EmptyResult) {}
$response->getBody()->write(json_encode($output));
return $response->withHeader('Content-Type', 'application/json');
return $this->withJson($response, $output);
}
public function vigentes(ServerRequestInterface $request, ResponseInterface $response, Repository\Venta\Cierre $cierreRepository): ResponseInterface
{
@ -49,7 +50,6 @@ class Cierres
$output[$row['Proyecto']][$estado] += $row['Cantidad'];
$output[$row['Proyecto']]['total'] += $row['Cantidad'];
}
$response->getBody()->write(json_encode(['cierres' => $output]));
return $response->withHeader('Content-Type', 'application/json');
return $this->withJson($response, ['cierres' => $output]);
}
}