Compare commits

..

45 Commits

Author SHA1 Message Date
Felix Morales b5eba08ffa Creacion del funcionamiento para generar el reporte general 5 days ago
Felix Morales 7f35bc9d02 Upgraded the upload maximum file size up to 200MB 2 months ago
Felix Morales 395d21d2e9 Added a new endpoint to supply the D: drive storage status to the front end 3 months ago
Felix Morales aad941897f Functionality is created to handle requests from the Alen account statements component on the client side 3 months ago
Felix Morales eac74a4b62 Fix an route permission error by adding a try catch estructure to the GetFileContentById endpoint 4 months ago
Felix Morales b68cffe741 Se corrige el id para tomar la ruta del archivo elecgt 5 months ago
Felix Morales 7b75d79348 Merge branch 'feature/Creacion_Reporte_Archivo_Electronico_20240417' 5 months ago
Felix Morales ce5f7a2971 Creacion del reporte de archivos electronicos, comprimir los archivos oficiales de distintas referencias en un mismo zip 5 months ago
Felix Morales dcff6f0e91 Agregar la columna Total Pagado al reporte de cuentas pagadas 5 months ago
Felix Morales 8170a2a56b primer avance de la creacion del reporte de archivo electronico para la vista del cliente 5 months ago
Felix Morales 1a7db051eb Creacion del funcionamiento para exportar traficos a un excel en la vista del cliente 5 months ago
Felix Morales e6c0ed26cb Merge branch 'feature/Creacion_Catalogo_Tabuladores_Corresponsales_20240408' 6 months ago
Felix Morales 8f21cff4c2 Se agregan las propiedades Tipo y Moneda a los tabuladores y la propiedad CostoCorresponsal al detalle de los tabuladores 6 months ago
Felix Morales 07eeaeba7b Agregar las nuevas propiedades al DTO del reporte de cuentas cerradas 6 months ago
Felix Morales 6ae359d50a Se quitan propiedades del DTO que no corresponden al desarrollo de esta rama 6 months ago
Felix Morales 6712176496 Se agrega la propiedad IdCorresponsal a los tabuladores para hacer la distincion cuando es un tabulador de cliente y cuando es de corresponsal 6 months ago
Felix Morales 778dbc46de Agregar columnas Fecha de Cruce y Semaforo fiscal de contenedores al reporte de cuentas cerradas 6 months ago
Felix Morales 53257ec2d6 Devolver la fecha de pago de los pedimentos de un trafico en null cuando no esta capturada 6 months ago
Felix Morales f37191134c Corregir la longitud del nombre del proveedor en el txt que se genera para facturacion 6 months ago
Felix Morales c68547eb34 Agregar la propiedad Estado a los filtros de la vista del cliente 6 months ago
Felix Morales 482bb62ba2 Agregar Columna del tipo de contenedor al reporte semanal de Newell 6 months ago
Felix Morales 619205387d Creacion del catalogo de tipos de contenedores y del funcionamiento para asignar el tipo de contenedor 6 months ago
Felix Morales b3bfc19d0f Cambiar el tipo de dato de la propiedad Aduana para ser almacenado como una cadena en lugar de como numero 6 months ago
Felix Morales 647193c3db Permitir crear referencias sin Pedimento para hacer cargos tipo OT 7 months ago
Felix Morales d19baaad78 Merge branch 'feature/solicitar_eliminacion_de_referenica_20240219' 7 months ago
Felix Morales 705ce31e4e Creacion de los enpoint para crear y obtener las solicitudes, además del endpoint para el indiciador del dashboard del supervisor de corresponsalias 7 months ago
Felix Morales 102207c514 Creacion del reporte de cuentas cerradas 7 months ago
Felix Morales 0b5de936a2 Renombrar modelo, dto y archivos de solicitudes 7 months ago
Felix Morales 5197a2c581 Merge branch 'bugfix/fix_reporte_semanal_newell' into feature/solicitar_eliminacion_de_referenica_20240219 7 months ago
Felix Morales 08e7c8f5ec al crear el reporte semanal se tomaba de la aduana y patente de las celdas A2 y B2 para buscar el trafico, ahora se toman del renglon que se está leyendo ya que puede haber más de una aduana y patente en el archivo 7 months ago
Felix Morales eefb8ddb36 primer avance para crear la solicitud para dar de baja una referencia 7 months ago
Felix Morales a439e3ac55 creacion de endpoints necesarios para crear solicitudes y reaperturar cuentas 8 months ago
Felix Morales ff19ac9612 fix, al crear el txt de facturacion no se borraban los saltos de linea de la descripcion de la mercancia 8 months ago
Felix Morales e22abe3952 Creacion de nuevo endpoint para consultar el historial completo de los movimientos de contabilidad en un trafico 8 months ago
Felix Morales ba01950af5 Se corrige error en el reporte semanal de newel al buscar los datos de un trafico en base a su pedimento 8 months ago
Felix Morales 7b81e1c16c Agregar las nuevas propiedades al DTO del historial de rechazos 8 months ago
Felix Morales 83ceff58cf Merge branch 'main' into feature/Cambio_Estructura_Historial_Rechazos_20230125 8 months ago
Felix Morales 1bd0d75014 Agregar columna Numero de Remesa y Contraprestacion al reporte de facturas de consolidados de Alen 8 months ago
Felix Morales 9761a27433 Se agregan los nuevos parámetros and endpoint para consultar los datos del dashboard de contabilidad 8 months ago
Felix Morales 377c6d01c5 Creacion del Txt de facturacion, enviar correo en caso de error 8 months ago
Felix Morales 2d2819ba97 Creacion del reporte de facturas de traficos consolidados de Alen 8 months ago
Felix Morales b9f26944fb Agregar multiples rectificaciones a un mismo trafico 9 months ago
Felix Morales b32321ea86 Ordenar las facturas en base a la fecha del contenedor y tomar la fecha más reciente de los contenedores para tomarla como fecha de desaduanamiento 9 months ago
Felix Morales c5afa9e7b7 Merge branch 'feature/Reporte_Relacion_Facturas_Alen' 9 months ago
Felix Morales 1702ee386c Funcionamiento para crear el reporte de relacion de facturas de alen 9 months ago
  1. 25
      CORRESPONSALBackend.sln
  2. 9
      Contracts/ArchivoElectronico/IArchivoElectronicoRepository.cs
  3. 5
      Contracts/ArchivoElectronico/IArchivoElectronicoService.cs
  4. 7
      Contracts/Catalogos/ICatTiposContenedoresRepository.cs
  5. 2
      Contracts/Catalogos/ITabuladorRepository.cs
  6. 3
      Contracts/Contabilidad/Corresponsalias/IContabilidadCorresponsaliasRepository.cs
  7. 11
      Contracts/Corresponsalias/ICorresponsaliasSolicitudesRepository.cs
  8. 9
      Contracts/Corresponsalias/ICorresponsaliasTraficosRepository.cs
  9. 6
      Contracts/Corresponsalias/Services/ICorresponsaliasTraficosService.cs
  10. 2
      Contracts/Dashboard/IDashboardCorresponsalesRepository.cs
  11. 16
      Contracts/Reportes/Alen/IEstadosCuentaAlenRepository.cs
  12. 5
      Contracts/Reportes/Alen/IReportesAlenRepository.cs
  13. 8
      Contracts/Reportes/Alen/IReportesAlenService.cs
  14. 7
      Contracts/Reportes/CuentasCerradas/IReporteCuentasCerradasRepository.cs
  15. 7
      Contracts/Reportes/CuentasCerradas/IReporteCuentasCerradasService.cs
  16. 8
      Contracts/Reportes/Facturacion/IReportesFacturacionRepository.cs
  17. 7
      Contracts/Reportes/ITraficosClientesService.cs
  18. 1
      Contracts/Utils/IFileManagerRepository.cs
  19. 6
      Controllers/AuthController.cs
  20. 22
      Controllers/Catalogos/CatTiposContenedoresController.cs
  21. 6
      Controllers/Catalogos/TabuladorController.cs
  22. 21
      Controllers/ClientesController.cs
  23. 12
      Controllers/Contabilidad/Corresponsales/ContabilidadTraficoController.cs
  24. 57
      Controllers/Corresponsalias/SolicitudesController.cs
  25. 100
      Controllers/Corresponsalias/TraficosController.cs
  26. 37
      Controllers/Dashboard/CorresponsalesController.cs
  27. 105
      Controllers/FileManagerController.cs
  28. 252
      Controllers/Reportes/Alen/ReporteEstadosCuentaAlenController.cs
  29. 54
      Controllers/Reportes/Facturacion/ReportesFacturacionController.cs
  30. 30
      Controllers/Reportes/ReporteCuentasCerradasController.cs
  31. 58
      Controllers/Reportes/ReportesAlenController.cs
  32. 93
      Controllers/Utils/ArchivoElectronicoController.cs
  33. 4
      Controllers/Utils/MFileManagerController.cs
  34. 1
      Controllers/Utils/ReportesController.cs
  35. 3
      DTO/Corresponsales/DTOCorresponsalTrafico.cs
  36. 11
      DTO/Corresponsales/DTORectificacionHistorico.cs
  37. 2
      DTO/Corresponsales/DTOTraficoCompleto.cs
  38. 11
      DTO/Corresponsales/DTOTraficoSolicitud.cs
  39. 50
      DTO/Reportes/Alen/DTOEstadosCuentaAlen.cs
  40. 13
      DTO/Reportes/Alen/DTOEstadosCuentaAlenFilters.cs
  41. 20
      DTO/Reportes/Alen/DTOReporteFacturasTraficosConsolidados.cs
  42. 26
      DTO/Reportes/CuentasCerradas/DTOReporteCuentasCerradas.cs
  43. 3
      DTO/Reportes/DTOFiltrosTraficosClientes.cs
  44. 2
      DTO/Reportes/DTOReporteCorresponsales.cs
  45. 1
      DTO/Reportes/DTOReporteSemanalNewel.cs
  46. 32
      DTO/Reportes/Facturacion/DTOReporteGeneralFacturacion.cs
  47. 2
      DTO/Reportes/GC50/DTOReporteGC50.cs
  48. 2
      Models/Catalogos/CatCorresponsales.cs
  49. 6
      Models/Catalogos/CatTiposContenedores.cs
  50. 3
      Models/Catalogos/Tabulador.cs
  51. 1
      Models/Catalogos/TabuladorDetalle.cs
  52. 39
      Models/Clientes/Alen/EstadosCuenta.cs
  53. 5
      Models/Corresponsales/CorresponsalFacturas.cs
  54. 4
      Models/Corresponsales/CorresponsalPedimentosConsolidados.cs
  55. 3
      Models/Corresponsales/CorresponsalTraficoContabilidad.cs
  56. 1
      Models/Corresponsales/CorresponsalesContenedores.cs
  57. 1
      Models/Corresponsales/IPrecuenta.cs
  58. 3
      Models/Corresponsales/ITrafico.cs
  59. 13
      Models/Corresponsales/ITraficoSolicitud.cs
  60. 11
      Models/Reportes/RptPedimentosPagadosAEO.cs
  61. 28
      Program.cs
  62. 31
      Repository/ArchivoElectronicoRepository.cs
  63. 23
      Repository/Catalogos/CatTiposContenedoresRepository.cs
  64. 1
      Repository/Catalogos/TabuladorDetalleRepository.cs
  65. 8
      Repository/Catalogos/TabuladorRepository.cs
  66. 3
      Repository/ClientesRepository.cs
  67. 20
      Repository/Contabilidad/ContabilidadCorresponsaliasRepository.cs
  68. 3
      Repository/Corresponsalias/CorresponsaliasContenedoresRepository.cs
  69. 7
      Repository/Corresponsalias/CorresponsaliasFacturasRepository.cs
  70. 85
      Repository/Corresponsalias/CorresponsaliasSolicitudesRepository.cs
  71. 3
      Repository/Corresponsalias/CorresponsaliasTraficoRectificacionHistorico.cs
  72. 54
      Repository/Corresponsalias/CorresponsaliasTraficosRepository.cs
  73. 18
      Repository/Dashboard/DashboardCorresponsalesRepository.cs
  74. 138
      Repository/Reportes/Alen/EstadosCuentaAlenRepository.cs
  75. 22
      Repository/Reportes/Alen/ReportesAlenRepository.cs
  76. 28
      Repository/Reportes/CuentasCerradas/ReporteCuentasCerradasRepository.cs
  77. 34
      Repository/Reportes/Facturacion/ReportesFacturacionRepository.cs
  78. 11
      Repository/Utils/FileManagerRepository.cs
  79. 7
      Services/ArchivoElectronicoService.cs
  80. 2
      Services/C1896/SrvUploadTemplete.cs
  81. 115
      Services/Corresponsalias/Traficos/CorresponsaliasTraficosService.cs
  82. 103
      Services/Reportes/Alen/ReportesAlenService.cs
  83. 43
      Services/Reportes/CuentasCerradas/ReporteCuentasCerradasService.cs
  84. 21
      Services/Reportes/Newell/Semanal/ReporteSemanalService.cs
  85. 63
      Services/Reportes/TraficosClientesService.cs
  86. 1
      appsettings.Development.json
  87. 1
      appsettings.Staging.json
  88. 1
      appsettings.json
  89. 2
      web.config

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CORRESPONSALBackend", "CORRESPONSALBackend.csproj", "{5FEAD431-682F-483D-8B56-E2F066C67B9D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5FEAD431-682F-483D-8B56-E2F066C67B9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FEAD431-682F-483D-8B56-E2F066C67B9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FEAD431-682F-483D-8B56-E2F066C67B9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FEAD431-682F-483D-8B56-E2F066C67B9D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3F707F07-2501-48B3-A5A3-AE1EF8C6847B}
EndGlobalSection
EndGlobal

@ -0,0 +1,9 @@
using CORRESPONSALBackend.DTO.ArchivoElectronico;
using GEMCO.Backend.Models.Reportes;
namespace CORRESPONSALBackend.Contracts.ArchivoElectronico{
public interface IArchivoElectronicoRepository
{
public Task<List<RptPedimentosPagadosAEO>> getRptPedimentoPagadosAEO(DTOAEPeriodo dTOData);
}
}

@ -0,0 +1,5 @@
namespace CORRESPONSALBackend.Contracts.ArchivoElectronico{
public interface IArchivoElectronicoService{
}
}

@ -0,0 +1,7 @@
using CORRESPONSALBackend.Models.Catalogos;
namespace CORRESPONSALBackend.Contracts.Catalogos{
public interface ICatTiposContenedoresRepository{
public Task<IEnumerable<CatTiposContenedores>> Get();
}
}

@ -3,7 +3,7 @@ namespace CORRESPONSALBackend.Contracts.Catalogos
{
public interface ITabuladorRepository
{
public Task<IEnumerable<Tabulador>> GetAll(int id, int IdCliente);
public Task<IEnumerable<Tabulador>> GetAll(int id, int IdCliente, int? idCorresponsal);
public Task<Tabulador> Append(Tabulador data);
public Task Delete(int id);
}

@ -5,6 +5,7 @@ namespace CORRESPONSALBackend.Contracts.Contabilidad.Corresponsalias
public interface IContabilidadCorresponsaliasRepository
{
public Task<CorresponsalTraficoContabilidad> Append(CorresponsalTraficoContabilidad data);
public Task<IEnumerable<string>> Get(int IdTrafico, int tipo);
public Task<IEnumerable<string>> Get(int IdTrafico, int procesoAnterior, int nuevoProceso);
public Task<IEnumerable<string>> Historial(int IdTrafico);
}
}

@ -0,0 +1,11 @@
using CORRESPONSALBackend.DTO.Corresponsales;
using CORRESPONSALBackend.Models.Corresponsales;
namespace CORRESPONSALBackend.Contracts.Corresponsalias{
public interface ICorresponsaliasSolicitudesRepository{
public Task<ITraficoSolicitud> AppendSolicitudReapertura(ITraficoSolicitud solicitud);
public Task<DTOTraficoSolicitud> GetSolicitudReapertura(int idTrafico);
public Task<ITraficoSolicitud> AppendSolicitudEliminarReferencia(ITraficoSolicitud solicitud);
public Task<DTOTraficoSolicitud> GetSolicitudEliminarReferencia(int idTrafico);
}
}

