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

feature/ReportesContabilidad_FacturasTraficosConsolidadosAlen_20240116
Felix Morales 9 months ago
parent c5afa9e7b7
commit b32321ea86
  1. 24
      Controllers/Corresponsalias/TraficosController.cs

@ -9,6 +9,7 @@ using CORRESPONSALBackend.Repository.Corresponsalias;
using CORRESPONSALBackend.DTO.Reportes;
using CORRESPONSALBackend.Contracts.Corresponsalias.Services;
using CORRESPONSALBackend.Contracts.Catalogos;
using System.Globalization;
namespace CORRESPONSALBackend.Controllers.Corresponsalias
{
@ -164,17 +165,20 @@ namespace CORRESPONSALBackend.Controllers.Corresponsalias
var proveedores = await _proveedoresRepository.GetAll(0);
proveedores.ToList();
var facturas = await _traficosService.ReadTxtFacturasAlen(fileId);
{
trafico.Pedimento = int.Parse(facturas[0][6]);
trafico.FechaPago = DateTime.Parse(facturas[0][7]).ToString("yyyy/MM/dd");
trafico.Clave = facturas[0][8];
trafico.TipoCambio = double.Parse(facturas[0][15]);
trafico.CantidadFracciones = int.Parse(facturas[0][21]);
trafico.DescripcionMercancia = facturas[0][14];
trafico.Observaciones = facturas[0][48];
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 facturas){
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,
@ -204,7 +208,7 @@ namespace CORRESPONSALBackend.Controllers.Corresponsalias
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){

Loading…
Cancel
Save