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,28 +1,27 @@
<?php
namespace Incoviba\Service;
namespace Incoviba\Service\Contabilidad;
use DateTimeInterface;
use DateTimeImmutable;
use DateInterval;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileInterface;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal\Service;
use DateTimeInterface;
use Incoviba\Common\Define\Cartola\Banco;
use Incoviba\Common\Define\Contabilidad\Exporter;
use Incoviba\Common\Ideal\Service;
use Incoviba\Common\Implement\Exception;
use Incoviba\Model;
use Incoviba\Repository;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileInterface;
use Psr\Log\LoggerInterface;
class Cartola extends Service
{
public function __construct(LoggerInterface $logger,
protected StreamFactoryInterface $streamFactory, protected Exporter $exporter,
protected Repository\Inmobiliaria $inmobiliariaRepository,
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
protected Repository\Movimiento $movimientoRepository,
protected Movimiento $movimientoService,
protected Repository\Cartola $cartolaRepository) {
public function __construct(LoggerInterface $logger,
protected StreamFactoryInterface $streamFactory, protected Exporter $exporter,
protected Repository\Inmobiliaria $inmobiliariaRepository,
protected Repository\Inmobiliaria\Cuenta $cuentaRepository,
protected Repository\Contabilidad\Movimiento $movimientoRepository,
protected Movimiento $movimientoService,
protected Repository\Contabilidad\Cartola $cartolaRepository) {
parent::__construct($logger);
}
@ -32,11 +31,11 @@ class Cartola extends Service
$this->bancos[$name] = $banco;
return $this;
}
public function process(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, UploadedFileInterface $file): array
public function process(Model\Inmobiliaria $inmobiliaria, Model\Contabilidad\Banco $banco, DateTimeInterface $mes, UploadedFileInterface $file): array
{
return $this->bancos[strtolower($banco->nombre)]->process($file);
}
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string
public function export(Model\Inmobiliaria $inmobiliaria, Model\Contabilidad\Banco $banco, DateTimeInterface $mes, array $movimientos): string
{
return $this->exporter->export($inmobiliaria, $banco, $mes, $movimientos);
}
@ -93,13 +92,13 @@ class Cartola extends Service
return compact('cartola', 'movimientos');
}
protected function getMovimientosDiarios(Model\Banco $banco, UploadedFileInterface $file): array
protected function getMovimientosDiarios(Model\Contabilidad\Banco $banco, UploadedFileInterface $file): array
{
$movimientos = $this->bancos[strtolower($banco->nombre)]->process($file);
return $this->bancos[strtolower($banco->nombre)]->processMovimientosDiarios($movimientos);
}
protected array $groupedMovimientos = [];
protected function groupMovimientoByDay(Model\Movimiento $movimiento): Cartola
protected function groupMovimientoByDay(Model\Contabilidad\Movimiento $movimiento): Cartola
{
if (!isset($this->groupedMovimientos[$movimiento->fecha->getTimestamp()])) {
$this->groupedMovimientos[$movimiento->fecha->getTimestamp()] = [];
@ -107,7 +106,7 @@ class Cartola extends Service
$this->groupedMovimientos[$movimiento->fecha->getTimestamp()] []= $movimiento;
return $this;
}
protected function buildCartola(Model\Inmobiliaria\Cuenta $cuenta, DateTimeInterface $fecha, array $data): Model\Cartola
protected function buildCartola(Model\Inmobiliaria\Cuenta $cuenta, DateTimeInterface $fecha, array $data): Model\Contabilidad\Cartola
{
try {
return $this->cartolaRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
@ -118,7 +117,7 @@ class Cartola extends Service
return $this->cartolaRepository->save($cartola);
}
}
protected function buildMovimiento(Model\Inmobiliaria\Cuenta $cuenta, array $data): Model\Movimiento
protected function buildMovimiento(Model\Inmobiliaria\Cuenta $cuenta, array $data): Model\Contabilidad\Movimiento
{
try {
return $this->movimientoRepository

View File

@ -1,9 +1,9 @@
<?php
namespace Incoviba\Service\Cartola;
namespace Incoviba\Service\Contabilidad\Cartola;
use Psr\Http\Message\UploadedFileInterface;
use PhpOffice\PhpSpreadsheet;
use Incoviba\Common\Ideal\Cartola\Banco;
use PhpOffice\PhpSpreadsheet;
use Psr\Http\Message\UploadedFileInterface;
class BCI extends Banco
{

View File

@ -1,10 +1,10 @@
<?php
namespace Incoviba\Service\Cartola;
namespace Incoviba\Service\Contabilidad\Cartola;
use DateTimeImmutable;
use Psr\Http\Message\UploadedFileInterface;
use PhpOffice\PhpSpreadsheet;
use Incoviba\Common\Ideal\Cartola\Banco;
use PhpOffice\PhpSpreadsheet;
use Psr\Http\Message\UploadedFileInterface;
class Itau extends Banco
{

View File

@ -1,10 +1,9 @@
<?php
namespace Incoviba\Service\Cartola;
namespace Incoviba\Service\Contabilidad\Cartola;
use DateTimeImmutable;
use Psr\Http\Message\UploadedFileInterface;
use PhpOffice\PhpSpreadsheet;
use Incoviba\Common\Ideal\Cartola\Banco;
use PhpOffice\PhpSpreadsheet;
use Psr\Http\Message\UploadedFileInterface;
class Santander extends Banco
{

View File

@ -1,11 +1,11 @@
<?php
namespace Incoviba\Service\Cartola;
namespace Incoviba\Service\Contabilidad\Cartola;
use DOMDocument;
use DateTimeImmutable;
use Psr\Http\Message\UploadedFileInterface;
use PhpOffice\PhpSpreadsheet;
use DOMDocument;
use Incoviba\Common\Ideal\Cartola\Banco;
use PhpOffice\PhpSpreadsheet;
use Psr\Http\Message\UploadedFileInterface;
class Security extends Banco
{

View File

@ -10,9 +10,9 @@ use PhpOffice\PhpSpreadsheet;
class Nubox implements Exporter
{
public function __construct(protected Repository\CentroCosto $centroCostoRepository, protected string $uploadFolder) {}
public function __construct(protected Repository\Contabilidad\CentroCosto $centroCostoRepository, protected string $uploadFolder) {}
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string
public function export(Model\Inmobiliaria $inmobiliaria, Model\Contabilidad\Banco $banco, DateTimeInterface $mes, array $movimientos): string
{
PhpSpreadsheet\Settings::setLocale('es-CL');
$workbook = new PhpSpreadsheet\Spreadsheet();

View File

@ -1,23 +1,23 @@
<?php
namespace Incoviba\Service\Contabilidad\Informe;
use DateTimeInterface;
use DateInterval;
use Psr\Log\LoggerInterface;
use DateTimeInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Log\LoggerInterface;
class Tesoreria extends Ideal\Service
{
public function __construct(LoggerInterface $logger,
protected Repository\Inmobiliaria $inmobiliariaRepository,
protected Service\Inmobiliaria\Cuenta $cuentaService,
protected Repository\Deposito $depositoRepository,
protected Repository\Cartola $cartolaRepository,
protected Repository\Movimiento $movimientoRepository,
protected Repository\Contabilidad\Deposito $depositoRepository,
protected Repository\Contabilidad\Cartola $cartolaRepository,
protected Repository\Contabilidad\Movimiento $movimientoRepository,
protected Service\Contabilidad\Informe\Tesoreria\Excel $excelService,
protected Service\Contabilidad\Informe\Tesoreria\PDF $pdfService)
{
@ -241,11 +241,11 @@ class Tesoreria extends Ideal\Service
try {
$movimientos = $this->movimientoRepository->fetchByCuentaAndFecha($cuenta->id, $fecha);
$this->addMovimientos(self::INGRESOS,
array_filter($movimientos, function(Model\Movimiento $movimiento) {
array_filter($movimientos, function(Model\Contabilidad\Movimiento $movimiento) {
return $movimiento->abono > 0;
}));
$this->addMovimientos(self::EGRESOS,
array_filter($movimientos, function(Model\Movimiento $movimiento) {
array_filter($movimientos, function(Model\Contabilidad\Movimiento $movimiento) {
return $movimiento->cargo > 0;
}));
} catch (Implement\Exception\EmptyResult) {}

View File

@ -1,26 +1,26 @@
<?php
namespace Incoviba\Service;
namespace Incoviba\Service\Contabilidad;
use DateTimeInterface;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal\Service;
use Incoviba\Common\Implement;
use Incoviba\Repository;
use Incoviba\Model;
use Incoviba\Repository;
use Psr\Log\LoggerInterface;
class Movimiento extends Service
{
public function __construct(LoggerInterface $logger, protected Repository\Movimiento $movimientoRepository,
public function __construct(LoggerInterface $logger,
protected Repository\Contabilidad\Movimiento $movimientoRepository,
protected Repository\Movimiento\Detalle $detalleRepository)
{
parent::__construct($logger);
}
public function getById(int $movimiento_id): Model\Movimiento
public function getById(int $movimiento_id): Model\Contabilidad\Movimiento
{
return $this->process($this->movimientoRepository->fetchById($movimiento_id));
}
public function setDetalles(Model\Movimiento $movimiento, array $data): Model\Movimiento
public function setDetalles(Model\Contabilidad\Movimiento $movimiento, array $data): Model\Contabilidad\Movimiento
{
try {
$detalles = $this->detalleRepository->fetchByMovimiento($movimiento->id);
@ -33,7 +33,7 @@ class Movimiento extends Service
return $movimiento;
}
public function process(Model\Movimiento $movimiento): Model\Movimiento
public function process(Model\Contabilidad\Movimiento $movimiento): Model\Contabilidad\Movimiento
{
$movimiento->addFactory('detalles', (new Implement\Repository\Factory())->setCallable(function(int $movimiento_id) {
return $this->detalleRepository->fetchByMovimiento($movimiento_id);

View File

@ -2,24 +2,24 @@
namespace Incoviba\Service\Contabilidad;
use DateTimeInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement\Exception;
use Incoviba\Repository;
use Incoviba\Service;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Implement\Exception;
use Incoviba\Repository;
use Incoviba\Service;
use Incoviba\Common\Ideal;
class Nubox extends Ideal\Service
{
public function __construct(protected LoggerInterface $logger,
protected Repository\Nubox $nuboxRepository,
protected Service\Redis $redisService,
protected ClientInterface $client,
protected RequestFactoryInterface $requestFactory,
protected string $api_url)
public function __construct(protected LoggerInterface $logger,
protected Repository\Contabilidad\Nubox $nuboxRepository,
protected Service\Redis $redisService,
protected ClientInterface $client,
protected RequestFactoryInterface $requestFactory,
protected string $api_url)
{
parent::__construct($logger);
}