@ -9,16 +9,17 @@ namespace CORRESPONSALBackend.Contracts.Corresponsalias
public interface ICorresponsaliasTraficosRepository
{
public Task<ITrafico> Get(int id);
public Task<DTOReporteSemanalNewell> GetByPedimento(int pedimento);
public Task<DTOReporteSemanalNewell> GetByPedimento(int pedimento, string aduana, int patente);
public Task<ITrafico> GetByReferencia(string referencia);
public Task<DashboardTotal> GetAll(int Mode);
public Task<IEnumerable<ICorRectificaciones>> GetRectificaciones(int id);
public Task<ICorRectificaciones> AddRectificacion(int id);
public Task<ITrafico> Append(ITrafico data);
public Task<IEnumerable<CorresponsalesTraficoEstatus>> GetTraficoEstatus();
public Task<Boolean> ValidaTraficoCompleto(DTOTraficoCompleto data);
public Task<Boolean> RectificacionHistoricoAppend(DTORectificacionHistorico data);
public Task<CorresponsaliasTraficoRectificacionHistorico> RectificacionHistoricoGet(int IdTrafico);
public Task<CorresponsaliasTraficoRectificacionHistorico> RectificacionHistoricoAppend(DTORectificacionHistorico data);
public Task<IEnumerable<CorresponsaliasTraficoRectificacionHistorico>> RectificacionHistoricoGet(int IdTrafico);
public Task<string> ValidaTraficoDuplicado(int aduana, int patente, int pedimento, int idTrafico);
public Task<string> ValidaTraficoDuplicado(string aduana, int patente, int pedimento, int idTrafico);
}
}

@ -0,0 +1,6 @@
namespace CORRESPONSALBackend.Contracts.Corresponsalias.Services{
public interface ICorresponsaliasTraficosService{
public Task<List<string[]>> ReadTxtFacturasAlen(int fileId);
public Task<string> GetTxtFacturacionData(int idTrafico);
}
}

@ -10,5 +10,7 @@ namespace CORRESPONSALBackend.Contracts.Dashboard
public Task<DashboardCorresponsales> GetRechazosContabilidad();
public Task<IEnumerable<DashboardCorresponsales>> GetFacturacion();
public Task<DashboardCorresponsales> GetTraficosConCargosDlls();
public Task<DashboardCorresponsales> SolicitudesReapertura();
public Task<DashboardCorresponsales> SolicitudesElminarCuenta();
}
}

@ -0,0 +1,16 @@
using CORRESPONSALBackend.DTO.Reportes.Alen;
using CORRESPONSALBackend.Models.Clientes.Alen;
namespace CORRESPONSALBackend.Contracts.Reportes.Alen{
public interface IEstadosCuentaAlenRepository{
public Task ClearData();
public Task<IEnumerable<DTOEstadosCuentaAlen>> GetAll(DTOEstadosCuentaAlenFilters filters);
public Task<EstadosCuenta> Append (EstadosCuenta data);
public Task<EstadosCuenta> GetByFolio (string Folio);
public Task<EstadosCuenta> MarkAsProgramado (string NoMovimiento, string NoSerie);
public Task<EstadosCuenta> AppendOrdenCompra(DTOEstadosCuentaAlen data);
public Task<EstadosCuenta> AppendObservaciones(DTOEstadosCuentaAlen data);
}
}

@ -0,0 +1,5 @@
namespace CORRESPONSALBackend.Contracts.Reportes.Alen{
public interface IReportesAlenRepository{
public Task<IEnumerable<DTOReporteFacturasTraficosConsolidados>> GetFacturasTraficoConsolidado(int idTrafico, string referencia);
}
}

@ -0,0 +1,8 @@
using CORRESPONSALBackend.Models.Corresponsales;
namespace CORRESPONSALBackend.Contracts.Reportes.Alen{
public interface IReportesAlenService{
public Task<MemoryStream> GetRelacionFacturas(ITrafico trafico, IEnumerable<CorresponsalFacturas> facturas, IEnumerable<CorresponsalesContenedores> contenedores);
public Task<MemoryStream> GetReporteFacturasTraficoConsolidado(string referencia);
}
}

@ -0,0 +1,7 @@
using CORRESPONSALBackend.DTO.Reportes.CuentasCerradas;
namespace CORRESPONSALBackend.Contracts.Reportes.CuentasCerradas{
public interface IReporteCuentasCerradasRepository{
public Task<IEnumerable<DTOCuentasCerradas>> GetCuentasCerradas(string Inicio, string Fin, int TipoOperacion, int NoCliente, int IdCorresponsal);
}
}

@ -0,0 +1,7 @@
using CORRESPONSALBackend.DTO.Reportes.CuentasCerradas;
namespace CORRESPONSALBackend.Contracts.Reportes.CuentasCerradas{
public interface IReporteCuentasCerradasService{
public Task<MemoryStream> GetExcel(IEnumerable<DTOCuentasCerradas> cuentas);
}
}

@ -0,0 +1,8 @@
using CORRESPONSALBackend.DTO.Reportes;
using CORRESPONSALBackend.DTO.Reportes.Facturacion;
namespace CORRESPONSALBackend.Contracts.Reportes.Facturacion{
public interface IReportesFacturacionRepository{
public Task<IEnumerable<DTOReporteGeneralFacturacion>> GetCuentasFacturadas(DTOReporteCorresponsales data);
}
}

@ -0,0 +1,7 @@
using CORRESPONSALBackend.DTO.Corresponsales;
namespace CORRESPONSALBackend.Contracts.Reportes{
public interface ITraficosClientesService{
public Task<MemoryStream> GetExcel(IEnumerable<DTOCorresponsalTrafico> traficos);
}
}

@ -12,5 +12,6 @@ namespace CORRESPONSALBackend.Contracts.Utils
public Task<FileManager> UpdateFileNameById(long id, string newFileName);
public Task<IEnumerable<FileManager>> GetFilesByProcessId(int process);
public Task<FileManager> UpdateFileProcessById(long fileId, int process);
public Task<IEnumerable<FileManager>> GetTraficoFiles(int idTrafico);
}
}

@ -133,10 +133,10 @@ namespace CORRESPONSALBackend.Controllers
{
DTOPINData PINData = await _usuariosRepo.CreatePIN(IdUser);
string htmlContent = $@"<table>
<tr><td>Estimado usuario, mediante este correo se le notifica que esta en proceso de cambiar su contraseña</td></tr>
<tr><td>Estimado usuario, mediante este correo se le notifica que está en proceso de cambiar su contraseña.</td></tr>
<tr><td>Se ha generado un PIN para poder cambiar su contraseña. PIN : <b>{PINData.PIN}</b> </td></tr>
<tr><td>El PIN tiene un tiempo de vida de 10 minutos, a partir de su generacion, despues de ese tiempo caduca</td></tr>
<tr><td>Si usted <b>no</b> es quien ha activando este mecanismo, favor de ponerse en contacto con personal de ZINC</td></tr>
<tr><td>El PIN tiene un tiempo de vida de 10 minutos, a partir de su generación.</td></tr>
<tr><td>Si usted <b>NO</b> es quien ha activando este mecanismo, favor de ponerse en contacto con personal de GEMCO.</td></tr>
</table>";
if (PINData.PIN > 0)
{

@ -0,0 +1,22 @@
using CORRESPONSALBackend.Contracts.Catalogos;
using CORRESPONSALBackend.Models.Catalogos;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace CORRESPONSALBackend.Controllers.Catalogos{
[Authorize]
[Route("api/Catalogos/[controller]")]
public class CatTiposContenedoresController : Controller{
private readonly ICatTiposContenedoresRepository _repo;
public CatTiposContenedoresController(ICatTiposContenedoresRepository repo){
_repo = repo;
}
[HttpGet]
public async Task<IEnumerable<CatTiposContenedores>> Get(){
var tipos = await _repo.Get();
return tipos;
}
}
}

@ -22,16 +22,16 @@ namespace CORRESPONSALBackend.Controllers.Catalogos
[HttpGet]
[Route("getAll")]
public async Task<IEnumerable<Tabulador>> GetAll(int id, int IdCliente)
public async Task<IEnumerable<Tabulador>> GetAll(int id, int IdCliente, int? idCorresponsal)
{
return await _Repo.GetAll(id, IdCliente);
return await _Repo.GetAll(id, IdCliente, idCorresponsal);
}
[HttpGet]
[Route("getByCustomer")]
public async Task<IEnumerable<Tabulador>> GetByCustomer(int IdCliente)
{
return await _Repo.GetAll(0, IdCliente);
return await _Repo.GetAll(0, IdCliente, 0);
}

@ -1,4 +1,5 @@
using CORRESPONSALBackend.Contracts;
using CORRESPONSALBackend.Contracts.Reportes;
using CORRESPONSALBackend.DTO.Cliente;
using CORRESPONSALBackend.DTO.Corresponsales;
using CORRESPONSALBackend.DTO.Reportes;
@ -14,10 +15,12 @@ namespace CORRESPONSALBackend.Controllers
public class ClientesController : Controller
{
private readonly IClientesRepository _clientesRepo;
private readonly ITraficosClientesService _traficosClientesService;
public ClientesController(IClientesRepository clientesRepo)
public ClientesController(IClientesRepository clientesRepo, ITraficosClientesService traficosClientesService)
{
_clientesRepo = clientesRepo;
_traficosClientesService = traficosClientesService;
}
[Route("getAllClientes")]
@ -105,5 +108,21 @@ namespace CORRESPONSALBackend.Controllers
var entrada = await _clientesRepo.GetTraficos(data);
return entrada;
}
[HttpGet("Excel")]
public async Task<IActionResult> GetExcel([FromQuery] DTOFiltrosTraficosClientes data){
try{
var traficos = await _clientesRepo.GetTraficos(data);
var stream = await _traficosClientesService.GetExcel(traficos);
if(stream.Length > 0){
stream.Position = 0;
return File(stream,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", $"Reporte_Operaciones.xlsx");
}else{
throw new Exception("Ocurrio un error al generar el reporte, intentelo de nuevo");
}
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -29,9 +29,17 @@ namespace CORRESPONSALBackend.Controllers.Contabilidad.Corresponsales
[HttpGet]
[Route("Get")]
public async Task<IEnumerable<string>> Get(int IdTrafico, int tipo)
public async Task<IEnumerable<string>> Get(int IdTrafico, int procesoAnterior, int nuevoProceso)
{
var entrada = await _Repo.Get(IdTrafico, tipo);
var entrada = await _Repo.Get(IdTrafico, procesoAnterior, nuevoProceso);
return entrada;
}
[HttpGet]
[Route("Historial")]
public async Task<IEnumerable<string>> Historial(int IdTrafico)
{
var entrada = await _Repo.Historial(IdTrafico);
return entrada;
}
}

@ -0,0 +1,57 @@
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.Models.Corresponsales;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace CORRESPONSALBackend.Controllers.Corresponsalias{
[Authorize]
[Route("api/Corresponsalias/[controller]")]
[ApiController]
public class SolicitudesController : ControllerBase
{
private readonly ICorresponsaliasSolicitudesRepository _Repo;
public SolicitudesController(ICorresponsaliasSolicitudesRepository Repo){
_Repo = Repo;
}
[HttpPost("Reapertura/Append")]
public async Task<IActionResult> AppendSolicitudReapertura([FromBody] ITraficoSolicitud solicitud){
try{
var response = await _Repo.AppendSolicitudReapertura(solicitud);
return Ok(response);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpGet("Reapertura/Get")]
public async Task<IActionResult> GetSolicitudReapertura([FromQuery] int idTrafico){
try{
var solicitud = await _Repo.GetSolicitudReapertura(idTrafico);
return Ok(solicitud);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpPost("EliminarCuenta/Append")]
public async Task<IActionResult> AppendSolicitudEliminarCuenta([FromBody] ITraficoSolicitud solicitud){
try{
var response = await _Repo.AppendSolicitudEliminarReferencia(solicitud);
return Ok(response);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpGet("EliminarCuenta/Get")]
public async Task<IActionResult> GetSolicitudEliminarCuenta([FromQuery] int idTrafico){
try{
var solicitud = await _Repo.GetSolicitudEliminarReferencia(idTrafico);
return Ok(solicitud);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -7,6 +7,10 @@ using Microsoft.AspNetCore.Mvc;
using CORRESPONSALBackend.Services.C1896;
using CORRESPONSALBackend.Repository.Corresponsalias;
using CORRESPONSALBackend.DTO.Reportes;
using CORRESPONSALBackend.Contracts.Corresponsalias.Services;
using CORRESPONSALBackend.Contracts.Catalogos;
using System.Globalization;
using CORRESPONSALBackend.Contracts;
namespace CORRESPONSALBackend.Controllers.Corresponsalias
{
@ -19,14 +23,31 @@ namespace CORRESPONSALBackend.Controllers.Corresponsalias
private readonly ICorresponsaliasTraficosRepository _Repo;
private readonly ICorresponsaliasFacturasRepository _RepoFacturas;
private readonly ICorresponsaliasContenedoresRepository _RepoContenedores;
private readonly ICorresponsaliasTraficosService _traficosService;
private readonly IProveedoresRepository _proveedoresRepository;
private readonly ICorresponsaliasFacturasRepository _facturasRepository;
private readonly ICorresponsaliasContenedoresRepository _contenedoresRepository;
private readonly IClientesRepository _clientesRepository;
private readonly ICatCentrosCostosRepository _centrosCostosRepository;
private readonly ITiposMercanciaRepository _tiposMercanciaRepository;
private readonly IConfiguration _config;
public TraficosController(ICorresponsaliasTraficosRepository Repo, ICorresponsaliasFacturasRepository RepoFacturas, ICorresponsaliasContenedoresRepository RepoContenedores, IConfiguration config)
public TraficosController(ICorresponsaliasTraficosRepository Repo, ICorresponsaliasFacturasRepository RepoFacturas, IClientesRepository clientesRepository,
ICorresponsaliasContenedoresRepository RepoContenedores, IConfiguration config, ICorresponsaliasTraficosService traficosService,
IProveedoresRepository proveedoresRepository, ICorresponsaliasFacturasRepository facturasRepository, ICorresponsaliasContenedoresRepository contenedoresRepository,
ICatCentrosCostosRepository centrosCostosRepository, ITiposMercanciaRepository tiposMercanciaRepository)
{
_config = config;
_Repo = Repo;
_RepoFacturas = RepoFacturas;
_RepoContenedores = RepoContenedores;
_traficosService = traficosService;
_proveedoresRepository = proveedoresRepository;
_facturasRepository = facturasRepository;
_contenedoresRepository = contenedoresRepository;
_clientesRepository = clientesRepository;
_centrosCostosRepository = centrosCostosRepository;
_tiposMercanciaRepository = tiposMercanciaRepository;
}
/// Corresponsales: Traficos
@ -48,9 +69,9 @@ namespace CORRESPONSALBackend.Controllers.Corresponsalias
[HttpGet]
[Route("GetByPedimento")]
public async Task<DTOReporteSemanalNewell> GetByPedimento([FromQuery] int pedimento)
public async Task<DTOReporteSemanalNewell> GetByPedimento([FromQuery] int pedimento, string aduana, int patente)
{
var entrada = await _Repo.GetByPedimento(pedimento);
var entrada = await _Repo.GetByPedimento(pedimento, aduana, patente);
return entrada;
}
@ -123,15 +144,20 @@ namespace CORRESPONSALBackend.Controllers.Corresponsalias
[HttpPost]
[Route("Rectificacion/Historico/Append")]
public async Task<Boolean> RectificacionHistoricoAppend(DTORectificacionHistorico data)
public async Task<IActionResult> RectificacionHistoricoAppend(DTORectificacionHistorico data)
{
var entrada = await _Repo.RectificacionHistoricoAppend(data);
return entrada;
try{
var entrada = await _Repo.RectificacionHistoricoAppend(data);
return Ok(entrada);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpGet]
[Route("Rectificacion/Historico/Get")]
public async Task<CorresponsaliasTraficoRectificacionHistorico> RectificacionHistoricoGet(int IdTrafico)
public async Task<IEnumerable<CorresponsaliasTraficoRectificacionHistorico>> RectificacionHistoricoGet(int IdTrafico)
{
var entrada = await _Repo.RectificacionHistoricoGet(IdTrafico);
return entrada;
@ -139,10 +165,68 @@ namespace CORRESPONSALBackend.Controllers.Corresponsalias
[HttpGet]
[Route("Duplicado")]
public async Task<string> ValidaTraficoDuplicado(int aduana, int patente, int pedimento, int idTrafico)
public async Task<string> ValidaTraficoDuplicado(string aduana, int patente, int pedimento, int idTrafico)
{
var referencia = await _Repo.ValidaTraficoDuplicado(aduana, patente, pedimento, idTrafico);
return referencia;
}
[HttpPost("Append/LayoutAlen")]
public async Task<IActionResult> AppendFacturasContenedoresAlen([FromQuery] int idTrafico, [FromQuery] int fileId){
try{
var trafico = await _Repo.Get(idTrafico);
var proveedores = await _proveedoresRepository.GetAll(0);
proveedores.ToList();
var facturas = await _traficosService.ReadTxtFacturasAlen(fileId);
var facturasOrdenadas = facturas.OrderByDescending(x => DateTime.ParseExact(x[22].Replace(" "," "), "MM/dd/yyyy h:mm:ss tt", CultureInfo.InvariantCulture)).ToArray();
{
trafico.Pedimento = int.Parse(facturasOrdenadas[0][6]);
trafico.FechaPago = facturasOrdenadas[0][7];
trafico.Clave = facturasOrdenadas[0][8];
trafico.TipoCambio = double.Parse(facturasOrdenadas[0][15]);
trafico.CantidadFracciones = int.Parse(facturasOrdenadas[0][21]);
trafico.DescripcionMercancia = facturasOrdenadas[0][14];
trafico.Observaciones = facturasOrdenadas[0][48];
trafico.FechaDesaduanamiento = facturasOrdenadas[0][22];
await _Repo.Append(trafico);
}
foreach(var factura in facturasOrdenadas){
if (!new List<string>() { " ", "-", "_" }.Contains(factura[13]) && !String.IsNullOrEmpty(factura[13])){
//Crear modelo de contenedor y asignar los datos en la factura actual
CorresponsalesContenedores nuevoContenedor = new CorresponsalesContenedores(){
id = 0,
IdTrafico = idTrafico,
Contenedor = factura[32],
Semaforo = (byte?)(factura[45] == "VERDE" ? 2 : 1),
FSemaforo = factura[22]
};
var contenedorGuardado = await _contenedoresRepository.Append(nuevoContenedor);
//Crear modelo de factura y asignar los datos en la factura actual
var proveedorFactura = proveedores.FirstOrDefault(p => p.Nombre == factura[10]);
CorresponsalFacturas nuevaFactura = new CorresponsalFacturas(){
id = 0,
Factura = factura[13],
IdTrafico = idTrafico,
ValorFacturaDls = double.Parse(factura[16]),
Proveedor = proveedorFactura.id,
Pedido = factura[29],
FechaFactura = factura[7],
Activo = true,
Code = 0,
FolioGEMCO = "",
COVE = factura[50],
Entrega = factura[52],
Transporte = factura[51],
UUID = factura[33],
IdContenedor = contenedorGuardado.id
};
await _facturasRepository.Append(nuevaFactura);
}
}
return new OkObjectResult(new {trafico, facturas = await _facturasRepository.GetAll(idTrafico), contenedores = await _contenedoresRepository.GetAll(idTrafico)});
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -2,6 +2,7 @@
using CORRESPONSALBackend.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using System.IO;
namespace CORRESPONSALBackend.Controllers.Dashboard
{
@ -55,5 +56,41 @@ namespace CORRESPONSALBackend.Controllers.Dashboard
var traficos = await _Repo.GetTraficosConCargosDlls();
return traficos;
}
[HttpGet]
[Route("SolicitudesReapertura")]
public async Task<DashboardCorresponsales> SolicitudesReapertura(){
var traficos = await _Repo.SolicitudesReapertura();
return traficos;
}
[HttpGet]
[Route("SolicitudesEliminarCuenta")]
public async Task<DashboardCorresponsales> SolicitudesElminarCuenta(){
var traficos = await _Repo.SolicitudesElminarCuenta();
return traficos;
}
[HttpGet("GetDiskUsage")]
public async Task<IActionResult> GetTotalFreeSpace()
{
var diskName = _config.GetValue<string>("DataDisk");
//List<DashboardCorresponsales> diskData = new List<DashboardCorresponsales>();
foreach (DriveInfo drive in DriveInfo.GetDrives())
{
if (drive.IsReady && drive.Name == diskName)
{
long driveFreeSpaceInGB = drive.TotalFreeSpace / 1024 / 1024 / 1024;
long driveTotalSpaceInGB = drive.TotalSize / 1024 / 1024 / 1024;
long driveTotalUsedSpaceInGB = driveTotalSpaceInGB - driveFreeSpaceInGB;
long usedStoragePercentage = driveTotalUsedSpaceInGB * 100 / driveTotalSpaceInGB;
return new OkObjectResult(new DashboardCorresponsales(){
Total = Convert.ToInt32(usedStoragePercentage),
Descripcion = $"{driveTotalUsedSpaceInGB} GB usados de {driveTotalSpaceInGB} GB"
});
}
}
return BadRequest("No se pudo obtener la información de la unidad");
}
}
}

@ -10,6 +10,9 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.HttpResults;
using CORRESPONSALBackend.Contracts.Auth;
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.Contracts.Corresponsalias.Services;
using Newtonsoft.Json;
using System.Text;
namespace CORRESPONSALBackend.Controllers
{
@ -24,23 +27,20 @@ namespace CORRESPONSALBackend.Controllers
private readonly IFilePaths4ProcessRepository _RepoRelativePath;
private readonly IConfiguration _config;
private readonly IAuthService _authService;
private readonly ICorresponsaliasTraficosService _traficoService;
private readonly ICorresponsaliasTraficosRepository _traficosRepository;
private readonly string RootPathCorresponsales;
public FileManagerController(IFileManagerRepository Repo,
IFilePaths4ProcessRepository RepoRelativePath,
IConfiguration config,
IUsuariosRepository RepoUsuarios,
ICasaCuervoRepository RepoCasaCuervo,
IAuthService authService,
ICorresponsaliasTraficosRepository traficosRepository)
public FileManagerController(IFileManagerRepository Repo, IFilePaths4ProcessRepository RepoRelativePath, IConfiguration config, IUsuariosRepository RepoUsuarios,
ICasaCuervoRepository RepoCasaCuervo, IAuthService authService, ICorresponsaliasTraficosRepository traficosRepository, ICorresponsaliasTraficosService traficoService)
{
_config = config;
_Repo = Repo;
_RepoUsuarios = RepoUsuarios;
_RepoCasaCuervo = RepoCasaCuervo;
_RepoRelativePath = RepoRelativePath;
_traficoService = traficoService;
RootPathCorresponsales = _config.GetValue<string>("AllFiles");
_authService = authService;
_traficosRepository = traficosRepository;
@ -65,6 +65,8 @@ namespace CORRESPONSALBackend.Controllers
}
[Route("AppendFileByProcess")]
[RequestSizeLimit(209715200)]
[RequestFormLimits(MultipartBodyLengthLimit = 209715200)]
[HttpPost]
public async Task<dynamic> AppendFileByProcess(IFormFile file, int IdUsuario, int Proceso, string Tags, int crud)
{
@ -110,7 +112,7 @@ namespace CORRESPONSALBackend.Controllers
}
catch (Exception ex)
{
return Ok(ex.Message);
return BadRequest(ex.Message);
}
}
@ -324,6 +326,9 @@ namespace CORRESPONSALBackend.Controllers
var zipFilePath = tempFilesPath + trafico.FolioGemco + ".zip";
if(!System.IO.File.Exists(zipFilePath)){//Se valida si no existe el archivo
var procesos = new int[]{2,37,38,39,41};//Se crea un array con los procesos de los cuales se van a necesitar los archivos
if(trafico.PedimentoObligatorio == 0){
procesos = new int[]{37,38,39,41};
}
string folderName = string.Concat(trafico.FolioGemco, "\\"); // "23-000xxxC" -> "23-000xxxC\"
if(!System.IO.Directory.Exists(tempFilesPath + folderName))
System.IO.Directory.CreateDirectory(tempFilesPath + folderName);// Path: C:data\Corresponsales\Zips\Facturacion\Entregas\23-000xxxC\
@ -374,5 +379,89 @@ namespace CORRESPONSALBackend.Controllers
}
return Ok();
}
[HttpGet("CreateFacturacionTxt")]
public async Task<IActionResult> CreateFacturacionTxt(string folioTrafico, int idTrafico, int idUsuario){
try {
var fileData = await _traficoService.GetTxtFacturacionData(idTrafico);
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(31);//Se obtiene la ruta de los archivos sin procesar para agregar el archivo del token.
string FileName = folioTrafico + "_" + DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss")+ ".txt";
string txtFacturacionPath = RootPathCorresponsales + RelativePath.Path + FileName;
if(System.IO.File.Exists(txtFacturacionPath)){
System.IO.File.Delete(txtFacturacionPath);
}
//Se crea el txt de faturacion. Por el momento se encuentra vacío
var fileStream = System.IO.File.Create(txtFacturacionPath);
fileStream.Close();
//Se "abre" el archivo y se escribe el contenido obtenido del servicio de los traficos
var writer = new StreamWriter(txtFacturacionPath);
await writer.WriteLineAsync(fileData);
//Se cierra el archivo
writer.Close();
//Comienza el proceso para guardar los datos del archivo en la base de datos.
FileManager dto = new FileManager(){
id = 0,
IdUsuario = idUsuario,
NombreArchivo = FileName,
Proceso = 31,
FechaRegistro = "",
Tags = idTrafico.ToString(),
Activo = 1,
Size = 1,
};
return Ok(await _Repo.FileManager(dto));
}catch(Exception ex){
var jsonContent = JsonConvert.SerializeObject(new {
To = "fmorales@gemcousa.com",
Subject = "Error al crear el txt de Facturación",
Text = "",
Html = @$"
<h3>El se detectó el siguiente error durante la creación del archivo texto del trafico {folioTrafico}</h3>
<br/>
<p>{ex.Message}</p>
"
});
HttpContent httpContent = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var client = new HttpClient())
using (var formData = new MultipartFormDataContent())
{
var response = await client.PostAsync("https://pyapi.gemcousa.mx/SendEmail", httpContent);
}
return BadRequest(ex.Message);
}
}
[HttpGet("FileListByReferencia")]
public async Task<IActionResult> GeFileListByReferencia([FromQuery] string referencia){
try{
var trafico = await _traficosRepository.GetByReferencia(referencia);
var fileList = await _Repo.GetTraficoFiles(trafico.id);
return Ok(fileList);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpGet("GetAEO")]
public async Task<IActionResult> GetArchivoElectronicoOficial([FromQuery] string serie, string noMovimiento, string fileMime, string trafico){
try{
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(47);
string folderPath = RootPathCorresponsales + RelativePath.Path + trafico + "\\";
string fileName = $"RGMS960730IL9_{serie}-00000{noMovimiento}.{fileMime}";
string fullPath = folderPath + fileName;
if (!System.IO.File.Exists(fullPath))
{
throw new Exception("No se encontró el archivo solicitado.");
}
var mime = "application/" + fileMime.ToLower();
byte[] pdfBytes = System.IO.File.ReadAllBytes(fullPath);
MemoryStream ms = new MemoryStream(pdfBytes);
return new FileStreamResult(ms, mime);//D:\data\ArchivoElectronicoSIR\www.gemcousa.com\SIR-GEMCO\DOCS-SIR\ALEN DEL NORTE SA DE CV\2024\24-00665E
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -0,0 +1,252 @@
using System.Globalization;
using CORRESPONSALBackend.Contracts.Reportes.Alen;
using CORRESPONSALBackend.Contracts.Utils;
using CORRESPONSALBackend.DTO.Reportes.Alen;
using CORRESPONSALBackend.Models.Clientes.Alen;
using CORRESPONSALBackend.Models.Utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using OfficeOpenXml.Table;
namespace CORRESPONSALBackend.Controllers.Reportes.Alen{
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class ReporteEstadosCuentaAlenController : ControllerBase{
private readonly IFileManagerRepository _Repo;
private readonly IFilePaths4ProcessRepository _RepoRelativePath;
private readonly IConfiguration _config;
private readonly string RootPathCorresponsales;
private readonly IEstadosCuentaAlenRepository _EstadosCuentaAlenRepo;
public ReporteEstadosCuentaAlenController(IFilePaths4ProcessRepository RepoRelativePath, IConfiguration config, IFileManagerRepository Repo, IEstadosCuentaAlenRepository EstadosCuentaAlenRepo){
_Repo = Repo;
_RepoRelativePath = RepoRelativePath;
_config = config;
RootPathCorresponsales = _config.GetValue<string>("AllFiles");
_EstadosCuentaAlenRepo = EstadosCuentaAlenRepo;
}
[HttpPost("Append")]
public async Task<IActionResult> Append(IFormFile file){
try{
await _EstadosCuentaAlenRepo.ClearData();
//Obtener la ruta del archivo
//Se obtiene la ruta del archivo
//FileManager recFound = await _Repo.getFileById(45);
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(45);
if(!System.IO.Directory.Exists(RootPathCorresponsales + RelativePath.Path)){
System.IO.Directory.CreateDirectory(RootPathCorresponsales + RelativePath.Path);
}
string filePath = RootPathCorresponsales + RelativePath.Path + file.FileName;
if(System.IO.File.Exists(filePath)){
System.IO.File.Delete(filePath);
}
//Si es un archivo nuevo se guarda
using(var stream = System.IO.File.Create(filePath)){
await file.CopyToAsync(stream);
}
//Leer el archivo con epplus
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using(ExcelPackage package = new ExcelPackage(filePath)){
var worksheet = package.Workbook.Worksheets.FirstOrDefault();
int rowCount = 2;
worksheet.Column(18).Style.Numberformat.Format = "yyyy-mm-dd";
worksheet.Column(19).Style.Numberformat.Format = "yyyy-mm-dd";
worksheet.Column(20).Style.Numberformat.Format = "yyyy-mm-dd";
while(string.IsNullOrWhiteSpace(worksheet?.Cells[rowCount, 4].Value?.ToString()) == false){
EstadosCuenta estadoCuenta = new EstadosCuenta(){
id=0,
TipoMovimiento = worksheet.Cells[rowCount, 1].Value != null ? worksheet.Cells[rowCount, 1].Value?.ToString() : "",
NoSerie = worksheet.Cells[rowCount, 2].Value != null ? worksheet.Cells[rowCount, 2].Value?.ToString() : "",
NoMovimiento = worksheet.Cells[rowCount, 3].Value != null ? worksheet.Cells[rowCount, 3].Value?.ToString() : "",
Trafico = worksheet.Cells[rowCount, 4].Value != null ? worksheet.Cells[rowCount, 4].Value?.ToString() : "",
Impexp = worksheet.Cells[rowCount, 5].Value != null ? worksheet.Cells[rowCount, 5].Value?.ToString() : "",
Aduana = worksheet.Cells[rowCount, 6].Value != null ? worksheet.Cells[rowCount, 6].Value?.ToString() : "",
Patente = worksheet.Cells[rowCount, 7].Value != null ? worksheet.Cells[rowCount, 7].Value?.ToString() : "",
Pedimento = worksheet.Cells[rowCount, 8].Value != null ? worksheet.Cells[rowCount, 8].Value?.ToString() : "",
Clave = worksheet.Cells[rowCount, 9].Value != null ? worksheet.Cells[rowCount, 9].Value?.ToString() : "",
NoCliente = worksheet.Cells[rowCount, 10].Value != null ? worksheet.Cells[rowCount, 10].Value?.ToString() : "",
NoCentro = worksheet.Cells[rowCount, 11].Value != null ? worksheet.Cells[rowCount, 11].Value?.ToString() : "",
SubCentro = worksheet.Cells[rowCount, 12].Value != null ? worksheet.Cells[rowCount, 12].Value?.ToString() : "",
Nombre = worksheet.Cells[rowCount, 13].Value != null ? worksheet.Cells[rowCount, 13].Value?.ToString() : "",
SubCtaNombre = worksheet.Cells[rowCount, 14].Value != null ? worksheet.Cells[rowCount, 14].Value?.ToString() : "",
TipoRangos = worksheet.Cells[rowCount, 15].Value != null ? worksheet.Cells[rowCount, 15].Value?.ToString() : "",
Cargos = worksheet.Cells[rowCount, 16].Value != null ? worksheet.Cells[rowCount, 16].Value?.ToString() : "",
Abonos = worksheet.Cells[rowCount, 17].Value != null ? worksheet.Cells[rowCount, 17].Value?.ToString() : "",
Fecha = worksheet.Cells[rowCount, 18].Value != null ? StringToDateTime(worksheet.Cells[rowCount, 18].Value?.ToString().Substring(0,10)) : "",
FechaPedimento = worksheet.Cells[rowCount, 19].Value != null ? StringToDateTime(worksheet.Cells[rowCount, 19].Value?.ToString().Substring(0,10)) : "",
FechaRev = worksheet.Cells[rowCount, 20].Value != null ? StringToDateTime(worksheet.Cells[rowCount, 20].Value?.ToString().Substring(0,10)) : "",
DiasPedimCta = worksheet.Cells[rowCount, 21].Value != null ? worksheet.Cells[rowCount, 21].Value?.ToString() : "",
DiasCtaRev = worksheet.Cells[rowCount, 22].Value != null ? worksheet.Cells[rowCount, 22].Value?.ToString() : "",
DiasRev = worksheet.Cells[rowCount, 23].Value != null ? worksheet.Cells[rowCount, 23].Value?.ToString() : "",
IvaAl = worksheet.Cells[rowCount, 24].Value != null ? worksheet.Cells[rowCount, 24].Value?.ToString() : "",
TotalFacturado = worksheet.Cells[rowCount, 25].Value != null ? worksheet.Cells[rowCount, 25].Value?.ToString() : "",
SaldoFinal = worksheet.Cells[rowCount, 26].Value != null ? worksheet.Cells[rowCount, 26].Value?.ToString() : "",
Anticipo = worksheet.Cells[rowCount, 27].Value != null ? worksheet.Cells[rowCount, 27].Value?.ToString() : "",
UUID = worksheet.Cells[rowCount, 28].Value != null ? worksheet.Cells[rowCount, 28].Value?.ToString() : "",
Descripcion = worksheet.Cells[rowCount, 29].Value != null ? worksheet.Cells[rowCount, 29].Value?.ToString() : "",
Remitente = worksheet.Cells[rowCount, 30].Value != null ? worksheet.Cells[rowCount, 30].Value?.ToString() : "",
Pedido = worksheet.Cells[rowCount, 31].Value != null ? worksheet.Cells[rowCount, 31].Value?.ToString() : "",
TipoMercancia = worksheet.Cells[rowCount, 32].Value != null ? worksheet.Cells[rowCount, 32].Value?.ToString() : "",
CampoAdicional5 = worksheet.Cells[rowCount, 33].Value != null ? worksheet.Cells[rowCount, 33].Value?.ToString() : "",
};
var resp = await _EstadosCuentaAlenRepo.Append(estadoCuenta);
rowCount++;
}
}
return Ok();
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
private string StringToDateTime(string s){
return DateTime.ParseExact(s, "dd/MM/yyyy",CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
}
[HttpGet("GetAll")]
public async Task<IActionResult> GetAll([FromQuery] DTOEstadosCuentaAlenFilters filters){
try{
var estados = await _EstadosCuentaAlenRepo.GetAll(filters);
return Ok(estados);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpPost("Export")]
public async Task<IActionResult> Export([FromBody] DTOEstadosCuentaAlen[] estados){
try{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (ExcelPackage excelPackage = new ExcelPackage()){
var worksheet = excelPackage.Workbook.Worksheets.Add("sheet1");
int rowCount = 2;
worksheet.Cells[$"A1"].Value = "Serie";
worksheet.Cells[$"B1"].Value = "Movimiento";
worksheet.Cells[$"C1"].Value = "Fecha";
worksheet.Cells[$"D1"].Value = "Trafico";
worksheet.Cells[$"E1"].Value = "Aduana";
worksheet.Cells[$"F1"].Value = "Patente";
worksheet.Cells[$"G1"].Value = "Pedimento";
worksheet.Cells[$"H1"].Value = "Cve. Pedim.";
worksheet.Cells[$"I1"].Value = "Impo/Expo";
worksheet.Cells[$"J1"].Value = "No. Cte.";
worksheet.Cells[$"K1"].Value = "Nombre Cliente";
worksheet.Cells[$"L1"].Value = "Cargos";
worksheet.Cells[$"M1"].Value = "Abonos";
worksheet.Cells[$"N1"].Value = "SaldoFinal";
worksheet.Cells[$"O1"].Value = "% IVA";
worksheet.Cells[$"P1"].Value = "Descripcion";
worksheet.Cells[$"Q1"].Value = "Remitente";
worksheet.Cells[$"R1"].Value = "Pedido";
worksheet.Cells[$"S1"].Value = "Orden Compra";
worksheet.Cells[$"T1"].Value = "Tipo Mcia";
foreach (var estado in estados){
worksheet.Cells[$"A{rowCount}"].Value = estado.Serie;
worksheet.Cells[$"B{rowCount}"].Value = estado.NoMovimiento;
worksheet.Cells[$"C{rowCount}"].Value = estado.Fecha;
worksheet.Cells[$"D{rowCount}"].Value = estado.Trafico;
worksheet.Cells[$"E{rowCount}"].Value = estado.Aduana;
worksheet.Cells[$"F{rowCount}"].Value = estado.Patente;
worksheet.Cells[$"G{rowCount}"].Value = estado.Pedimento;
worksheet.Cells[$"H{rowCount}"].Value = estado.Clave;
worksheet.Cells[$"I{rowCount}"].Value = estado.Impexp;
worksheet.Cells[$"J{rowCount}"].Value = estado.NoCliente;
worksheet.Cells[$"K{rowCount}"].Value = estado.Nombre;
worksheet.Cells[$"L{rowCount}"].Value = estado.Cargos;
worksheet.Cells[$"M{rowCount}"].Value = estado.Abonos;
worksheet.Cells[$"N{rowCount}"].Value = estado.SaldoFinal;
worksheet.Cells[$"O{rowCount}"].Value = estado.IvaAl;
worksheet.Cells[$"P{rowCount}"].Value = estado.Descripcion;
worksheet.Cells[$"Q{rowCount}"].Value = estado.Remitente;
worksheet.Cells[$"R{rowCount}"].Value = estado.Pedido;
worksheet.Cells[$"S{rowCount}"].Value = estado.OrdenCompra;
worksheet.Cells[$"T{rowCount}"].Value = estado.TipoMercancia;
rowCount++;
}
ExcelRange range = worksheet.Cells[1, 1,estados.Count() + 1, 20];
ExcelTable tab = worksheet.Tables.Add(range, "Table1");
tab.TableStyle = TableStyles.Light1;
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
worksheet.Cells[worksheet.Dimension.Address].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
excelPackage.Workbook.Calculate();
var stream = new MemoryStream();
excelPackage.SaveAs(stream);
if(stream.Length > 0){
stream.Position = 0;
return File(stream,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", $"Reporte_Operaciones.xlsx");
}else{
throw new Exception("Ocurrio un error al generar el reporte, intentelo de nuevo");
}
}
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpPost("AppendProgramacionesPago")]
public async Task<IActionResult> AppendProgramacionesPago(IFormFile file){
try{
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(46);
if(!System.IO.Directory.Exists(RootPathCorresponsales + RelativePath.Path)){
System.IO.Directory.CreateDirectory(RootPathCorresponsales + RelativePath.Path);
}
string filePath = RootPathCorresponsales + RelativePath.Path + file.FileName;
if(System.IO.File.Exists(filePath)){
System.IO.File.Delete(filePath);
}
//Si es un archivo nuevo se guarda
using(var stream = System.IO.File.Create(filePath)){
await file.CopyToAsync(stream);
}
//Leer el archivo con epplus
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using(ExcelPackage package = new ExcelPackage(filePath)){
var worksheet = package.Workbook.Worksheets.FirstOrDefault();
int rowCount = 3;
while(string.IsNullOrWhiteSpace(worksheet?.Cells[rowCount, 2].Value?.ToString()) == false){
//Quitar el prefijo de la serie del numero de cuenta.
string folio = worksheet.Cells[rowCount, 2].Value != null ? worksheet.Cells[rowCount, 2].Value?.ToString().Substring(1,5) : "";
//Buscar el registro de la cuenta
var cuenta = await _EstadosCuentaAlenRepo.GetByFolio(folio);
if(cuenta.id != 0){
//Hacer la llamada a al base de datos para actualizar el registro
cuenta = await _EstadosCuentaAlenRepo.MarkAsProgramado(cuenta.NoMovimiento, cuenta.NoSerie);
}
rowCount++;
}
}
return Ok();
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpPost("AppendOrdenCompra")]
public async Task<IActionResult> AppendOrdenCompra([FromBody] DTOEstadosCuentaAlen data){
try{
var trafico = await _EstadosCuentaAlenRepo.AppendOrdenCompra(data);
return Ok(trafico);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpPost("AppendObservaciones")]
public async Task<IActionResult> AppendObservaciones([FromBody] DTOEstadosCuentaAlen data){
try{
var trafico = await _EstadosCuentaAlenRepo.AppendObservaciones(data);
return Ok(trafico);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -0,0 +1,54 @@
using CORRESPONSALBackend.Contracts.Reportes.Facturacion;
using CORRESPONSALBackend.DTO.Reportes;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml;
using OfficeOpenXml.Table;
namespace CORRESPONSALBackend.Controllers.Reportes.Facturacion{
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class ReportesFacturacionController : ControllerBase{
private readonly IReportesFacturacionRepository _cuentasRepo;
public ReportesFacturacionController(IReportesFacturacionRepository cuentasRepo){
_cuentasRepo = cuentasRepo;
}
[HttpGet("CuentasFacturadas")]
public async Task<IActionResult> GetCuentasFacturadas([FromQuery] DTOReporteCorresponsales data){
try{
var cuentas = await _cuentasRepo.GetCuentasFacturadas(data);
return Ok(cuentas);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpGet("FacturacionExcel")]
public async Task<IActionResult> GetFacturacionExcel([FromQuery] DTOReporteCorresponsales data ){
try{
var traficos = await _cuentasRepo.GetCuentasFacturadas(data);
var today = DateTime.Now;
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (ExcelPackage excelPackage = new ExcelPackage()){
var worksheet = excelPackage.Workbook.Worksheets.Add("sheet1");
worksheet.Cells["A1"].LoadFromCollection(traficos, true);
//Se crea la tabla en el rango de celdas donde se mostrara la inforamcion.
ExcelRange range = worksheet.Cells[1, 1,traficos.Count() + 1, 27];
ExcelTable tab = worksheet.Tables.Add(range, "Table1");
tab.TableStyle = TableStyles.Light1;
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
excelPackage.Workbook.Calculate();
var stream = new MemoryStream();
excelPackage.SaveAs(stream);
stream.Position = 0;
return File(stream, "application/octet-stream", $"ReporteFacturacion_{today.Day}-{today.Month}-{today.Year}.xlsx");
}
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -0,0 +1,30 @@
using CORRESPONSALBackend.Contracts.Reportes.CuentasCerradas;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace CORRESPONSALBackend.Controllers.Reportes{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class ReporteCuentasCerradasController : ControllerBase{
private readonly IReporteCuentasCerradasService _service;
private readonly IReporteCuentasCerradasRepository _repository;
public ReporteCuentasCerradasController(IReporteCuentasCerradasService service, IReporteCuentasCerradasRepository repository){
_service = service;
_repository = repository;
}
[HttpGet("GetExcel")]
public async Task<IActionResult> ReporteCuentasCerradas([FromQuery] string Inicio, string Fin, int TipoOperacion, int NoCliente, int IdCorresponsal){
try{
var cuentas = await _repository.GetCuentasCerradas(Inicio, Fin, TipoOperacion, NoCliente, IdCorresponsal);
var stream = await _service.GetExcel(cuentas);
stream.Position = 0;
return File(stream, "application/octet-stream", $"Reporte.xlsx");
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -0,0 +1,58 @@
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.Contracts.Reportes.Alen;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace CORRESPONSALBackend.Controllers.Reportes{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class ReportesAlenController : ControllerBase{
private readonly ICorresponsaliasTraficosRepository _traficosRepository;
private readonly ICorresponsaliasFacturasRepository _facturasRepository;
private readonly ICorresponsaliasContenedoresRepository _contenedoresRepository;
private readonly IReportesAlenService _reportesAlenService;
public ReportesAlenController(ICorresponsaliasTraficosRepository traficosRepository, ICorresponsaliasFacturasRepository facturasRepository,
IReportesAlenService reportesAlenService, ICorresponsaliasContenedoresRepository contenedoresRepository){
_traficosRepository = traficosRepository;
_facturasRepository = facturasRepository;
_contenedoresRepository = contenedoresRepository;
_reportesAlenService = reportesAlenService;
}
[HttpGet("RelacionFacturas")]
public async Task<IActionResult> GetRelacionFacturas([FromQuery] string referencia){
try{
var trafico = await _traficosRepository.GetByReferencia(referencia);
var facturas = await _facturasRepository.GetAll(trafico.id);
var contenedores = await _contenedoresRepository.GetAll(trafico.id);
var stream = await _reportesAlenService.GetRelacionFacturas(trafico, facturas, contenedores);
if(stream.Length > 0){
stream.Position = 0;
return File(stream,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", $"RelacionFacturas.xlsx");
}else{
throw new Exception("Ocurrio un error al generar el reporte, intentelo de nuevo");
}
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
[HttpGet("FacturasConsolidados")]
public async Task<IActionResult> FacturasConsolidados([FromQuery] string referencia){
try{
var trafico = await _traficosRepository.GetByReferencia(referencia);
var stream = await _reportesAlenService.GetReporteFacturasTraficoConsolidado(referencia);
if(stream.Length > 0){
stream.Position = 0;
return File(stream,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", $"FacturasConsolidado_{trafico.FolioGemco}.xlsx");
}else{
throw new Exception("Ocurrio un error al generar el reporte, intentelo de nuevo");
}
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -0,0 +1,93 @@
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.Contracts.Utils;
using CORRESPONSALBackend.DTO.ArchivoElectronico;
using CORRESPONSALBackend.Models.Utils;
using CORRESPONSALBackend.Repository.Utils;
using GEMCO.Backend.Models.Reportes;
using Microsoft.AspNetCore.Mvc;
namespace CORRESPONSALBackend.Controllers.Utils{
[Route("api/[controller]")]
[ApiController]
public class ArchivoElectronicoController : ControllerBase {
private readonly IArchivoElectronicoRepository _AERepo;
private readonly IConfiguration _config;
private readonly IFilePaths4ProcessRepository _RepoRelativePath;
private readonly string RootPathCorresponsales;
private readonly ICorresponsaliasTraficosRepository _traficosRepository;
private readonly IFileManagerRepository _fileManagerRepo;
public ArchivoElectronicoController(IArchivoElectronicoRepository AERepo, IConfiguration config,
ICorresponsaliasTraficosRepository traficosRepository, IFilePaths4ProcessRepository RepoRelativePath,
IFileManagerRepository fileManagerRepo){
_AERepo = AERepo;
_traficosRepository = traficosRepository;
_config = config;
_RepoRelativePath = RepoRelativePath;
_fileManagerRepo = fileManagerRepo;
RootPathCorresponsales = _config.GetValue<string>("AllFiles");
}
[HttpGet]
[Route("RptArchivoElectronicoOficial")]
public async Task<List<RptPedimentosPagadosAEO>> GetReporteArchivElectronicoOficial([FromQuery] DTOAEPeriodo DTOData)
{
List<RptPedimentosPagadosAEO> data = await _AERepo.getRptPedimentoPagadosAEO(DTOData);
return data;
}
[HttpPost]
[Route("DownloadZippedArchivosOficiales")]
public async Task<IActionResult> DownloadZippedArchivosOficiales([FromBody] DTOAEPeriodoSeleccion data){
try{
//Se obtiene la ruta donde se alojará temporalmente el zip
FilePaths4Process tempFilesRelativePath = await _RepoRelativePath.getPaths4ProcessById(44); // Path: Corresponsales\Zips\Facturacion\Entregas\
var tempFilesPath = RootPathCorresponsales + tempFilesRelativePath.Path;// Path: C:data\Corresponsales\Zips\Clientes\ArchivosElectronicos
string tempFolderName = "ReporteArchivosElectronicos";//Nombre del folder Temporal
string tempFolderPath= tempFilesPath + $"{tempFolderName}\\";//ruta del folder temporal Path: C:data\Corresponsales\Zips\Clientes\ArchivosElectronicos\ReporteArchivosElectronicos
string zipFileName = $"{tempFolderName}.zip";//Nombre del zip final
var zipFilePath = tempFilesPath + zipFileName;//Ruta del zip final Path: C:data\Corresponsales\Zips\Clientes\ArchivosElectronicos\ReporteArchivosElectronicos.zip
if(System.IO.File.Exists(zipFilePath)){//Si ya existe un zip de una descarga anterior lo borra
System.IO.File.Delete(zipFilePath);
}
if(System.IO.Directory.Exists(tempFolderPath)){//Si ya existe la carpeta temporal de una descarga anterior la borra
System.IO.Directory.Delete(tempFolderPath, true);
}
System.IO.Directory.CreateDirectory(tempFolderPath);//Se crea el folder temporal donde se pondran los archivos oficiales
foreach(var referencia in data.Referencias){
var trafico = await _traficosRepository.GetByReferencia(referencia);
string folderAE = tempFolderPath + $"{referencia}\\";//Se obtiene el nombre de la subcarpeta del AE de cada referencia
if(System.IO.Directory.Exists(folderAE)){//Si existe la carpeta se borra
System.IO.Directory.Delete(folderAE);
}
System.IO.Directory.CreateDirectory(folderAE);//Se crea la carpeta
//Obtener la lista de archivos de la referencia actual.
var filesLog = await _fileManagerRepo.GetTraficoFiles(trafico.id);
var filteredFilesLog = filesLog.Where(x => new List<int>(){2,10,11,12,13,14,15,19,17,18,37,38,39,41}.Contains(x.Proceso));
foreach(var fileLog in filteredFilesLog){
FilePaths4Process fileRelativePath = await _RepoRelativePath.getPaths4ProcessById(fileLog.Proceso);//Se obtiene la ruta relativa donde debe estar alojado el archivo
var filePath = RootPathCorresponsales + fileRelativePath.Path + fileLog!.NombreArchivo;//Ahora se obtiene la ruta completa del archivo.
if(System.IO.File.Exists(filePath)){
var bytes = await System.IO.File.ReadAllBytesAsync(filePath);
var originalFileStream = new MemoryStream(bytes);
using(var tempFileStream = System.IO.File.Create(folderAE + fileLog.NombreArchivo)){
await originalFileStream.CopyToAsync(tempFileStream);
}
}
}
}
System.IO.Compression.ZipFile.CreateFromDirectory(tempFolderPath, zipFilePath);//Se comprime la carpeta con los archivos electronicos de las referencias
Directory.Delete(tempFolderPath, true);//Se borra el folder temporal
var zipBytes = await System.IO.File.ReadAllBytesAsync(zipFilePath);
var zipStream = new MemoryStream(zipBytes);
return File(zipStream, "application/zip", zipFileName);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}
}
}

@ -39,9 +39,13 @@ namespace CORRESPONSALBackend.Controllers.Utils
[Route("GetFileContentById")]
public async Task<IActionResult> GetFileContentById(long id, int Proceso)
{
try{
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(Proceso);
SvcMFileManager FM = new SvcMFileManager(_config, _Repo, RootPath + RelativePath.Path);
return await FM.getFileContentById(id);
}catch(Exception ex){
return BadRequest(ex.Message);
}
}

@ -6,6 +6,7 @@ using CORRESPONSALBackend.DTO.Corresponsales;
namespace CORRESPONSALBackend.Controllers
{
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class ReportesController : ControllerBase

@ -22,7 +22,7 @@ namespace CORRESPONSALBackend.DTO.Corresponsales
public int? Estatus { get; set; } = 0;
public string sEstatus { get; set; } = null!;
public string? Trafico { get; set; } = null!;
public int? Aduana { get; set; } = 0;
public string? Aduana { get; set; } = "0";
public int? Patente { get; set; } = 0;
public int? Pedimento { get; set; } = 0;
public string? Clave { get; set; } = null!;
@ -48,5 +48,6 @@ namespace CORRESPONSALBackend.DTO.Corresponsales
public int Rechazado { get; set; } = 0;
public int NoRecti { get; set; } = 0;
public byte? Activo { get; set; } = 0;
public int TieneSolicitud {get;set;} = 0;
}
}

@ -5,5 +5,16 @@ namespace CORRESPONSALBackend.DTO.Corresponsales
{
public int IdTrafico { get; set; } = 0;
public int IdUsuario { get; set; } = 0;
public int IdPedimento { get; set; } = 0;
public string Aduana { get; set; } = "0";
public int Patente { get; set; } = 0;
public int Pedimento { get; set; } = 0;
public string Clave { get; set; } = "";
public string FechaPago { get; set; } = "";
public string AduanaH { get; set; } = "0";
public int PatenteH { get; set; } = 0;
public int PedimentoH { get; set; } = 0;
public string ClaveH { get; set; } = "";
public string FechaPagoH { get; set; } = "";
}
}

@ -4,7 +4,7 @@ namespace CORRESPONSALBackend.DTO.Corresponsales
{
public int Id { get; set; } = 0;
public int IdUsuario { get; set; } = 0;
public byte Estatus { get; set; } = 0;
public byte PedimentoObligatorio { get; set; } = 0;
public string Comentarios { get; set; } = null!;
}
}

@ -0,0 +1,11 @@
namespace CORRESPONSALBackend.DTO.Corresponsales{
public class DTOTraficoSolicitud{
public int Id { get; set; }
public int IdTrafico { get; set; }
public int IdUsuarioSolicita { get; set; }
public string UsuarioSolicita { get; set; }
public string FechaSolicita { get; set; }
public string MotivoSolicita { get; set; }
public int Estado { get; set; }
}
}

@ -0,0 +1,50 @@
namespace CORRESPONSALBackend.DTO.Reportes.Alen{
public class DTOEstadosCuentaAlen{
public int id { get; set; }
public string? TipoMovimiento { get; set; } = "";
public string? NoSerie { get; set; } = "";
public string? NoMovimiento {get;set;} = "";
public string? Trafico {get;set;} = "";
public string? Impexp {get;set;} = "";
public string? Aduana {get;set;} = "";
public string? Patente {get;set;} = "";
public string? Pedimento {get;set;} = "";
public string? Clave {get;set;} = "";
public string? NoCliente {get;set;} = "";
public string? NoCentro {get;set;} = "";
public string? SubCentro {get;set;} = "";
public string? Nombre {get;set;} = "";
public string? SubCtaNombre {get;set;} = "";
public string? TipoRangos {get;set;} = "";
public string? Cargos {get;set;} = "";
public string? Abonos {get;set;} = "";
public string? Fecha {get;set;} = "";
public string? FechaPedimento {get;set;} = "";
public string? FechaRev {get;set;} = "";
public string? DiasPedimCta {get;set;} = "";
public string? DiasCtaRev {get;set;} = "";
public string? DiasRev {get;set;} = "";
public string? IvaAl {get;set;} = "";
public string? TotalFacturado {get;set;} = "";
public string? SaldoFinal {get;set;} = "";
public string? Anticipo {get;set;} = "";
public string? UUID {get;set;} = "";
public string? Descripcion {get;set;} = "";
public string? Remitente {get;set;} = "";
public string? Pedido {get;set;} = "";
public string? TipoMercancia {get;set;} = "";
public string? CampoAdicional5 {get;set;} = "";
public int? IdPdf {get;set;}=0;
public string? Pdf {get;set;}="";
public int? IdXml {get;set;}=0;
public string? Xml {get;set;}="";
public int? IdNotasCargo {get;set;}=0;
public string? NotasCargo {get;set;}="";
public bool? Programado {get;set;} = false;
public string? Serie {get;set;} = "";
public int? IdOrdenCompra {get;set;} = 0;
public string? OrdenCompra {get;set;} = "";
public int? IdObservaciones {get;set;} = 0;
public string? Observaciones {get;set;} = "";
}
}

@ -0,0 +1,13 @@
namespace CORRESPONSALBackend.DTO.Reportes.Alen{
public class DTOEstadosCuentaAlenFilters{
public string? Trafico {get;set;}="";
public string? Impexp {get;set;}="";
public string? Aduana {get;set;}="";
public string? Patente {get;set;}="";
public string? Pedimento {get;set;}="";
public string? Inicio {get;set;}="";
public string? Fin {get;set;}="";
public string? Remitente {get;set;}="";
public string? Programado {get;set;} = "";
}
}

@ -0,0 +1,20 @@
public class DTOReporteFacturasTraficosConsolidados{
public string trafico { get; set; }
public string TipoOperacion { get; set; }
public string Cliente { get; set; }
public string Proveedor { get; set; }
public string Corresponsal { get; set; }
public string Aduana { get; set; }
public int Patente { get; set; }
public string Pedimento { get; set; }
public int PedimentoMaster { get; set; }
public string Fecha { get; set; }
public string Cuenta { get; set; }
public string Factura { get; set; }
public string Descripcion { get; set; }
public string Semaforo { get; set; }
public string ClavePedimento { get; set; }
public string TipoCambio { get; set; }
public string Operacion { get; set; }
public string Contenedor { get; set; }
}

@ -0,0 +1,26 @@
namespace CORRESPONSALBackend.DTO.Reportes.CuentasCerradas{
public class DTOCuentasCerradas{
public string Trafico { get; set; }
public string TipoOperacion { get; set; }
public string Cliente { get; set; }
public string Proveedor { get; set; }
public string Corresponsal { get; set; }
public string Aduana { get; set; }
public string Patente { get; set; }
public string Pedimento { get; set; }
public string FechaPago { get; set; }
public string Facturas { get; set; }
public string Descripcion { get; set; }
public string FechaAlta { get; set; }
public string Clave { get; set; }
public string ValorMn { get; set; }
public string ValorDls { get; set; }
public string TipoCambio { get; set; }
public string ValorComercial { get; set; }
public string Fracciones { get; set; }
public string TotalPagado { get; set; }
/* public string Caja { get; set; }
public string FechaCruce {get;set;}
public string Semaforo {get;set;} */
}
}

@ -9,8 +9,9 @@ namespace CORRESPONSALBackend.DTO.Reportes
public int IdCorresponsal { get; set; } = 0;
public int Pedimento {get;set;} = 0;
public int Patente {get;set;} = 0;
public int Aduana {get;set;} = 0;
public string Aduana {get;set;} = "0";
public string? Referencia { get; set; } = null!;
public int IdUsuario {get;set;} = 0;
public int Estado {get;set;} = 0;
}
}

@ -16,7 +16,7 @@ namespace CORRESPONSALBackend.DTO.Reportes
public int Modo { get; set; } = 0;
public int Pedimento {get;set;} = 0;
public int Patente {get;set;} = 0;
public int Aduana {get;set;} = 0;
public string Aduana {get;set;} = "0";
public string? Referencia { get; set; } = null!;
}
}

@ -3,6 +3,7 @@ namespace CORRESPONSALBackend.DTO.Reportes
public class DTOReporteSemanalNewell{
public string GC {get;set;}
public string Contenedor { get; set; }
public string TipoContenedor {get;set;}
public string CuentaDeGastos { get; set; }
public string Razon { get; set; }
public float Maniobras { get; set; }

@ -0,0 +1,32 @@
namespace CORRESPONSALBackend.DTO.Reportes.Facturacion{
public class DTOReporteGeneralFacturacion
{
public string Trafico { get; set; }
public string Corresponsal { get; set; }
public string Aduana { get; set; }
public int Patente { get; set; }
public string PedimentoCorreponsal { get; set; }
public string PedimentoCorresponsalR1 { get; set; }
public string FechaPago { get; set; }
public string FechaAnticipo { get; set; }
public double SumaAnticipoCorresponsalFinanciado { get; set; }
public string FechaAlta { get; set; }
public string UsuarioAlta { get; set; }
public int Cliente { get; set; }
public string Nombrecliente { get; set; }
public string Cuenta { get; set; }
public string TipoOperacion { get; set; }
public string Terminado { get; set; }
public string FechaRegistroContabilizar { get; set; }
public string FechaContabilizado { get; set; }
public string FechaFacturado { get; set; }
public string FechaFacturaCorresponsal { get; set; }
public string FechaCruce { get; set; }
public string MotivoCuentaRechazadaContabilidad { get; set; }
public string MotivoCuentaRechazadaFacturacion { get; set; }
public string MotivoSolicitaReapertura { get; set; }
public string SolicitudReaperturaAutorizada { get; set; }
public string EstatusOperacion { get; set; }
public string CargoShipper { get; set; }
}
}

@ -2,7 +2,7 @@ namespace CORRESPONSALBackend.DTO.Reportes.GC50{
public class DTOReporteGC50{
public string Trafico { get; set; }
public string Corresponsal { get; set; }
public int Aduana { get; set; }
public string Aduana { get; set; }
public int Patente { get; set; }
public string PedimentoCorresponsal { get; set; }
public string PedimentoCorresponsalR1 { get; set; }

@ -5,7 +5,7 @@ namespace CORRESPONSALBackend.Models.Catalogos
public int id { set; get; } = 0;
public string Nombre { set; get; } = null!;
public int Patente { set; get; } = 0;
public int Aduana { set; get; } = 0;
public string Aduana { set; get; } = "0";
public string Correos { set; get; } = null!;
}
}

@ -0,0 +1,6 @@
namespace CORRESPONSALBackend.Models.Catalogos{
public class CatTiposContenedores {
public int id { get; set; }
public string Descripcion { get; set; }
}
}

@ -6,5 +6,8 @@
public string Nombre { set; get; } = null!;
public int IdCliente { set; get; } = 0;
public Boolean Activo { set; get; } = true;
public int? IdCorresponsal {get;set;} = null;
public int? Tipo {get; set;} = 0;
public int? Moneda {get; set;} = 0;
}
}

@ -8,5 +8,6 @@
public string? Concepto { set; get; } = null!;
public double Costo { set; get; } = 0;
public int Activo { set; get; } = 0;
public double CostoCorresponsal { set; get; } = 0;
}
}

@ -0,0 +1,39 @@
namespace CORRESPONSALBackend.Models.Clientes.Alen{
public class EstadosCuenta{
public int id { get; set; }
public string? TipoMovimiento { get; set; } = "";
public string? NoSerie { get; set; } = "";
public string? NoMovimiento {get;set;} = "";
public string? Trafico {get;set;} = "";
public string? Impexp {get;set;} = "";
public string? Aduana {get;set;} = "";
public string? Patente {get;set;} = "";
public string? Pedimento {get;set;} = "";
public string? Clave {get;set;} = "";
public string? NoCliente {get;set;} = "";
public string? NoCentro {get;set;} = "";
public string? SubCentro {get;set;} = "";
public string? Nombre {get;set;} = "";
public string? SubCtaNombre {get;set;} = "";
public string? TipoRangos {get;set;} = "";
public string? Cargos {get;set;} = "";
public string? Abonos {get;set;} = "";
public string? Fecha {get;set;} = "";
public string? FechaPedimento {get;set;} = "";
public string? FechaRev {get;set;} = "";
public string? DiasPedimCta {get;set;} = "";
public string? DiasCtaRev {get;set;} = "";
public string? DiasRev {get;set;} = "";
public string? IvaAl {get;set;} = "";
public string? TotalFacturado {get;set;} = "";
public string? SaldoFinal {get;set;} = "";
public string? Anticipo {get;set;} = "";
public string? UUID {get;set;} = "";
public string? Descripcion {get;set;} = "";
public string? Remitente {get;set;} = "";
public string? Pedido {get;set;} = "";
public string? TipoMercancia {get;set;} = "";
public string? CampoAdicional5 {get;set;} = "";
public bool? Programado = false;
}
}

@ -12,5 +12,10 @@
public Boolean? Activo { get; set; } = true;
public int? Code { get; set; } = 0;
public string? FolioGEMCO { get; set; } = null!;
public string? COVE {get;set;} = null!;
public string? Entrega {get;set;}=null!;
public string? Transporte {get;set;}=null!;
public string? UUID {get;set;}= null!;
public int? IdContenedor {get;set;} = 0;
}
}

@ -2,10 +2,10 @@ namespace CORRESPONSALBackend.Models.Corresponsales{
public class CorresponsalPedimentosConsolidados{
public int Id { get; set; }
public int IdTrafico { get; set; }
public int Aduana { get; set; }
public string Aduana { get; set; }
public int Patente { get; set; }
public int Pedimento { get; set; }
public string Clave { get; set; }
public DateTime FechaPago { get; set; }
public DateTime? FechaPago { get; set; } = null;
}
}

@ -8,6 +8,7 @@ namespace CORRESPONSALBackend.Models.Corresponsales
public int StatusProceso { set; get; } = 0!;
public string FechaRegistro { set; get; } = null!;
public string RazonRechazo { set; get; } = null!;
public int Tipo { set; get; } = 0!;
public int NuevoProceso { set; get; } = 0!;
public int ProcesoAnterior { set; get; } = 0!;
}
}

@ -7,5 +7,6 @@
public string? Contenedor { get; set; } = null!;
public string? FSemaforo { get; set; } = null!;
public byte? Semaforo { get; set; } = 0!;
public int IdTipoContenedor { get; set; } = 0;
}
}

@ -9,5 +9,6 @@
public string Concepto { get; set; } = null!;
public double Costo { get; set; } = 0;
public byte Activo { get; set; } = 0;
public double CostoCorresponsal {get; set;} = 0;
}
}

@ -16,7 +16,7 @@
public double? Kilos { get; set; } = 0;
public int? Estatus { get; set; } = 0;
public string? Trafico { get; set; } = null!;
public int? Aduana { get; set; } = 0;
public string? Aduana { get; set; } = "0";
public int? Patente { get; set; } = 0;
public int? Pedimento { get; set; } = 0;
public string? Clave { get; set; } = null!;
@ -46,5 +46,6 @@
public string CausaRectificacion {get;set;} = "";
public double TotalHonorariosAA { get; set; }
public double TotalGastosTerceros { get; set; }
public int PedimentoObligatorio {get;set;}
}
}

@ -0,0 +1,13 @@
namespace CORRESPONSALBackend.Models.Corresponsales{
public class ITraficoSolicitud{
public int Id { get; set; }
public int IdTrafico { get; set; }
public int IdUsuarioSolicita { get; set; }
public string? FechaSolicita { get; set; } = null;
public string MotivoSolicita { get; set; }
public int IdUsuarioAutoriza { get; set; }
public string? FechaAutoriza { get; set; } = null;
public string MotivoRechazo { get; set; }
public short Estado { get; set; }
}
}

@ -0,0 +1,11 @@
namespace GEMCO.Backend.Models.Reportes
{
public class RptPedimentosPagadosAEO
{
public string Referencia { set; get; } = null!;
public int Aduana { get; set; } = 0;
public int Patente { get; set; } = 0;
public int Pedimento { get; set; } = 0;
public string FechaPago { set; get; } = null!;
}
}

@ -44,6 +44,19 @@ using CORRESPONSALBackend.Contracts.Reportes.Newell.Semanal;
using CORRESPONSALBackend.Services.Reportes.Newell.Semanal;
using CORRESPONSALBackend.Contracts.Corresponsalias.Services;
using CORRESPONSALBackend.Services.Corresponsalias.Facturas;
using CORRESPONSALBackend.Services.Corresponsalias.Traficos;
using CORRESPONSALBackend.Contracts.Reportes.Alen;
using CORRESPONSALBackend.Services.Reportes.Alen;
using CORRESPONSALBackend.Contracts.Reportes.CuentasCerradas;
using CORRESPONSALBackend.Repository.Reportes.CuentasCerradas;
using CORRESPONSALBackend.Services.Reportes.CuentasCerradas;
using CORRESPONSALBackend.Contracts.Reportes;
using CORRESPONSALBackend.Services.Reportes;
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
using CORRESPONSALBackend.Services;
using CORRESPONSALBackend.Repository.Reportes.Alen;
using CORRESPONSALBackend.Contracts.Reportes.Facturacion;
using CORRESPONSALBackend.Repository.Reportes.Facturacion;
var builder = WebApplication.CreateBuilder(args);
@ -65,7 +78,12 @@ builder.Services.AddScoped<IReportesEmbarquesService, ReportesEmbarquesService>(
builder.Services.AddScoped<IReportesEmbarquesRepository, ReportesEmbarquesRepository>();
builder.Services.AddScoped<IReporteGC50Repository, ReporteGC50Repository>();
builder.Services.AddScoped<ICorresponsaliasFacturasService, CorresponsaliasFactuasService>();
builder.Services.AddScoped<ICorresponsaliasTraficosService, CorresponsaliasTraficosService>();
builder.Services.AddScoped<IReportesAlenService, ReportesAlenService>();
builder.Services.AddScoped<IReportesAlenRepository, ReportesAlenRepository>();
builder.Services.AddScoped<IReporteCuentasCerradasRepository, ReporteCuentasCerradasRepository>();
builder.Services.AddScoped<IReporteCuentasCerradasService, ReporteCuentasCerradasService>();
builder.Services.AddScoped<IReportesFacturacionRepository, ReportesFacturacionRepository>();
// Corresponsalias
builder.Services.AddScoped<IContabilidadCorresponsaliasRepository, ContabilidadCorresponsaliasRepository>();
builder.Services.AddScoped<ICorresponsaliasContenedoresRepository, CorresponsaliasContenedoresRepository>();
@ -79,9 +97,14 @@ builder.Services.AddScoped<ICorresponsaliasPedimentoRepository, CorresponsaliasP
builder.Services.AddScoped<ICorresponsaliasPedimentoPartidasRepository, CorresponsaliasPedimentoPartidasRepository>();
builder.Services.AddScoped<ICorresponsaliasCuentasComplementarias, CorresponsaliasCuentaComplementariaRepository>();
builder.Services.AddScoped<ICorresponsaliasPedimentosConsolidadosRepository, CorresponsaliasPedimentosConsolidadosRepository>();
builder.Services.AddScoped<ICorresponsaliasSolicitudesRepository, CorresponsaliasSolicitudesRepository>();
builder.Services.AddScoped<ITraficosClientesService, TraficosClientesService>();
builder.Services.AddScoped<IArchivoElectronicoRepository, ArchivoElectronicoRepository>();
builder.Services.AddScoped<IArchivoElectronicoService, ArchivoElectronicoService>();
//Clientes
builder.Services.AddScoped<ICasaCuervoRepository, CasaCuervoRepository>();
//Estados de Cuenta
builder.Services.AddScoped<IEstadosCuentaAlenRepository, EstadosCuentaAlenRepository>();
// Dashboards
builder.Services.AddScoped<IDashboardCorresponsalesRepository, DashboardCorresponsalesRepository>();
@ -98,6 +121,7 @@ builder.Services.AddScoped<ICorresponsaliasCatMediosEmbarqueRepository, Correspo
builder.Services.AddScoped<ITiposMercanciaRepository, TiposMercanciaRepository>();
builder.Services.AddScoped<ICatCentrosCostosRepository, CatCentrosCostosRepository>();
builder.Services.AddScoped<ICatClavesPedimentosRepository, CatClavesPedimentosRepository>();
builder.Services.AddScoped<ICatTiposContenedoresRepository, CatTiposContenedoresRepository>();
//Utilerias
builder.Services.AddScoped<IFileManagerRepository, FileManagerRepository>();

@ -0,0 +1,31 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
using CORRESPONSALBackend.DTO.ArchivoElectronico;
using Dapper;
using GEMCO.Backend.Models.Reportes;
namespace CORRESPONSALBackend.Repository{
public class ArchivoElectronicoRepository : IArchivoElectronicoRepository
{
private readonly DapperContext _context;
public ArchivoElectronicoRepository(DapperContext context) { _context = context; }
public async Task<List<RptPedimentosPagadosAEO>> getRptPedimentoPagadosAEO(DTOAEPeriodo data)
{
var query = "getRptArchivoElectronicoOficial";
using (var connection = _context.CreateConnection())
{
var entrada = await connection.QueryAsync<RptPedimentosPagadosAEO>(query,
new
{
@Anio = data.Anio,
@Mes = data.Mes,
@NoCliente = data.NoCliente,
@TipoOperacion = data.TipoOperacion
},
commandType: CommandType.StoredProcedure);
return entrada.ToList();
}
}
}
}

@ -0,0 +1,23 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.Catalogos;
using CORRESPONSALBackend.Models.Catalogos;
using Dapper;
namespace CORRESPONSALBackend.Repository.Catalogos{
public class CatTiposContenedoresRepository : ICatTiposContenedoresRepository
{
private readonly DapperContext _context;
public CatTiposContenedoresRepository(DapperContext context){
_context = context;
}
public async Task<IEnumerable<CatTiposContenedores>> Get()
{
var query = "[Catalogo.CatTiposContenedores.Get]";
var connection = _context.CreateConnection();
var tipos = await connection.QueryAsync<CatTiposContenedores>(query, new {}, commandType: CommandType.StoredProcedure);
return tipos;
}
}
}

@ -21,6 +21,7 @@ namespace CORRESPONSALBackend.Repository.Catalogos
data.IdTabulador,
data.IdConcepto,
data.Costo,
data.CostoCorresponsal
},
commandType: CommandType.StoredProcedure);
return entrada;

@ -12,14 +12,15 @@ namespace CORRESPONSALBackend.Repository.Catalogos
private readonly DapperContext _context;
public TabuladorRepository(DapperContext context) { _context = context; }
public async Task<IEnumerable<Tabulador>> GetAll(int id, int IdCliente)
public async Task<IEnumerable<Tabulador>> GetAll(int id, int IdCliente, int? idCorresponsal)
{
var query = "[Catalogo.Tabulador.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<Tabulador>(query, new
{
@id = id,
@IdCliente = IdCliente
@IdCliente = IdCliente,
@IdCorresponsal = idCorresponsal
},
commandType: CommandType.StoredProcedure);
return entrada;
@ -35,6 +36,9 @@ namespace CORRESPONSALBackend.Repository.Catalogos
data.id,
data.Nombre,
data.IdCliente,
data.IdCorresponsal,
data.Tipo,
data.Moneda
},
commandType: CommandType.StoredProcedure);
return entrada.First();

@ -94,7 +94,8 @@ namespace CORRESPONSALBackend.Repository
@Aduana = data.Aduana,
@Pedimento = data.Pedimento,
@Referencia = data.Referencia,
@idUsuario = data.IdUsuario
@idUsuario = data.IdUsuario,
@Estado = data.Estado
},
commandType: CommandType.StoredProcedure);
return entrada;

@ -22,25 +22,37 @@ namespace CORRESPONSALBackend.Repository.Contabilidad
@IdTrafico = data.IdTrafico,
@StatusProceso = data.StatusProceso,
@RazonRechazo = data.RazonRechazo,
@Tipo = data.Tipo
@NuevoProceso = data.NuevoProceso,
@ProcesoAnterior = data.ProcesoAnterior
},
commandType: CommandType.StoredProcedure);
return entrada.FirstOrDefault(new CorresponsalTraficoContabilidad { });
}
public async Task<IEnumerable<string>> Get(int IdTrafico, int tipo)
public async Task<IEnumerable<string>> Get(int IdTrafico, int procesoAnterior, int nuevoProceso)
{
var query = "[Contabilidad.Corresponsales.Trafico.Validacion.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<string>(query, new
{
@IdTrafico = IdTrafico,
@tipo = tipo
@procesoAnterior = procesoAnterior,
@nuevoProceso = nuevoProceso
},
commandType: CommandType.StoredProcedure);
return entrada;
}
public async Task<IEnumerable<string>> Historial(int IdTrafico)
{
var query = "[Contabilidad.Corresponsales.Trafico.HistorialMovimientos]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<string>(query, new
{
@IdTrafico = IdTrafico
},
commandType: CommandType.StoredProcedure);
return entrada;
}
}
}

@ -33,7 +33,8 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias
data.IdTrafico,
data.Contenedor,
data.FSemaforo,
data.Semaforo
data.Semaforo,
data.IdTipoContenedor
},
commandType: CommandType.StoredProcedure);
return entrada.First();

@ -36,7 +36,12 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias
data.Proveedor,
data.ValorFacturaDls,
data.Pedido,
data.FechaFactura
data.FechaFactura,
data.UUID,
data.COVE,
data.Entrega,
data.Transporte,
data.IdContenedor
},
commandType: CommandType.StoredProcedure);
return entrada.First();

@ -0,0 +1,85 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.DTO.Corresponsales;
using CORRESPONSALBackend.Models.Corresponsales;
using Dapper;
namespace CORRESPONSALBackend.Repository.Corresponsalias{
public class CorresponsaliasSolicitudesRepository : ICorresponsaliasSolicitudesRepository
{
private readonly DapperContext _context;
public CorresponsaliasSolicitudesRepository(DapperContext context) { _context = context; }
public async Task<ITraficoSolicitud> AppendSolicitudReapertura(ITraficoSolicitud solicitud)
{
var query = "[Corresponsales.Trafico.SolicitudReapertura.Append]";
using var connection = _context.CreateConnection();
var response = await connection.QueryAsync<ITraficoSolicitud>(query, new {
@id =solicitud.Id,
@idTrafico = solicitud.IdTrafico,
@idUsuarioSolicita = solicitud.IdUsuarioSolicita,
@fechaSolicita = solicitud.FechaSolicita,
@motivoSolicita = solicitud.MotivoSolicita,
@idUsuarioAutoriza = solicitud.IdUsuarioAutoriza,
@fechaAutoriza = solicitud.FechaAutoriza,
@motivoRechazo = solicitud.MotivoRechazo,
@estado = solicitud.Estado
}, commandType: CommandType.StoredProcedure);
return response.First();
}
public async Task<DTOTraficoSolicitud> GetSolicitudReapertura(int idTrafico)
{
var query = "[Corresponsales.Trafico.SolicitudReapertura.Get]";
using var connection = _context.CreateConnection();
var response = await connection.QueryAsync<DTOTraficoSolicitud>(query, new {
@idTrafico = idTrafico
}, commandType: CommandType.StoredProcedure);
return response.FirstOrDefault(new DTOTraficoSolicitud{
Id=0,
IdTrafico=idTrafico,
UsuarioSolicita= "",
FechaSolicita=null,
MotivoSolicita="",
Estado=1
});
}
public async Task<ITraficoSolicitud> AppendSolicitudEliminarReferencia(ITraficoSolicitud solicitud)
{
var query = "[Corresponsales.Trafico.Solicitud.EliminarCuenta.Append]";
using var connection = _context.CreateConnection();
var response = await connection.QueryAsync<ITraficoSolicitud>(query, new {
@id =solicitud.Id,
@idTrafico = solicitud.IdTrafico,
@idUsuarioSolicita = solicitud.IdUsuarioSolicita,
@fechaSolicita = solicitud.FechaSolicita,
@motivoSolicita = solicitud.MotivoSolicita,
@idUsuarioAutoriza = solicitud.IdUsuarioAutoriza,
@fechaAutoriza = solicitud.FechaAutoriza,
@motivoRechazo = solicitud.MotivoRechazo,
@estado = solicitud.Estado
}, commandType: CommandType.StoredProcedure);
return response.First();
}
public async Task<DTOTraficoSolicitud> GetSolicitudEliminarReferencia(int idTrafico)
{
var query = "[Corresponsales.Trafico.Solicitud.EliminarCuenta.Get]";
using var connection = _context.CreateConnection();
var response = await connection.QueryAsync<DTOTraficoSolicitud>(query, new {
@idTrafico = idTrafico
}, commandType: CommandType.StoredProcedure);
return response.FirstOrDefault(new DTOTraficoSolicitud{
Id=0,
IdTrafico=idTrafico,
UsuarioSolicita= "",
FechaSolicita=null,
MotivoSolicita="",
Estado=1
});
}
}
}

@ -5,12 +5,13 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias
public int Id { get; set; } = 0;
public int Usuario { get; set; } = 0;
public int IdTrafico { get; set; } = 0;
public int Aduana { get; set; } = 0;
public string Aduana { get; set; } = "0";
public int Patente { get; set; } = 0;
public int Pedimento { get; set; } = 0;
public string Clave { get; set; } = null!;
public string FechaPago { get; set; } = null!;
public string FHCreacion { get; set; } = null!;
public byte Activo { get; set; } = 0;
public int IdPedimentoConsolidado {get;set;} = 0 ;
}
}

@ -39,18 +39,32 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias
return entrada.FirstOrDefault(new ITrafico { });
}
public async Task<DTOReporteSemanalNewell> GetByPedimento(int pedimento)
public async Task<DTOReporteSemanalNewell> GetByPedimento(int pedimento, string aduana, int patente)
{
var query = "[Corresponsales.Trafico.GetByPedimento]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<DTOReporteSemanalNewell>(query, new
{
@pedimento
@pedimento,
@aduana,
@patente
},
commandType: CommandType.StoredProcedure);
return entrada.FirstOrDefault(new DTOReporteSemanalNewell { });
}
public async Task<ITrafico> GetByReferencia(string referencia)
{
var query = "[Corresponsales.Trafico.GetByReferencia]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<ITrafico>(query, new
{
@referencia=referencia
},
commandType: CommandType.StoredProcedure);
return entrada.FirstOrDefault(new ITrafico { });
}
public async Task<IEnumerable<ICorRectificaciones>> GetRectificaciones(int id)
{
var query = "[Corresponsales.Trafico.Rectificacion.GetAll]";
@ -117,7 +131,8 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias
@CargoA = data.CargoA,
@CausaRectificacion = data.CausaRectificacion,
@TotalHonorariosAA = data.TotalHonorariosAA,
@TotalGastosTerceros = data.TotalGastosTerceros
@TotalGastosTerceros = data.TotalGastosTerceros,
@PedimentoObligatorio = data.PedimentoObligatorio
},
commandType: CommandType.StoredProcedure);
return entrada.First();
@ -142,33 +157,49 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias
{
@id = data.Id,
@IdUsuario = data.IdUsuario,
@Estatus = data.Estatus,
@PedimentoObligatorio = data.PedimentoObligatorio,
@Comentarios = data.Comentarios
},
commandType: CommandType.StoredProcedure);
return true;
}
public async Task<Boolean> RectificacionHistoricoAppend(DTORectificacionHistorico data)
public async Task<CorresponsaliasTraficoRectificacionHistorico> RectificacionHistoricoAppend(DTORectificacionHistorico data)
{
try
{
var query = "[Corresponsales.Trafico.Rectificacion.Historico.Append]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync(query, new { @data.IdTrafico, @data.IdUsuario }, commandType: CommandType.StoredProcedure);
return true;
}catch(Exception ex) { return false; }
var entrada = await connection.QueryFirstAsync<CorresponsaliasTraficoRectificacionHistorico>(query, new {
@data.IdTrafico,
@data.IdUsuario,
@data.IdPedimento,
@data.Aduana,
@data.Patente,
@data.Pedimento,
@data.Clave,
@data.FechaPago,
@data.AduanaH,
data.PatenteH,
data.PedimentoH,
data.ClaveH,
data.FechaPagoH
}, commandType: CommandType.StoredProcedure);
return entrada;
}catch(Exception ex) {
throw new Exception(ex.Message);
}
}
public async Task<CorresponsaliasTraficoRectificacionHistorico> RectificacionHistoricoGet(int IdTrafico)
public async Task<IEnumerable<CorresponsaliasTraficoRectificacionHistorico>> RectificacionHistoricoGet(int IdTrafico)
{
var query = "[Corresponsales.Trafico.Rectificacion.Historico.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<CorresponsaliasTraficoRectificacionHistorico>(query, new { @IdTrafico }, commandType: CommandType.StoredProcedure);
return entrada.FirstOrDefault(new CorresponsaliasTraficoRectificacionHistorico { });
return entrada;
}
public async Task<string> ValidaTraficoDuplicado(int aduana, int patente, int pedimento, int idTrafico)
public async Task<string> ValidaTraficoDuplicado(string aduana, int patente, int pedimento, int idTrafico)
{
var query = "[Corresponsales.Trafico.ValidateDuplicity]";
using var connection = _context.CreateConnection();
@ -182,6 +213,5 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias
return "";
}
}
}
}

@ -54,5 +54,23 @@ namespace CORRESPONSALBackend.Repository.Dashboard
return entrada.First();
}
public async Task<DashboardCorresponsales> SolicitudesReapertura()
{
var query = "[Dashboard.Facturacion.SolicitudesReapertura.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<DashboardCorresponsales>(query, new {}, commandType: CommandType.StoredProcedure);
return entrada.First();
}
public async Task<DashboardCorresponsales> SolicitudesElminarCuenta()
{
var query = "[Dashboard.Facturacion.SolicitudesEliminarCuenta.Get]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<DashboardCorresponsales>(query, new {}, commandType: CommandType.StoredProcedure);
return entrada.First();
}
}
}

@ -0,0 +1,138 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.Reportes.Alen;
using CORRESPONSALBackend.DTO.Reportes.Alen;
using CORRESPONSALBackend.Models.Clientes.Alen;
using Dapper;
namespace CORRESPONSALBackend.Repository.Reportes.Alen{
public class EstadosCuentaAlenRepository : IEstadosCuentaAlenRepository
{
private readonly DapperContext _context;
private readonly IConfiguration _config;
public EstadosCuentaAlenRepository(DapperContext context, IConfiguration config)
{
_context = context;
_config = config;
}
public async Task<EstadosCuenta> Append(EstadosCuenta data)
{
var query = "[EstadosCuenta.Alen.Append]";
using (var connection = _context.CreateConnection())
{
var estado = await connection.QueryAsync<EstadosCuenta>(query, new
{
data.TipoMovimiento,
data.NoSerie,
data.NoMovimiento,
data.Trafico,
data.Impexp,
data.Aduana,
data.Patente,
data.Pedimento,
data.Clave,
data.NoCliente,
data.NoCentro,
data.SubCentro,
data.Nombre,
data.SubCtaNombre,
data.TipoRangos,
data.Cargos,
data.Abonos,
data.Fecha,
data.FechaPedimento,
data.FechaRev,
data.DiasPedimCta,
data.DiasCtaRev,
data.DiasRev,
data.IvaAl,
data.TotalFacturado,
data.SaldoFinal,
data.Anticipo,
data.UUID,
data.Descripcion,
data.Remitente,
data.Pedido,
data.TipoMercancia,
data.CampoAdicional5,
}, commandType: CommandType.StoredProcedure);
return estado.First();
}
}
public async Task<EstadosCuenta> AppendObservaciones(DTOEstadosCuentaAlen data)
{
var query = "[EstadosCuenta.Alen.AppendObservaciones]";
using (var connection = _context.CreateConnection())
{
var cuenta = await connection.QueryAsync<EstadosCuenta>(query, new {data.IdObservaciones, @NoCuenta = data.NoMovimiento, data.Observaciones}, commandType: CommandType.StoredProcedure);
return cuenta.First();
}
}
public async Task<EstadosCuenta> AppendOrdenCompra(DTOEstadosCuentaAlen data)
{
var query = "[EstadosCuenta.Alen.AppendOrdenCompra]";
using (var connection = _context.CreateConnection())
{
var cuenta = await connection.QueryAsync<EstadosCuenta>(query, new {data.IdOrdenCompra, @NoCuenta = data.NoMovimiento, data.OrdenCompra}, commandType: CommandType.StoredProcedure);
return cuenta.First();
}
}
public async Task ClearData()
{
var query = "[EstadosCuenta.Alen.Clear]";
using (var connection = _context.CreateConnection())
{
await connection.QueryAsync<DTOEstadosCuentaAlen>(query, new {}, commandType: CommandType.StoredProcedure);
}
}
public async Task<IEnumerable<DTOEstadosCuentaAlen>> GetAll(DTOEstadosCuentaAlenFilters filters)
{
var query = "[EstadosCuenta.Alen.GetAll]";
using (var connection = _context.CreateConnection())
{
var estados = await connection.QueryAsync<DTOEstadosCuentaAlen>(query, new {
filters.Trafico,
filters.Impexp,
filters.Aduana,
filters.Patente,
filters.Pedimento,
filters.Inicio,
filters.Fin,
filters.Remitente,
filters.Programado
}, commandType: CommandType.StoredProcedure);
return estados;
}
}
public async Task<EstadosCuenta> GetByFolio(string Folio)
{
var query = "[EstadosCuenta.Alen.GetByFolio]";
using (var connection = _context.CreateConnection())
{
var cuenta= await connection.QueryAsync<EstadosCuenta>(query, new {
@Folio
}, commandType: CommandType.StoredProcedure);
return cuenta.FirstOrDefault(new EstadosCuenta(){id=0});
}
}
public async Task<EstadosCuenta> MarkAsProgramado(string NoMovimiento, string NoSerie)
{
var query = "[EstadosCuenta.Alen.MarkAsProgramado]";
using (var connection = _context.CreateConnection())
{
var cuenta= await connection.QueryFirstOrDefaultAsync<EstadosCuenta>(query, new {
@NoCuenta = NoMovimiento,
@NoSerie = NoSerie
}, commandType: CommandType.StoredProcedure);
return cuenta;
}
}
}
}

@ -0,0 +1,22 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.Reportes.Alen;
using Dapper;
public class ReportesAlenRepository : IReportesAlenRepository
{
private readonly DapperContext _context;
public ReportesAlenRepository(DapperContext context) { _context = context; }
public async Task<IEnumerable<DTOReporteFacturasTraficosConsolidados>> GetFacturasTraficoConsolidado(int idTrafico, string referencia)
{
var query = "[Reportes.Alen.FacturasTraficosConsolidados]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<DTOReporteFacturasTraficosConsolidados>(query, new
{
@IdTrafico = idTrafico,
@Referencia = referencia
},
commandType: CommandType.StoredProcedure);
return entrada;
}
}

@ -0,0 +1,28 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.Reportes.CuentasCerradas;
using CORRESPONSALBackend.DTO.Reportes.CuentasCerradas;
using Dapper;
namespace CORRESPONSALBackend.Repository.Reportes.CuentasCerradas{
public class ReporteCuentasCerradasRepository : IReporteCuentasCerradasRepository
{
private readonly DapperContext _context;
public ReporteCuentasCerradasRepository(DapperContext context) { _context = context; }
public async Task<IEnumerable<DTOCuentasCerradas>> GetCuentasCerradas(string Inicio, string Fin, int TipoOperacion, int NoCliente, int IdCorresponsal)
{
var query = "[Reportes.CuentasCerradas]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<DTOCuentasCerradas>(query, new
{
@Inicio = Inicio,
@Fin = Fin,
@NoCliente = NoCliente,
@TipoOperacion = TipoOperacion,
@IdCorresponsal = IdCorresponsal
},
commandType: CommandType.StoredProcedure);
return entrada;
}
}
}

@ -0,0 +1,34 @@
using System.Data;
using CORRESPONSALBackend.Context;
using CORRESPONSALBackend.Contracts.Reportes.Facturacion;
using CORRESPONSALBackend.DTO.Reportes;
using CORRESPONSALBackend.DTO.Reportes.Facturacion;
using Dapper;
namespace CORRESPONSALBackend.Repository.Reportes.Facturacion{
public class ReportesFacturacionRepository : IReportesFacturacionRepository
{
private readonly DapperContext _context;
public ReportesFacturacionRepository(DapperContext context) { _context = context; }
public async Task<IEnumerable<DTOReporteGeneralFacturacion>> GetCuentasFacturadas(DTOReporteCorresponsales data)
{
var query = "[Reportes.Facturacion.GetCuentasFacturadas]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<DTOReporteGeneralFacturacion>(query, new
{
@Inicio = data.Inicio,
@Fin = data.Fin,
@NoCliente = data.NoCliente,
@TipoOperacion = data.TipoOperacion,
@IdCorresponsal = data.IdCorresponsal,
@Patente = data.Patente,
@Aduana = data.Aduana,
@Pedimento = data.Pedimento,
@Proceso = data.Proceso,
@Modo = data.Modo
},
commandType: CommandType.StoredProcedure);
return entrada;
}
}
}

