Restructura contabilidad

This commit is contained in:
Juan Pablo Vial
2024-03-26 09:38:20 -03:00
parent 4b3397dd63
commit 5f56022109
57 changed files with 311 additions and 291 deletions

View File

@ -1,24 +1,23 @@
<?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;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Cartolas extends Controller
{
use withJson;
public function procesar(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Banco $bancoRepository,
Service\Cartola $cartolaService): ResponseInterface
public function procesar(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Contabilidad\Banco $bancoRepository,
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
{
$body = $request->getParsedBody();
$output = [
@ -34,10 +33,10 @@ class Cartolas extends Controller
} catch (EmptyResult) {}
return $this->withJson($response, $output);
}
public function exportar(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Banco $bancoRepository,
Service\Cartola $cartolaService): ResponseInterface
public function exportar(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Contabilidad\Banco $bancoRepository,
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
{
$body = $request->getParsedBody();
$output = [
@ -52,9 +51,9 @@ class Cartolas extends Controller
} catch (EmptyResult) {}
return $this->withJson($response, $output);
}
public function diaria(ServerRequestInterface $request, ResponseInterface $response,
public function diaria(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria\Cuenta $cuentaRepository,
Service\Cartola $cartolaService): ResponseInterface
Service\Contabilidad\Cartola $cartolaService): ResponseInterface
{
$body = $request->getParsedBody();
$output = [
@ -80,9 +79,9 @@ class Cartolas extends Controller
}
return $this->withJson($response, $output);
}
public function ayer(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria\Cuenta $cuentaRepository,
Repository\Cartola $cartolaRepository): ResponseInterface
public function ayer(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria\Cuenta $cuentaRepository,
Repository\Contabilidad\Cartola $cartolaRepository): ResponseInterface
{
$body = $request->getParsedBody();
$output = [

View File

@ -1,17 +1,18 @@
<?php
namespace Incoviba\Controller\API;
namespace Incoviba\Controller\API\Contabilidad;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Controller\API\withJson;
use Incoviba\Repository;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class CentrosCostos
{
use withJson;
public function add(ServerRequestInterface $request, ResponseInterface $response,
Repository\CentroCosto $centroCostoRepository): ResponseInterface
public function add(ServerRequestInterface $request, ResponseInterface $response,
Repository\Contabilidad\CentroCosto $centroCostoRepository): ResponseInterface
{
$body = $request->getParsedBody();
$output = [
@ -26,8 +27,8 @@ class CentrosCostos
} catch (EmptyResult) {}
return $this->withJson($response, $output);
}
public function edit(ServerRequestInterface $request, ResponseInterface $response,
Repository\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
public function edit(ServerRequestInterface $request, ResponseInterface $response,
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
{
$body = $request->getParsedBody();
$output = [
@ -45,8 +46,8 @@ class CentrosCostos
} catch (EmptyResult) {}
return $this->withJson($response, $output);
}
public function remove(ServerRequestInterface $request, ResponseInterface $response,
Repository\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
public function remove(ServerRequestInterface $request, ResponseInterface $response,
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $centro_costo_id): ResponseInterface
{
$output = [
'centro_costo_id' => $centro_costo_id,

View File

@ -2,23 +2,23 @@
namespace Incoviba\Controller\API\Contabilidad;
use DateTimeImmutable;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Controller\API\withJson;
use Incoviba\Repository;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Depositos extends Ideal\Controller
{
use withJson;
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Banco $bancoRepository,
Repository\Inmobiliaria\Cuenta $cuentaRepository,
Repository\Deposito $dapRepository,
int $inmobiliaria_rut): ResponseInterface
public function inmobiliaria(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Contabilidad\Banco $bancoRepository,
Repository\Inmobiliaria\Cuenta $cuentaRepository,
Repository\Contabilidad\Deposito $dapRepository,
int $inmobiliaria_rut): ResponseInterface
{
$output = [
'inmobiliaria_rut' => $inmobiliaria_rut,
@ -33,10 +33,10 @@ class Depositos extends Ideal\Controller
} catch (Implement\Exception\EmptyResult) {}
return $this->withJson($response, $output);
}
public function add(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository, Repository\Banco $bancoRepository,
Repository\Inmobiliaria\Cuenta $cuentaRepository,
Repository\Deposito $dapRepository): ResponseInterface
public function add(ServerRequestInterface $request, ResponseInterface $response,
Repository\Inmobiliaria $inmobiliariaRepository, Repository\Contabilidad\Banco $bancoRepository,
Repository\Inmobiliaria\Cuenta $cuentaRepository,
Repository\Contabilidad\Deposito $dapRepository): ResponseInterface
{
$body = $request->getParsedBody();
$output = [

View File

@ -1,21 +1,21 @@
<?php
namespace Incoviba\Controller\API\Contabilidad;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Controller\API\withJson;
use Incoviba\Common\Ideal;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Movimientos extends Ideal\Controller
{
use withJson;
public function detalles(ServerRequestInterface $request, ResponseInterface $response,
Service\Movimiento $movimientoService,
Repository\CentroCosto $centroCostoRepository, int $movimiento_id): ResponseInterface
public function detalles(ServerRequestInterface $request, ResponseInterface $response,
Service\Contabilidad\Movimiento $movimientoService,
Repository\Contabilidad\CentroCosto $centroCostoRepository, int $movimiento_id): ResponseInterface
{
$body = $request->getParsedBody();
$output = [

View File

@ -1,11 +1,12 @@
<?php
namespace Incoviba\Controller\API;
namespace Incoviba\Controller\API\Contabilidad;
use DateTimeImmutable;
use Incoviba\Common\Implement\Exception\HttpResponse;
use Incoviba\Controller\API\withJson;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Implement\Exception\HttpResponse;
use Incoviba\Service;
class Nubox
{

View File

@ -1,32 +0,0 @@
<?php
namespace Incoviba\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Repository;
use Incoviba\Common\Alias\View;
class CentrosCostos
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
Repository\CentroCosto $centroCostoRepository,
Repository\TipoCentro $tipoCentroRepository,
Repository\CategoriaCentro $categoriaCentroRepository,
Repository\TipoCuenta $tipoCuentaRepository): ResponseInterface
{
$centrosCostos = $centroCostoRepository->fetchAll();
$tiposCentros = $tipoCentroRepository->fetchAll();
$categorias = $categoriaCentroRepository->fetchAll('descripcion');
$tiposCuentas = $tipoCuentaRepository->fetchAll();
return $view->render($response, 'contabilidad.centros_costos', compact('centrosCostos',
'tiposCentros', 'categorias', 'tiposCuentas'));
}
public function asignar(ServerRequestInterface $request, ResponseInterface $response, View $view,
Repository\CentroCosto $centroCostoRepository,
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
{
$centrosCostos = $centroCostoRepository->fetchAll();
$inmobiliarias = $inmobiliariaRepository->fetchAllActive('razon');
return $view->render($response, 'contabilidad.centros_costos.asignar', compact('centrosCostos', 'inmobiliarias'));
}
}

View File

@ -1,25 +1,25 @@
<?php
namespace Incoviba\Controller;
use DateTimeImmutable;
use DateInterval;
use Incoviba\Common\Ideal\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use DateTimeImmutable;
use Incoviba\Common\Alias\View;
use Incoviba\Common\Implement\Exception\{EmptyResult, EmptyRedis};
use Incoviba\Common\Ideal\Controller;
use Incoviba\Common\Implement\Exception\{EmptyRedis, EmptyResult};
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Contabilidad extends Controller
{
use withRedis;
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
Service\Redis $redisService,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\CentroCosto $centroCostoRepository): ResponseInterface
public function diaria(ServerRequestInterface $request, ResponseInterface $response, View $view,
Service\Redis $redisService,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Contabilidad\CentroCosto $centroCostoRepository): ResponseInterface
{
$redisKey = 'inmobiliarias';
$inmobiliarias = [];
@ -34,10 +34,10 @@ class Contabilidad extends Controller
$centrosCostos = $centroCostoRepository->fetchAll();
return $view->render($response, 'contabilidad.cartolas.diaria', compact('inmobiliarias', 'centrosCostos'));
}
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
Service\Redis $redisService,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Deposito $dapRepository): ResponseInterface
public function depositos(ServerRequestInterface $request, ResponseInterface $response, View $view,
Service\Redis $redisService,
Repository\Inmobiliaria $inmobiliariaRepository,
Repository\Contabilidad\Deposito $dapRepository): ResponseInterface
{
$redisKey = 'inmobiliarias';
$inmobiliarias = [];
@ -54,11 +54,11 @@ class Contabilidad extends Controller
$depositos = $dapRepository->fetchAll();
} catch (EmptyResult) {}
$fecha = new DateTimeImmutable('today');
$activos = array_filter($depositos, function(Model\Deposito $deposito) use ($fecha) {
$activos = array_filter($depositos, function(Model\Contabilidad\Deposito $deposito) use ($fecha) {
return $deposito->termino >= $fecha;
});
$mes = $fecha->sub(new DateInterval('P1M'));
$vencidos = array_filter($depositos, function(Model\Deposito $deposito) use ($fecha, $mes) {
$vencidos = array_filter($depositos, function(Model\Contabilidad\Deposito $deposito) use ($fecha, $mes) {
return $deposito->termino < $fecha and $deposito->termino >= $mes;
});
return $view->render($response, 'contabilidad.depositos', compact('inmobiliarias', 'activos', 'vencidos'));

View File

@ -0,0 +1,32 @@
<?php
namespace Incoviba\Controller\Contabilidad;
use Incoviba\Common\Alias\View;
use Incoviba\Repository;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class CentrosCostos
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
Repository\Contabilidad\CentroCosto $centroCostoRepository,
Repository\Contabilidad\TipoCentro $tipoCentroRepository,
Repository\Contabilidad\CategoriaCentro $categoriaCentroRepository,
Repository\TipoCuenta $tipoCuentaRepository): ResponseInterface
{
$centrosCostos = $centroCostoRepository->fetchAll();
$tiposCentros = $tipoCentroRepository->fetchAll();
$categorias = $categoriaCentroRepository->fetchAll('descripcion');
$tiposCuentas = $tipoCuentaRepository->fetchAll();
return $view->render($response, 'contabilidad.centros_costos', compact('centrosCostos',
'tiposCentros', 'categorias', 'tiposCuentas'));
}
public function asignar(ServerRequestInterface $request, ResponseInterface $response, View $view,
Repository\Contabilidad\CentroCosto $centroCostoRepository,
Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
{
$centrosCostos = $centroCostoRepository->fetchAll();
$inmobiliarias = $inmobiliariaRepository->fetchAllActive('razon');
return $view->render($response, 'contabilidad.centros_costos.asignar', compact('centrosCostos', 'inmobiliarias'));
}
}

View File

@ -1,14 +1,14 @@
<?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;
use Incoviba\Common\Implement\Exception\EmptyRedis;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Ventas
{
@ -103,12 +103,12 @@ class Ventas
$venta = $ventaService->getById($venta_id);
return $view->render($response, 'ventas.pies.cuotas', compact('venta'));
}
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
Repository\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
public function escriturar(ServerRequestInterface $request, ResponseInterface $response, Service\Venta $ventaService,
Repository\Contabilidad\Banco $bancoRepository, View $view, int $venta_id): ResponseInterface
{
$venta = $ventaService->getById($venta_id);
$bancos = $bancoRepository->fetchAll();
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
return strcmp($a->nombre, $b->nombre);
});
return $view->render($response, 'ventas.escriturar', compact('venta', 'bancos'));

View File

@ -1,17 +1,17 @@
<?php
namespace Incoviba\Controller\Ventas;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Alias\View;
use Incoviba\Common\Ideal\Controller;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Creditos extends Controller
{
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
Service\Venta $ventaService, Repository\Banco $bancoRepository,
Service\Venta $ventaService, Repository\Contabilidad\Banco $bancoRepository,
int $venta_id): ResponseInterface
{
$venta = $ventaService->getById($venta_id);

View File

@ -2,13 +2,13 @@
namespace Incoviba\Controller\Ventas;
use DateTimeImmutable;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Common\Alias\View;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use Incoviba\Model;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Cuotas
{
@ -73,12 +73,12 @@ class Cuotas
$response->getBody()->write(json_encode($output));
return $response->withHeader('Content-Type', 'application/json');
}
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
{
$pie = $pieService->getById($pie_id);
$venta = $ventaRepository->fetchByPie($pie_id);
$bancos = $bancoRepository->fetchAll();
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
return strcmp($a->nombre, $b->nombre);
});
return $view->render($response, 'ventas.pies.cuotas.add', compact('pie', 'venta', 'bancos'));

View File

@ -1,11 +1,11 @@
<?php
namespace Incoviba\Controller\Ventas;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Alias\View;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class Escrituras
{
@ -22,8 +22,8 @@ class Escrituras
return $view->render($response, 'ventas.escrituras.informe', compact('venta'));
}
public function add(ServerRequestInterface $request, ResponseInterface $response, View $view,
Service\Venta $ventaService, Repository\Banco $bancoRepository,
int $venta_id): ResponseInterface
Service\Venta $ventaService, Repository\Contabilidad\Banco $bancoRepository,
int $venta_id): ResponseInterface
{
$venta = $ventaService->getById($venta_id);
$bancos = $bancoRepository->fetchAll('nombre');

View File

@ -1,21 +1,21 @@
<?php
namespace Incoviba\Controller\Ventas;
use Incoviba\Common\Alias\View;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Incoviba\Common\Alias\View;
use Incoviba\Service;
use Incoviba\Repository;
use Incoviba\Model;
class Pies
{
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
public function cuotas(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, Repository\Venta $ventaRepository, Repository\Contabilidad\Banco $bancoRepository, View $view, int $pie_id): ResponseInterface
{
$pie = $pieService->getById($pie_id);
$venta = $ventaRepository->fetchByPie($pie_id);
$bancos = $bancoRepository->fetchAll();
usort($bancos, function(Model\Banco $a, Model\Banco $b) {
usort($bancos, function(Model\Contabilidad\Banco $a, Model\Contabilidad\Banco $b) {
return strcmp($a->nombre, $b->nombre);
});
return $view->render($response, 'ventas.pies.cuotas', compact('pie', 'venta', 'bancos'));