Ventas por unidades
This commit is contained in:
@ -9,6 +9,7 @@ use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Common\Implement\Exception\EmptyRedis;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\withRedis;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
@ -368,4 +369,23 @@ class Ventas extends Controller
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function byUnidades(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta $ventaService, Service\Venta\Unidad $unidadService): ResponseInterface
|
||||
{
|
||||
$input = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'ventas' => []
|
||||
];
|
||||
foreach ($input['unidad_ids'] as $unidad_id) {
|
||||
try {
|
||||
$venta = $ventaService->getByUnidadId($unidad_id);
|
||||
$output['ventas'][] = [
|
||||
'unidad_id' => $unidad_id,
|
||||
'venta' => $venta
|
||||
];
|
||||
} catch (Read) {}
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user