@ -122,5 +122,16 @@ namespace CORRESPONSALBackend.Repository.Utils
commandType: CommandType.StoredProcedure);
return entrada.FirstOrDefault();
}
public async Task<IEnumerable<FileManager>> GetTraficoFiles(int idTrafico){
string query = "[Utils.FileManager.GetTraficoFiles]";
using var connection = _context.CreateConnection();
var entrada = await connection.QueryAsync<FileManager>(query, new
{
@idtrafico = idTrafico
},
commandType: CommandType.StoredProcedure);
return entrada.ToList();
}
}
}

@ -0,0 +1,7 @@
using CORRESPONSALBackend.Contracts.ArchivoElectronico;
namespace CORRESPONSALBackend.Services{
public class ArchivoElectronicoService : IArchivoElectronicoService{
}
}

@ -95,7 +95,7 @@ namespace CORRESPONSALBackend.Services.C1896
{
Registro.Trafico = row.Referencia;
Registro.Patente = Int32.Parse(row.Patente);
Registro.Aduana = Int32.Parse(row.Aduana);
Registro.Aduana = row.Aduana;
Registro.Pedimento = Int32.Parse(row.Pedimento);
Registro.FechaPago = row.FechaPago;
Registro.TipoCambio = row.TC;

@ -0,0 +1,115 @@
using System.Globalization;
using System.Text.RegularExpressions;
using CORRESPONSALBackend.Contracts;
using CORRESPONSALBackend.Contracts.Catalogos;
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.Contracts.Corresponsalias.Services;
using CORRESPONSALBackend.Contracts.Utils;
using CORRESPONSALBackend.Models;
using CORRESPONSALBackend.Models.Utils;
namespace CORRESPONSALBackend.Services.Corresponsalias.Traficos{
public class CorresponsaliasTraficosService : ICorresponsaliasTraficosService
{
private readonly IFileManagerRepository _fileManagerRepo;
private readonly IFilePaths4ProcessRepository _RepoRelativePath;
private readonly ICorresponsaliasTraficosRepository _Repo;
private readonly IProveedoresRepository _proveedoresRepository;
private readonly ICorresponsaliasFacturasRepository _facturasRepository;
private readonly ICorresponsaliasContenedoresRepository _contenedoresRepository;
private readonly IClientesRepository _clientesRepository;
private readonly ICatCentrosCostosRepository _centrosCostosRepository;
private readonly ITiposMercanciaRepository _tiposMercanciaRepository;
private readonly IConfiguration _config;
private readonly string RootPathCorresponsales;
public CorresponsaliasTraficosService(IFileManagerRepository fileManagerRepo, IFilePaths4ProcessRepository RepoRelativePath, IConfiguration config,
ICorresponsaliasTraficosRepository Repo, IClientesRepository clientesRepository,
IProveedoresRepository proveedoresRepository, ICorresponsaliasFacturasRepository facturasRepository, ICorresponsaliasContenedoresRepository contenedoresRepository,
ICatCentrosCostosRepository centrosCostosRepository, ITiposMercanciaRepository tiposMercanciaRepository){
_fileManagerRepo = fileManagerRepo;
_RepoRelativePath = RepoRelativePath;
_Repo = Repo;
_proveedoresRepository = proveedoresRepository;
_facturasRepository = facturasRepository;
_contenedoresRepository = contenedoresRepository;
_clientesRepository = clientesRepository;
_centrosCostosRepository = centrosCostosRepository;
_tiposMercanciaRepository = tiposMercanciaRepository;
_config = config;
RootPathCorresponsales = _config.GetValue<string>("AllFiles");
}
public async Task<List<string[]>> ReadTxtFacturasAlen(int fileId)
{
FileManager recFound = await _fileManagerRepo.getFileById(fileId);
FilePaths4Process RelativePath = await _RepoRelativePath.getPaths4ProcessById(recFound.Proceso);
string filePath = RootPathCorresponsales + RelativePath.Path + recFound.NombreArchivo;
if(System.IO.File.Exists(filePath)){
try{
var fileContent = File.ReadAllText(filePath);
string[] GCs = fileContent.Split("\r\n");
List<string[]> facturas = new List<string[]>();
foreach(var gc in GCs){
facturas.Add(gc.Split('|'));
}
File.Delete(filePath);
return facturas;
}catch(Exception ex){
File.Delete(filePath);
throw new Exception(ex.Message);
}
}else{
return new List<string[]>();
}
}
public async Task<string> GetTxtFacturacionData(int idTrafico)
{
try{
var trafico = await _Repo.Get(idTrafico);
trafico.DescripcionMercancia = Regex.Replace(trafico.DescripcionMercancia, @"\t|\n|\r", "");
var tiposMercancia = await _tiposMercanciaRepository.GetAll();
var tipoMercancia = tiposMercancia.First(x => trafico.PedimentoObligatorio == 1 ? x.id == trafico.idTipoMercancia : x.id == 15);
var facturas = await _facturasRepository.GetAll(idTrafico);
string NombreProveedor = "";
var proveedores = await _proveedoresRepository.GetAll(0);
var contenedores = await _contenedoresRepository.GetAll(idTrafico);
var clientes = await _clientesRepository.getAllClientes(0);
var cliente = clientes.First(x => x.sClave == trafico.IdCliente);
var centroCostos = await _centrosCostosRepository.Get(trafico.IdCliente);
int IdCteFacturacion = centroCostos.ClienteFacturacion;
var cteFacturacion = clientes.FirstOrDefault(x => x.sClave == IdCteFacturacion, new IClientes());
string fileData = $"\"{trafico.FolioGemco}\"|{(IdCteFacturacion == trafico.IdCliente || IdCteFacturacion == 0 ? trafico.IdCliente : IdCteFacturacion)}|{trafico.Patente}|{trafico.Pedimento}|{trafico.TipoCambio}|";
fileData += $"{(trafico.FechaPago != null ? DateTime.ParseExact(trafico.FechaPago, "MM/dd/yyyy hh:mm:ss",CultureInfo.InvariantCulture).ToString("yyyy-MM-dd") : "/ / : :")}|";
fileData += $"0|0|0|0|0|0|0.00|\"{trafico.Aduana}\"|\"{trafico.Clave}\"|{trafico.TipoOperacion}|";
fileData += $"\"C\"|{trafico.ValorFacturaDls}|{trafico.ValorFacturaDls! * trafico.TipoCambio!}|{trafico.ValorAduanaMN}|\"{(trafico.DescripcionMercancia.Length >= 100 ? trafico.DescripcionMercancia.Substring(0,100): trafico.DescripcionMercancia)}\"|";
fileData += $"{trafico.Kilos}|{trafico.Kilos! * 2.20462}|{trafico.CantidadFracciones}|\"{(trafico.SemaforoFiscal == 0 ? "R" : "V")}\"|";
if(facturas.Count() > 0){
var factura = facturas.First(x => x.IdTrafico == idTrafico);
NombreProveedor = proveedores.First(x => x.id == factura.Proveedor).Nombre;
NombreProveedor = NombreProveedor.Length >= 50 ? NombreProveedor.Substring(0, 50) : NombreProveedor;
string[] foliosArray = facturas.Select(x => x.Factura).ToArray();
string folios = string.Join(",", foliosArray);
string [] pedidosArray = facturas.Where(x => x.Pedido != "").Select(x => x.Pedido).ToArray();
string pedidos = pedidosArray.Length > 0 ? string.Join(",", pedidosArray) : "";
fileData += $"{facturas.Count()}|\"{(folios.Length >= 25 ? folios.Substring(0,25) : folios)}\"|0|\"{NombreProveedor}\"|\"{(pedidos.Length >= 60 ? pedidos.Substring(0,60) : pedidos)}\"|";
}else{
fileData += $"0|\"\"|0|\"\"|\"\"|";
}
fileData += $"{trafico.Bultos}|0|0|";
fileData += $"{(trafico.FechaDesaduanamiento != "" ? trafico.FechaDesaduanamiento.Substring(0,10) : "/ / : :")}|";
fileData += $"{contenedores.Count()}|0|\"\"|";
fileData += $"{(trafico.FechaDesaduanamiento != "" ? trafico.FechaDesaduanamiento.Substring(0,10) : "/ / : :")}|";
fileData += $"{tipoMercancia.Clave}|0|0|\"\"|\"\"|\"\"|\"\"|/ /|F|F|F|F|0|0|F|0.00|F|0|\"\"|\"\"|";
fileData += $"{(trafico.FechaPago != null ? DateTime.ParseExact(trafico.FechaPago, "MM/dd/yyyy hh:mm:ss",CultureInfo.InvariantCulture).ToString("yyyy-MM-dd") : "/ / : :")}|";
fileData += $"\"\"|\"\"|0|\"{(IdCteFacturacion == trafico.IdCliente || IdCteFacturacion == 0 ? cliente!.sRazonSocial.Split("|")[0].Trim() : cteFacturacion!.sRazonSocial.Split("|")[0].Trim())}\"|";
fileData += $"{(IdCteFacturacion == trafico.IdCliente || IdCteFacturacion == 0 ? cliente!.sRFC : cteFacturacion.sRFC)}|\"\"|\"\"|\"\"|\"\"|\"\"|\"\"|\"\"|\"{NombreProveedor}\"|";
fileData += $"0|\"\"|\"\"|\"\"|\"\"|\"\"|\"\"|\"\"|\"\"|{trafico.ValorFacturaDls}|\"\"|\"\"|336|\"\"|/ / : :|{DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss")}|{DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss")}|";
fileData += $"0|\"\"|\"\"|\"\"|0|0|0|F|\"\"|0|\"\"|\"\"|0|0|0|0|\"\"|\"{centroCostos.CentroCostos.Trim()}\"";
return fileData;
}catch(Exception ex){
throw new Exception(ex.Message);
}
}
}
}

