parent
7f35bc9d02
commit
b5eba08ffa
@ -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,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,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; } |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue