diff --git a/Contracts/Reportes/Embarques/IReportesEmbarquesRepository.cs b/Contracts/Reportes/Embarques/IReportesEmbarquesRepository.cs new file mode 100644 index 0000000..1982acd --- /dev/null +++ b/Contracts/Reportes/Embarques/IReportesEmbarquesRepository.cs @@ -0,0 +1,9 @@ +using CORRESPONSALBackend.DTO.Reportes.Embarques; + +namespace CORRESPONSALBackend.Contracts.Reportes.Embarques{ + public interface IReportesEmbarquesRepository { + public Task> GetReporteEmbarquesPorImportar(); + public Task> GetReporteEmbarquesDespachados(DateTime inicio, DateTime fin); + public Task> BuscarEmbarques(string filtro); + } +} \ No newline at end of file diff --git a/Controllers/FileManagerController.cs b/Controllers/FileManagerController.cs index 5167d63..bf0ced4 100644 --- a/Controllers/FileManagerController.cs +++ b/Controllers/FileManagerController.cs @@ -360,5 +360,19 @@ namespace CORRESPONSALBackend.Controllers return BadRequest(ex.Message); } } + + + [HttpGet("GetFileById")] + public async Task GetFileById([FromQuery] int fileId){ + var fileLog = await _Repo.getFileById(fileId); + var relativePath = await _RepoRelativePath.getPaths4ProcessById(fileLog.Proceso); + var filePath = RootPathCorresponsales + relativePath.Path + fileLog.NombreArchivo; + if(System.IO.File.Exists(filePath)){ + byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); + MemoryStream fileStream = new MemoryStream(fileBytes); + return File(fileStream, "application/pdf", fileLog.NombreArchivo); + } + return Ok(); + } } } \ No newline at end of file diff --git a/Controllers/Reportes/ReportesEmbarquesController.cs b/Controllers/Reportes/ReportesEmbarquesController.cs new file mode 100644 index 0000000..f54195c --- /dev/null +++ b/Controllers/Reportes/ReportesEmbarquesController.cs @@ -0,0 +1,54 @@ +using System.Drawing; +using CORRESPONSALBackend.Contracts.Reportes.Embarques; +using CORRESPONSALBackend.DTO.Reportes.Embarques; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using OfficeOpenXml; + +namespace CORRESPONSALBackend.Controllers.Reportes{ + [Authorize] + [Route("api/[controller]")] + [ApiController] + public class ReportesEmbarquesController : ControllerBase{ + private readonly IReportesEmbarquesRepository _repo; + + public ReportesEmbarquesController(IReportesEmbarquesRepository repo){ + _repo = repo; + } + + [HttpGet("PorImportar")] + public async Task> GetReporteEmbarquesPorImportar(){ + var embarques = await _repo.GetReporteEmbarquesPorImportar(); + return embarques; + } + + [HttpGet("Despachados")] + public async Task> GetReporteEmbarquesDespachados([FromQuery] DateTime inicio, [FromQuery] DateTime fin){ + var embarques = await _repo.GetReporteEmbarquesDespachados(inicio, fin); + return embarques; + } + + [HttpGet("BuscarEmbarques")] + public async Task> BuscarEmbarques([FromQuery] string filtro){ + var embarques = await _repo.BuscarEmbarques(filtro); + return embarques; + } + + [HttpGet("ExcelEmbarquesPorImportar")] + public async Task GetExcelEmbarquesPorImportar(){ + var embarques = await _repo.GetReporteEmbarquesPorImportar(); + using (ExcelPackage excelPackage = new ExcelPackage()){ + ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + var today = new DateTime(); + var worksheet = excelPackage.Workbook.Worksheets.Add($"EmbarquesPorImportar_{today.Day-today.Month-today.Year}"); + worksheet.Cells["A1:A6"].Merge = true; + Image image = Image.FromFile("C:\\data\\Corresponsales\\Img\\LogoGemco.png"); + worksheet.Column(2).Width = 194; + worksheet.Column(3).Width = 144; + worksheet.Column(4).Width = 143; + worksheet.Cells["B1:B6"].Merge = true; + } + return Ok(); + } + } +} \ No newline at end of file diff --git a/DTO/Reportes/Embarques/DTOBuscarEmbarques.cs b/DTO/Reportes/Embarques/DTOBuscarEmbarques.cs new file mode 100644 index 0000000..d53d0af --- /dev/null +++ b/DTO/Reportes/Embarques/DTOBuscarEmbarques.cs @@ -0,0 +1,45 @@ +namespace CORRESPONSALBackend.DTO.Reportes.Embarques{ + public class DTOBuscarEmbarques{ + public int Id { get; set; } + public string Aduana { get; set; } + public string TipoEmbarque { get; set; } + public string Destino { get; set; } + public int DiasEnAduana { get; set; } + public string Nombre { get; set; } + public string NoPedimento { get; set; } + public string Tipo { get; set; } + public string OrdenCompra { get; set; } + public string Factura { get; set; } + public string Proveedor { get; set; } + public string DescripcionMercancia { get; set; } + public int Bultos { get; set; } + public int CantidadContenedores { get; set; } + public int PesoNeto { get; set; } + public string Incoterm { get; set; } + public string? FechaETA { get; set; } + public string Estatus { get; set; } + public string Observaciones { get; set; } + public string FechaInicioGastosAlmacenaje { get; set; } + public int CostoDiarioAlmacenaje { get; set; } + public int CostoDiarioConexion { get; set; } + public int TotalPagar { get; set; } + public int TotalPagarConexion { get; set; } + public string? FechaDespacho { get; set; } + public string NombrePaqueteria { get; set; } + public string NoGuiaEmbarqueDestino { get; set; } + public string? FechaEntregaDestinoFinal { get; set; } + public int FacturaCorresponsal { get; set; } + public int CertificadoCalidad { get; set; } + public int PackingList { get; set; } + public int HojaTecnica { get; set; } + public int BL { get; set; } + public int PedimentoInformativo { get; set; } + public int PedimentoSimplificado { get; set; } + public int DODA { get; set; } + public int Honorarios { get; set; } + public int TotalHonorarios { get; set; } + public int GastosTerceros { get; set; } + public int TotalGastosTerceros { get; set; } + public int ComprobantesGastosTerceros { get; set; } + } +} \ No newline at end of file diff --git a/DTO/Reportes/Embarques/DTOEmbarquesDespachados.cs b/DTO/Reportes/Embarques/DTOEmbarquesDespachados.cs new file mode 100644 index 0000000..fc3560a --- /dev/null +++ b/DTO/Reportes/Embarques/DTOEmbarquesDespachados.cs @@ -0,0 +1,69 @@ +namespace CORRESPONSALBackend.DTO.Reportes.Embarques{ + public class DTOEmbarquesDespachados{ + public int Id { get; set; } + public string Aduana { get; set; } + public string TipoEmbarque { get; set; } + public string Destino { get; set; } + public int DiasEnAduana { get; set; } + public string Nombre { get; set; } + public string Trafico { get; set; } + public string Referencia {get;set;} + public string NoPedimento { get; set; } + public string ClavePedimento { get; set; } + public string Tipo { get; set; } + public string OrdenCompra { get; set; } + public string Factura { get; set; } + public string Proveedor { get; set; } + public string DescripcionMercancia { get; set; } + public string LineaTransportistaInternacional { get; set; } + public string LineaNaviera { get; set; } + public string MAWB { get; set; } + public string HAWB { get; set; } + public string? FechaNotificacion { get; set; } + public int Bultos { get; set; } + public int CantidadContenedores { get; set; } + public string NumerosContenedores { get; set; } + public int PesoBruto { get; set; } + public int PesoNeto { get; set; } + public string Incoterm { get; set; } + public string? FechaETA { get; set; } + public string? FechaEntrada {get;set;} + public string? FechaRevalidacionGuia { get; set; } + public double MontoUSD { get; set; } + public string Origen { get; set; } + public string FraccionArancelaria { get; set; } + public string Descripcion { get; set; } + public string PreferenciaArancelaria { get; set; } + public string Estatus { get; set; } + public string Observaciones { get; set; } + public string FechaInicioGastosAlmacenaje { get; set; } + public int CostoDiarioAlmacenaje { get; set; } + public int CostoDiarioConexion { get; set; } + public int TotalPagar { get; set; } + public int TotalPagarConexion { get; set; } + public string? FechaPagoPedimento { get; set; } + public string? FechaInstrucciones { get; set; } + public TimeSpan? HoraInstrucciones { get; set; } + public string? FechaDespacho { get; set; } + public int DiasCPPagado {get;set;} + public string? FechaSalidaContenedores { get; set; } + public string NombrePaqueteria { get; set; } + public string NoGuiaEmbarqueDestino { get; set; } + public string? FechaEntregaDestinoFinal { get; set; } + public TimeSpan? HoraEntregaDestinoFinal { get; set; } + public int FacturaCorresponsal { get; set; } + public int CertificadoCalidad { get; set; } + public int PackingList { get; set; } + public int HojaTecnica { get; set; } + public int BL { get; set; } + public int PedimentoInformativo { get; set; } + public int PedimentoSimplificado { get; set; } + public int DODA { get; set; } + public int Honorarios { get; set; } + public int TotalHonorarios { get; set; } + public int GastosTerceros { get; set; } + public int TotalGastosTerceros { get; set; } + public int ComprobantesGastosTerceros { get; set; } + public int PruebaEntrega { get; set; } + } +} \ No newline at end of file diff --git a/DTO/Reportes/Embarques/DTOEmbarquesPorImportar.cs b/DTO/Reportes/Embarques/DTOEmbarquesPorImportar.cs new file mode 100644 index 0000000..08ee06e --- /dev/null +++ b/DTO/Reportes/Embarques/DTOEmbarquesPorImportar.cs @@ -0,0 +1,63 @@ +namespace CORRESPONSALBackend.DTO.Reportes.Embarques{ + public class DTOEmbarquesPorImportar{ + public int Id { get; set; } + public string Aduana { get; set; } + public string TipoEmbarque { get; set; } + public string Destino { get; set; } + public int DiasEnAduana { get; set; } + public string Nombre { get; set; } + public string Trafico { get; set; } + public string Referencia {get;set;} + public string NoPedimento { get; set; } + public string ClavePedimento { get; set; } + public string Tipo { get; set; } + public string OrdenCompra { get; set; } + public string Factura { get; set; } + public string Proveedor { get; set; } + public string DescripcionMercancia { get; set; } + public string LineaTransportistaInternacional { get; set; } + public string LineaNaviera { get; set; } + public string MAWB { get; set; } + public string HAWB { get; set; } + public string? FechaNotificacion { get; set; } + public int Bultos { get; set; } + public int CantidadContenedores { get; set; } + public string NumerosContenedores { get; set; } + public int PesoBruto { get; set; } + public int PesoNeto { get; set; } + public string Incoterm { get; set; } + public string? FechaETA { get; set; } + public string? FechaEntrada {get;set;} + public string? FechaRevalidacionGuia { get; set; } + public double MontoUSD { get; set; } + public string Origen { get; set; } + public string FraccionArancelaria { get; set; } + public string Descripcion { get; set; } + public string PreferenciaArancelaria { get; set; } + public string Estatus { get; set; } + public string Observaciones { get; set; } + public string FechaInicioGastosAlmacenaje { get; set; } + public int CostoDiarioAlmacenaje { get; set; } + public int CostoDiarioConexion { get; set; } + public int TotalPagar { get; set; } + public int TotalPagarConexion { get; set; } + public string? FechaPagoPedimento { get; set; } + public string? FechaInstrucciones { get; set; } + public TimeSpan? HoraInstrucciones { get; set; } + public string? FechaDespacho { get; set; } + public int DiasCPPagado {get;set;} + public string? FechaSalidaContenedores { get; set; } + public string NombrePaqueteria { get; set; } + public string NoGuiaEmbarqueDestino { get; set; } + public string? FechaEntregaDestinoFinal { get; set; } + public TimeSpan? HoraEntregaDestinoFinal { get; set; } + public int FacturaCorresponsal { get; set; } + public int CertificadoCalidad { get; set; } + public int PackingList { get; set; } + public int HojaTecnica { get; set; } + public int BL { get; set; } + public int PedimentoInformativo { get; set; } + public int PedimentoSimplificado { get; set; } + public int DODA { get; set; } + } +} \ No newline at end of file diff --git a/Models/Corresponsales/CorresponsalPedimento.cs b/Models/Corresponsales/CorresponsalPedimento.cs index c8f4f38..2d663cc 100644 --- a/Models/Corresponsales/CorresponsalPedimento.cs +++ b/Models/Corresponsales/CorresponsalPedimento.cs @@ -35,5 +35,10 @@ namespace CORRESPONSALBackend.Models.Corresponsales public int TipoEmbarque { get; set; } public double TotalPagar { get; set; } public byte Activo { get; set; } = 1; + public string FraccionArancelaria { get; set; } = null!; + public string LineaNaviera { get; set; } = null!; + public string FNotificacion { get; set; } = null!; + public double CostoDiarioConexion { get; set; } + public double TotalPagarConexion { get; set; } } } \ No newline at end of file diff --git a/Models/Corresponsales/ITrafico.cs b/Models/Corresponsales/ITrafico.cs index 4563de1..1732f58 100644 --- a/Models/Corresponsales/ITrafico.cs +++ b/Models/Corresponsales/ITrafico.cs @@ -44,5 +44,7 @@ public int? idTipoMercancia {get;set;} = null; public int CargoA {get;set;} = 0; public string CausaRectificacion {get;set;} = ""; + public double TotalHonorariosAA { get; set; } + public double TotalGastosTerceros { get; set; } } } diff --git a/Program.cs b/Program.cs index dc9bb6e..a6618b1 100644 --- a/Program.cs +++ b/Program.cs @@ -32,6 +32,8 @@ using CORRESPONSALBackend.Contracts.Reportes.Newell.Mensual; using CORRESPONSALBackend.Services.Reportes.Newell.Mensual; using CORRESPONSALBackend.Contracts.Auth; using CORRESPONSALBackend.Services.Auth; +using CORRESPONSALBackend.Contracts.Reportes.Embarques; +using CORRESPONSALBackend.Repository.Reportes.Embarques; var builder = WebApplication.CreateBuilder(args); @@ -46,6 +48,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); // Corresponsalias builder.Services.AddScoped(); diff --git a/Repository/Corresponsalias/CorresponsaliasPedimentoRepository.cs b/Repository/Corresponsalias/CorresponsaliasPedimentoRepository.cs index 4738ec4..38ebf16 100644 --- a/Repository/Corresponsalias/CorresponsaliasPedimentoRepository.cs +++ b/Repository/Corresponsalias/CorresponsaliasPedimentoRepository.cs @@ -50,7 +50,12 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias @PreferenciaArancelaria = data.PreferenciaArancelaria, @Seguros = data.Seguros, @TipoEmbarque = data.TipoEmbarque, - @TotalPagar = data.TotalPagar + @TotalPagar = data.TotalPagar, + @LineaNaviera = data.LineaNaviera, + @FNotificacion = data.FNotificacion, + @FraccionArancelaria = data.FraccionArancelaria, + @CostoDiarioConexion = data.CostoDiarioConexion, + @TotalPagarConexion = data.TotalPagarConexion }, commandType: CommandType.StoredProcedure); return entrada.First(); diff --git a/Repository/Corresponsalias/CorresponsaliasTraficosRepository.cs b/Repository/Corresponsalias/CorresponsaliasTraficosRepository.cs index ce11ec8..8eaf9c5 100644 --- a/Repository/Corresponsalias/CorresponsaliasTraficosRepository.cs +++ b/Repository/Corresponsalias/CorresponsaliasTraficosRepository.cs @@ -115,7 +115,9 @@ namespace CORRESPONSALBackend.Repository.Corresponsalias @IdTabulador = data.IdTabulador, @IdTipoMercancia = data.idTipoMercancia, @CargoA = data.CargoA, - @CausaRectificacion = data.CausaRectificacion + @CausaRectificacion = data.CausaRectificacion, + @TotalHonorariosAA = data.TotalHonorariosAA, + @TotalGastosTerceros = data.TotalGastosTerceros }, commandType: CommandType.StoredProcedure); return entrada.First(); diff --git a/Repository/Reportes/Embarques/ReportesEmbarquesRepository.cs b/Repository/Reportes/Embarques/ReportesEmbarquesRepository.cs new file mode 100644 index 0000000..8eb9da3 --- /dev/null +++ b/Repository/Reportes/Embarques/ReportesEmbarquesRepository.cs @@ -0,0 +1,35 @@ +using System.Data; +using CORRESPONSALBackend.Context; +using CORRESPONSALBackend.Contracts.Reportes.Embarques; +using CORRESPONSALBackend.DTO.Reportes.Embarques; +using Dapper; + +namespace CORRESPONSALBackend.Repository.Reportes.Embarques{ + public class ReportesEmbarquesRepository : IReportesEmbarquesRepository + { + private readonly DapperContext _context; + public ReportesEmbarquesRepository(DapperContext context) { _context = context; } + + public async Task> GetReporteEmbarquesPorImportar() + { + var query = "[Reportes.Embarques.GetPorImportar]"; + var connection = _context.CreateConnection(); + var embarques = await connection.QueryAsync(query, new {}, commandType: CommandType.StoredProcedure); + return embarques.ToList(); + } + public async Task> GetReporteEmbarquesDespachados(DateTime inicio, DateTime fin) + { + var query = "[Reportes.Embarques.GetDespachados]"; + var connection = _context.CreateConnection(); + var embarques = await connection.QueryAsync(query, new {@inicio = inicio, @fin = fin}, commandType: CommandType.StoredProcedure); + return embarques.ToList(); + } + public async Task> BuscarEmbarques(string filtro) + { + var query = "[Reportes.Embarques.BuscarEmbarques]"; + var connection = _context.CreateConnection(); + var embarques = await connection.QueryAsync(query, new {@Filtro = filtro}, commandType: CommandType.StoredProcedure); + return embarques.ToList(); + } + } +} \ No newline at end of file