Cartola diaria
This commit is contained in:
@ -13,62 +13,5 @@ class Contabilidad extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function procesarCartola(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->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 exportarCartola(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 procesarCartolaDiaria(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'cartola' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria_rut']);
|
||||
$banco = $bancoRepository->fetchById($body['banco_id']);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$file = $request->getUploadedFiles()['file'];
|
||||
$output['cartola'] = $cartolaService->diaria($inmobiliaria, $banco, $fecha, $file);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->debug($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
98
app/src/Controller/API/Contabilidad/Cartolas.php
Normal file
98
app/src/Controller/API/Contabilidad/Cartolas.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Common\Ideal\Controller;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Cartolas extends Controller
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function procesar(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->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 $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Service\Cartola $cartolaService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'cartola' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria_rut']);
|
||||
$banco = $bancoRepository->fetchById($body['banco_id']);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$file = $request->getUploadedFiles()['file'];
|
||||
$output['cartola'] = $cartolaService->diaria($inmobiliaria, $banco, $fecha, $file);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->debug($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function ayer(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Banco $bancoRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository,
|
||||
Repository\Cartola $cartolaRepository): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'cartola' => []
|
||||
];
|
||||
try {
|
||||
$inmobiliaria = $inmobiliariaRepository->fetchById($body['inmobiliaria_rut']);
|
||||
$banco = $bancoRepository->fetchById($body['banco_id']);
|
||||
$cuenta = $cuentaRepository->fetchByInmobiliariaAndBanco($inmobiliaria->rut, $banco->id);
|
||||
$fecha = new DateTimeImmutable($body['fecha']);
|
||||
$output['cartola'] = $cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->critical($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
31
app/src/Controller/Contabilidad.php
Normal file
31
app/src/Controller/Contabilidad.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyResult, EmptyRedis};
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Contabilidad
|
||||
{
|
||||
use withRedis;
|
||||
|
||||
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Redis $redisService,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$redisKey = 'inmobiliarias';
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = $this->fetchRedis($redisService, $redisKey);
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||||
$this->saveRedis($redisService, $redisKey, $inmobiliarias, 30 * 24 * 60 * 60);
|
||||
} catch (EmptyResult) {}
|
||||
}
|
||||
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user