getParsedBody(); $output = [ 'input' => $body, 'movimientos' => [] ]; try { $inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']); $banco = $bancoRepository->fetchById($body['banco']); $mes = new DateTimeImmutable($body['mes']); $file = $request->getUploadedFiles()['file']; $output['movimientos'] = $cartolaService->process($inmobiliaria, $banco, $mes, $file); } catch (EmptyResult) {} return $this->withJson($response, $output); } public function exportar(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria $inmobiliariaRepository, Repository\Banco $bancoRepository, Service\Cartola $cartolaService): ResponseInterface { $body = $request->getParsedBody(); $output = [ 'input' => $body, 'filename' => '' ]; try { $inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria']); $banco = $bancoRepository->fetchById($body['banco']); $mes = new DateTimeImmutable($body['mes']); $output['filename'] = $cartolaService->export($inmobiliaria, $banco, $mes, json_decode($body['movimientos'])); } catch (EmptyResult) {} return $this->withJson($response, $output); } public function diaria(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria\Cuenta $cuentaRepository, Service\Cartola $cartolaService): ResponseInterface { $body = $request->getParsedBody(); $output = [ 'input' => $body, 'cartolas' => [] ]; $fields = json_decode($body['fields']); foreach ($fields as $field) { try { $cuenta = $cuentaRepository->fetchById($body["cuenta_id{$field}"]); $fecha = new DateTimeImmutable($body["fecha{$field}"]); $file = $request->getUploadedFiles()["file{$field}"]; $output['cartolas'][$field] = $cartolaService->diaria($cuenta, $fecha, $file); } catch (EmptyResult $exception) { $this->logger->debug($exception); } } return $this->withJson($response, $output); } public function ayer(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria\Cuenta $cuentaRepository, Repository\Cartola $cartolaRepository): ResponseInterface { $body = $request->getParsedBody(); $output = [ 'input' => $body, 'cartola' => [] ]; try { $cuenta = $cuentaRepository->fetchById($body['cuenta_id']); $fecha = new DateTimeImmutable($body['fecha']); $output['cartola'] = $cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha); } catch (EmptyResult) {} return $this->withJson($response, $output); } }