@ -0,0 +1,103 @@
using CORRESPONSALBackend.Contracts.Corresponsalias;
using CORRESPONSALBackend.Contracts.Reportes.Alen;
using CORRESPONSALBackend.Models.Corresponsales;
using OfficeOpenXml;
using OfficeOpenXml.Table;
namespace CORRESPONSALBackend.Services.Reportes.Alen{
public class ReportesAlenService : IReportesAlenService
{
private readonly ICorresponsaliasTraficosRepository _traficosRepo;
private readonly IReportesAlenRepository _repo;
public ReportesAlenService(ICorresponsaliasTraficosRepository traficosRepo, IReportesAlenRepository repo){
_traficosRepo = traficosRepo;
_repo = repo;
}
public async Task<MemoryStream> GetRelacionFacturas(ITrafico trafico, IEnumerable<CorresponsalFacturas> facturas, IEnumerable<CorresponsalesContenedores> contenedores)
{
try{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (ExcelPackage excelPackage = new ExcelPackage()){
var worksheet = excelPackage.Workbook.Worksheets.Add("sheet1");
worksheet.Cells["A1"].Value = "Numero de Remesa";
worksheet.Cells["B1"].Value = "Numero de Factura";
worksheet.Cells["C1"].Value = "Folio Fiscal";
worksheet.Cells["D1"].Value = "Fecha de Factura";
worksheet.Cells["E1"].Value = "Numero de COVE";
worksheet.Cells["F1"].Value = "Valor Factura";
worksheet.Cells["G1"].Value = "Entrega";
worksheet.Cells["H1"].Value = "Transporte";
worksheet.Cells["I1"].Value = "Pedimento";
worksheet.Cells["J1"].Value = "Fecha-Hora Cruce";
worksheet.Cells["K1"].Value = "Fecha Cuenta Corresponsal";
worksheet.Cells["L1"].Value = "Honorarios";
worksheet.Cells["M1"].Value = "Maniobras";
worksheet.Cells["N1"].Value = "Validacion";
worksheet.Cells["O1"].Value = "Contraprestacion";
worksheet.Cells["P1"].Value = "Prevalidacion";
worksheet.Cells["Q1"].Value = "IVA";
worksheet.Cells["R1"].Value = "Total M.N. por Operacion";
int currentRow = 2;
foreach(var factura in facturas){
var fechaCruce = factura.IdContenedor != null && factura.IdContenedor != 0 ? contenedores.FirstOrDefault(x => x.id == factura.IdContenedor).FSemaforo : "";
worksheet.Cells[$"A{currentRow}"].Value = $"{trafico.FolioGemco}-{currentRow-1}";
worksheet.Cells[$"B{currentRow}"].Value = factura.Factura;
worksheet.Cells[$"C{currentRow}"].Value = factura.UUID;
worksheet.Cells[$"D{currentRow}"].Value = factura.FechaFactura;
worksheet.Cells[$"E{currentRow}"].Value = factura.COVE;
worksheet.Cells[$"F{currentRow}"].Value = factura.ValorFacturaDls;
worksheet.Cells[$"G{currentRow}"].Value = factura.Entrega;
worksheet.Cells[$"H{currentRow}"].Value = factura.Transporte;
worksheet.Cells[$"I{currentRow}"].Value = trafico.Pedimento;
worksheet.Cells[$"J{currentRow}"].Value = fechaCruce;
worksheet.Cells[$"K{currentRow}"].Value = trafico.FechaCuenta;
worksheet.Cells[$"L{currentRow}"].Value = "$0.00";
worksheet.Cells[$"M{currentRow}"].Value = "$0.00";
worksheet.Cells[$"N{currentRow}"].Value = "$0.00";
worksheet.Cells[$"O{currentRow}"].Value = "$0.00";
worksheet.Cells[$"P{currentRow}"].Value = "$0.00";
worksheet.Cells[$"Q{currentRow}"].Value = "$0.00";
worksheet.Cells[$"R{currentRow}"].Value = "$0.00";
currentRow++;
}
//Se crea la tabla en el rango de celdas donde se mostrara la inforamcion.
ExcelRange range = worksheet.Cells[1, 1,facturas.Count() + 1, 18];
ExcelTable tab = worksheet.Tables.Add(range, "Table1");
tab.TableStyle = TableStyles.Light1;
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
excelPackage.Workbook.Calculate();
var stream = new MemoryStream();
excelPackage.SaveAs(stream);
stream.Position = 0;
return stream;
}
}catch(Exception ex){
throw new Exception(ex.Message);
}
}
public async Task<MemoryStream> GetReporteFacturasTraficoConsolidado(string referencia)
{
try{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (ExcelPackage excelPackage = new ExcelPackage()){
var worksheet = excelPackage.Workbook.Worksheets.Add("sheet1");
var trafico = await _traficosRepo.GetByReferencia(referencia);
var facturas = await _repo.GetFacturasTraficoConsolidado(trafico.id, referencia);
worksheet.Cells["A1"].LoadFromCollection(facturas, true);
ExcelRange range = worksheet.Cells[1, 1,facturas.Count() + 1, 18];
ExcelTable tab = worksheet.Tables.Add(range, "Table1");
tab.TableStyle = TableStyles.Light1;
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
excelPackage.Workbook.Calculate();
var stream = new MemoryStream();
excelPackage.SaveAs(stream);
stream.Position = 0;
return stream;
}
}catch(Exception ex){
throw new Exception(ex.Message);
}
}
}
}

@ -0,0 +1,43 @@
using CORRESPONSALBackend.Contracts.Reportes.CuentasCerradas;
using CORRESPONSALBackend.DTO.Reportes.CuentasCerradas;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using OfficeOpenXml.Table;
namespace CORRESPONSALBackend.Services.Reportes.CuentasCerradas{
public class ReporteCuentasCerradasService : IReporteCuentasCerradasService
{
public async Task<MemoryStream> GetExcel(IEnumerable<DTOCuentasCerradas> cuentas)
{
try{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (ExcelPackage excelPackage = new ExcelPackage()){
var worksheet = excelPackage.Workbook.Worksheets.Add("sheet1");
worksheet.Cells["A1"].LoadFromCollection(cuentas, true);
//Se crea la tabla en el rango de celdas donde se mostrara la inforamcion.
ExcelRange range = worksheet.Cells[1, 1,cuentas.Count() + 1, 19];
ExcelTable tab = worksheet.Tables.Add(range, "Table1");
tab.TableStyle = TableStyles.Light1;
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
worksheet.Column(10).Width = 100;
worksheet.Column(10).Style.WrapText = true;
worksheet.Column(11).Width = 100;
worksheet.Column(11).Style.WrapText = true;
/* worksheet.Column(19).Width = 100;
worksheet.Column(19).Style.WrapText = true;
worksheet.Column(20).Width = 100;
worksheet.Column(20).Style.WrapText = true;
worksheet.Column(21).Width = 100;
worksheet.Column(21).Style.WrapText = true; */
worksheet.Cells[worksheet.Dimension.Address].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
excelPackage.Workbook.Calculate();
var stream = new MemoryStream();
excelPackage.SaveAs(stream);
return stream;
}
}catch(Exception ex){
throw new Exception(ex.Message);
}
}
}
}

@ -36,22 +36,35 @@ namespace CORRESPONSALBackend.Services.Reportes.Newell.Semanal{
var start = worksheet.Dimension.Start;
var end = worksheet.Dimension.End;
int initialRow = start.Row+1;
/* var aduana = worksheet.Cells[$"A2"].Value.ToString();
var patente = worksheet.Cells[$"B2"].Value.ToString(); */
worksheet.Cells[$"S1"].Value = "Referencia";
worksheet.Cells[$"T1"].Value = "Contenedor";
worksheet.Cells[$"U1"].Value = "Tipo De Contenedor";
worksheet.Cells[$"V1"].Value = "Cuenta de Gastos";
worksheet.Cells[$"W1"].Value = "Estado";
worksheet.Cells[$"X1"].Value = "Maniobras";
for (int currentRow = initialRow; currentRow <= end.Row; currentRow++)// Recorrer renglon por renglon
{
if(!string.IsNullOrWhiteSpace(worksheet.Cells[$"C{currentRow}"].Value?.ToString()) && !string.IsNullOrEmpty(worksheet.Cells[$"C{currentRow}"].Value?.ToString())){
var aduana = worksheet.Cells[$"A{currentRow}"].Value.ToString();
var patente = worksheet.Cells[$"B{currentRow}"].Value.ToString();
var pedimento = worksheet.Cells[$"C{currentRow}"].Value.ToString();
var dto = await _traficosRepository.GetByPedimento(int.Parse(pedimento));
var dto = await _traficosRepository.GetByPedimento(int.Parse(pedimento), aduana, int.Parse(patente));
worksheet.Cells[$"S{currentRow}"].Value = dto.GC;
worksheet.Cells[$"T{currentRow}"].Value = dto.Contenedor;
worksheet.Cells[$"U{currentRow}"].Value = dto.CuentaDeGastos;
worksheet.Cells[$"V{currentRow}"].Value = dto.Razon;
worksheet.Cells[$"W{currentRow}"].Value = dto.Maniobras;
worksheet.Cells[$"U{currentRow}"].Value = dto.TipoContenedor;
worksheet.Cells[$"V{currentRow}"].Value = dto.CuentaDeGastos;
worksheet.Cells[$"W{currentRow}"].Value = dto.Razon;
worksheet.Cells[$"X{currentRow}"].Value = dto.Maniobras;
}else{
continue;
}
}
//Devolver el MS del archivo.
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
worksheet.Column(21).Width = 100;
worksheet.Column(21).Style.WrapText = true;
var stream = new MemoryStream();
package.SaveAs(stream);
stream.Position = 0;

@ -0,0 +1,63 @@
using CORRESPONSALBackend.Contracts.Reportes;
using CORRESPONSALBackend.DTO.Corresponsales;
using OfficeOpenXml;
using OfficeOpenXml.Table;
namespace CORRESPONSALBackend.Services.Reportes{
public class TraficosClientesService : ITraficosClientesService{
public TraficosClientesService(){
}
public async Task<MemoryStream> GetExcel(IEnumerable<DTOCorresponsalTrafico> traficos)
{
try{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using (ExcelPackage excelPackage = new ExcelPackage()){
var worksheet = excelPackage.Workbook.Worksheets.Add("sheet1");
worksheet.Cells["A1"].Value="Estado";
worksheet.Cells["B1"].Value="Trafico";
worksheet.Cells["C1"].Value="Fecha Registro";
worksheet.Cells["D1"].Value="Usuario";
worksheet.Cells["E1"].Value="Cliente";
worksheet.Cells["F1"].Value="Tipo Operación";
worksheet.Cells["G1"].Value="Estado Operación";
worksheet.Cells["H1"].Value="Patente";
worksheet.Cells["I1"].Value="Aduana";
worksheet.Cells["J1"].Value="Pedimento";
worksheet.Cells["K1"].Value="Fecha Pago";
worksheet.Cells["L1"].Value="Fecha Desaduanado";
worksheet.Cells["M1"].Value="Fecha Ultima Actualización";
int currentRow=2;
foreach(var trafico in traficos){
worksheet.Cells[$"A{currentRow}"].Value = trafico.Proceso == 1 ? "Por Terminar" : trafico.Proceso == 2 || trafico.Proceso == 3 ? "Despachado sin Facturar" : "Despachado y Facturado";
worksheet.Cells[$"B{currentRow}"].Value = trafico.Trafico;
worksheet.Cells[$"C{currentRow}"].Value = trafico.FechaRegistro;
worksheet.Cells[$"D{currentRow}"].Value = trafico.sUsuario;
worksheet.Cells[$"E{currentRow}"].Value = trafico.sCliente;
worksheet.Cells[$"F{currentRow}"].Value = trafico.sTipoOperacion;
worksheet.Cells[$"G{currentRow}"].Value = trafico.sEstatus;
worksheet.Cells[$"H{currentRow}"].Value = trafico.Patente;
worksheet.Cells[$"I{currentRow}"].Value = trafico.Aduana;
worksheet.Cells[$"J{currentRow}"].Value = trafico.Pedimento;
worksheet.Cells[$"K{currentRow}"].Value = trafico.FechaPago;
worksheet.Cells[$"L{currentRow}"].Value = trafico.FechaDesaduanamiento;
worksheet.Cells[$"M{currentRow}"].Value = trafico.UltimaActualizacion;
currentRow++;
}
ExcelRange range = worksheet.Cells[1, 1,traficos.Count() + 1, 13];
ExcelTable tab = worksheet.Tables.Add(range, "Table1");
tab.TableStyle = TableStyles.Light1;
worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
excelPackage.Workbook.Calculate();
var stream = new MemoryStream();
excelPackage.SaveAs(stream);
stream.Position = 0;
return stream;
}
}catch(Exception ex){
throw new Exception(ex.Message);
}
}
}
}

@ -8,6 +8,7 @@
"Microsoft.AspNetCore": "Warning"
}
},
"DataDisk":"C:\\",
"EmailServer": "gemcousa-com.mail.protection.outlook.com",
"EmailPort": 25,
"pathArchivoElectronico": "C:\\downs\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\",

@ -8,6 +8,7 @@
"Microsoft.AspNetCore": "Warning"
}
},
"DataDisk":"D:\\",
"EmailServer": "gemcousa-com.mail.protection.outlook.com",
"EmailPort": 25,
"pathArchivoElectronico": "D:\\data\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\",

@ -19,6 +19,7 @@
"Subject": "JWTServiceAccessToken",
"ExpirationHours": 4
},
"DataDisk":"D:\\",
"EmailServer": "gemcousa-com.mail.protection.outlook.com",
"EmailPort": 25,
"pathArchivoElectronico": "D:\\data\\ArchivoElectronicoSIR\\www.gemcousa.com\\SIR-GEMCO\\DOCS-SIR\\",

@ -12,7 +12,7 @@
</aspNetCore>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="62914561" />
<requestLimits maxAllowedContentLength="209715200" />
</requestFiltering>
</security>
</system.webServer>

Loading…
Cancel
Save