feat(reportes): Permite consulta consolidada en Detalle de Distribución
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 2m34s
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 2m34s
Implementa la funcionalidad para generar el reporte "Detalle de Distribución de Canillas" de forma consolidada para todas las empresas, separando entre Canillitas y Accionistas. Adicionalmente, se realizan correcciones y mejoras visuales en otros reportes.
### Cambios Principales
- **Frontend (`ReporteDetalleDistribucionCanillasPage`):**
- Se añade la opción "TODAS" al selector de Empresas.
- Al seleccionar "TODAS", se muestra un nuevo control para elegir entre "Canillitas" o "Accionistas".
- La vista del reporte se simplifica en el modo "TODAS", mostrando solo la tabla correspondiente y ocultando el resumen por tipo de vendedor.
- **Backend (`ReportesService`, `ReportesRepository`):**
- Se modifica el servicio para recibir el parámetro `esAccionista`.
- Se implementa una nueva lógica que, si `idEmpresa` es 0, llama a los nuevos procedimientos almacenados que consultan todas las empresas.
- Se ajusta el `ReportesController` para aceptar y pasar el nuevo parámetro.
### Correcciones
- **Base de Datos:**
- Se añade la función SQL `FN_ObtenerPrecioVigente` para los nuevos Stored Procedures.
- Se crean los Stored Procedures `SP_DistCanillasEntradaSalidaPubli_AllEmpresas` y `SP_DistCanillasAccEntradaSalidaPubli_AllEmpresas`.
- **Backend (`ReportesController`):**
- Se corrigen errores de compilación (`CS7036`, `CS8130`) añadiendo el parámetro `esAccionista` faltante en las llamadas al servicio `ObtenerReporteDistribucionCanillasAsync`.
### Mejoras Visuales
- **PDF (`ControlDevolucionesDocument.cs`):**
- Se ajustan los espaciados verticales (`Padding` y `Spacing`) en la plantilla QuestPDF del reporte "Control de Devoluciones" para lograr un diseño más compacto.
This commit is contained in:
@@ -41,9 +41,11 @@ namespace GestionIntegral.Api.Controllers.Reportes.PdfTemplates
|
|||||||
|
|
||||||
void ComposeContent(IContainer container)
|
void ComposeContent(IContainer container)
|
||||||
{
|
{
|
||||||
container.PaddingTop(1, Unit.Centimetre).Column(column =>
|
// << CAMBIO: Reducido el padding superior de 1cm a 5mm >>
|
||||||
|
container.PaddingTop(5, Unit.Millimetre).Column(column =>
|
||||||
{
|
{
|
||||||
column.Spacing(15);
|
// << CAMBIO: Reducido el espaciado principal entre elementos de 15 a 10 puntos >>
|
||||||
|
column.Spacing(10);
|
||||||
|
|
||||||
column.Item().Row(row =>
|
column.Item().Row(row =>
|
||||||
{
|
{
|
||||||
@@ -59,23 +61,24 @@ namespace GestionIntegral.Api.Controllers.Reportes.PdfTemplates
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
column.Item().PaddingTop(5).Border(1).Background(Colors.Grey.Lighten3).AlignCenter().Padding(2).Text(Model.NombreEmpresa).SemiBold();
|
column.Item().PaddingTop(3).Border(1).Background(Colors.Grey.Lighten3).AlignCenter().Padding(2).Text(Model.NombreEmpresa).SemiBold();
|
||||||
|
|
||||||
column.Item().Border(1).Padding(10).Column(innerCol =>
|
column.Item().Border(1).Padding(8).Column(innerCol => // << CAMBIO: Padding reducido de 10 a 8 >>
|
||||||
{
|
{
|
||||||
innerCol.Spacing(5);
|
// << CAMBIO: Reducido el espaciado interno de 5 a 4 >>
|
||||||
|
innerCol.Spacing(4);
|
||||||
|
|
||||||
// Fila de "Ingresados por Remito" con borde inferior sólido.
|
|
||||||
innerCol.Item().BorderBottom(1, Unit.Point).BorderColor(Colors.Grey.Medium).Row(row =>
|
innerCol.Item().BorderBottom(1, Unit.Point).BorderColor(Colors.Grey.Medium).Row(row =>
|
||||||
{
|
{
|
||||||
row.RelativeItem().Text("Ingresados por Remito:").SemiBold();
|
row.RelativeItem().Text("Ingresados por Remito:").SemiBold();
|
||||||
row.RelativeItem().AlignRight().Text(Model.TotalIngresadosPorRemito.ToString("N0"));
|
row.RelativeItem().AlignRight().Text(Model.TotalIngresadosPorRemito.ToString("N0"));
|
||||||
}); // <-- SOLUCIÓN: Borde sólido simple.
|
});
|
||||||
|
|
||||||
foreach (var item in Model.Detalles)
|
foreach (var item in Model.Detalles)
|
||||||
{
|
{
|
||||||
var totalSeccion = item.Devueltos - item.Llevados;
|
var totalSeccion = item.Devueltos - item.Llevados;
|
||||||
innerCol.Item().PaddingTop(5).Row(row =>
|
// << CAMBIO: Reducido el padding superior de 5 a 3 >>
|
||||||
|
innerCol.Item().PaddingTop(3).Row(row =>
|
||||||
{
|
{
|
||||||
row.ConstantItem(100).Text(item.Tipo).SemiBold();
|
row.ConstantItem(100).Text(item.Tipo).SemiBold();
|
||||||
|
|
||||||
@@ -90,7 +93,8 @@ namespace GestionIntegral.Api.Controllers.Reportes.PdfTemplates
|
|||||||
r.RelativeItem().Text("Devueltos");
|
r.RelativeItem().Text("Devueltos");
|
||||||
r.RelativeItem().AlignRight().Text($"{item.Devueltos:N0}");
|
r.RelativeItem().AlignRight().Text($"{item.Devueltos:N0}");
|
||||||
});
|
});
|
||||||
sub.Item().BorderTop(1.5f).BorderColor(Colors.Black).PaddingTop(2).Row(r => {
|
// << CAMBIO: Reducido el padding superior de 2 a 1 >>
|
||||||
|
sub.Item().BorderTop(1.5f).BorderColor(Colors.Black).PaddingTop(1).Row(r => {
|
||||||
r.RelativeItem().Text(t => t.Span("Total").SemiBold());
|
r.RelativeItem().Text(t => t.Span("Total").SemiBold());
|
||||||
r.RelativeItem().AlignRight().Text(t => t.Span(totalSeccion.ToString("N0")).SemiBold());
|
r.RelativeItem().AlignRight().Text(t => t.Span(totalSeccion.ToString("N0")).SemiBold());
|
||||||
});
|
});
|
||||||
@@ -99,7 +103,8 @@ namespace GestionIntegral.Api.Controllers.Reportes.PdfTemplates
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
column.Item().PaddingTop(10).Column(finalCol =>
|
// << CAMBIO: Reducido el padding superior de 10 a 8 >>
|
||||||
|
column.Item().PaddingTop(8).Column(finalCol =>
|
||||||
{
|
{
|
||||||
finalCol.Spacing(2);
|
finalCol.Spacing(2);
|
||||||
|
|
||||||
@@ -112,13 +117,15 @@ namespace GestionIntegral.Api.Controllers.Reportes.PdfTemplates
|
|||||||
if (isBold) valueText.SemiBold();
|
if (isBold) valueText.SemiBold();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Usamos bordes superiores para separar las líneas de total
|
// << CAMBIO: Reducido el padding superior de 2 a 1 en las siguientes líneas >>
|
||||||
finalCol.Item().BorderTop(2f).BorderColor(Colors.Black).PaddingTop(2).Row(row => AddTotalRow(row, "Total Devolución a la Fecha", Model.TotalDevolucionALaFecha.ToString("N0"), false));
|
finalCol.Item().BorderTop(2f).BorderColor(Colors.Black).PaddingTop(1).Row(row => AddTotalRow(row, "Total Devolución a la Fecha", Model.TotalDevolucionALaFecha.ToString("N0"), false));
|
||||||
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(2).Row(row => AddTotalRow(row, "Total Devolución Días Anteriores", Model.TotalDevolucionDiasAnteriores.ToString("N0"), false));
|
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(1).Row(row => AddTotalRow(row, "Total Devolución Días Anteriores", Model.TotalDevolucionDiasAnteriores.ToString("N0"), false));
|
||||||
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(2).Row(row => AddTotalRow(row, "Total Devolución", Model.TotalDevolucionGeneral.ToString("N0"), false));
|
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(1).Row(row => AddTotalRow(row, "Total Devolución", Model.TotalDevolucionGeneral.ToString("N0"), false));
|
||||||
finalCol.Item().BorderTop(2f).BorderColor(Colors.Black).PaddingTop(5).Row(row => AddTotalRow(row, "Sin Cargo", Model.TotalSinCargo.ToString("N0"), false));
|
// << CAMBIO: Reducido el padding superior de 5 a 3 >>
|
||||||
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(2).Row(row => AddTotalRow(row, "Sobrantes", $"-{Model.TotalSobrantes.ToString("N0")}", false));
|
finalCol.Item().BorderTop(2f).BorderColor(Colors.Black).PaddingTop(3).Row(row => AddTotalRow(row, "Sin Cargo", Model.TotalSinCargo.ToString("N0"), false));
|
||||||
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).BorderBottom(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(5).Row(row => AddTotalRow(row, "Diferencia", Model.DiferenciaFinal.ToString("N0"), true));
|
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(1).Row(row => AddTotalRow(row, "Sobrantes", $"-{Model.TotalSobrantes.ToString("N0")}", false));
|
||||||
|
// << CAMBIO: Reducido el padding superior de 5 a 3 >>
|
||||||
|
finalCol.Item().BorderTop(1).BorderColor(Colors.Grey.Lighten2).BorderBottom(1).BorderColor(Colors.Grey.Lighten2).PaddingTop(3).Row(row => AddTotalRow(row, "Diferencia", Model.DiferenciaFinal.ToString("N0"), true));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -678,13 +678,18 @@ namespace GestionIntegral.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<IActionResult> GetReporteDistribucionCanillasData([FromQuery] DateTime fecha, [FromQuery] int idEmpresa)
|
public async Task<IActionResult> GetReporteDistribucionCanillasData(
|
||||||
|
[FromQuery] DateTime fecha,
|
||||||
|
[FromQuery] int idEmpresa,
|
||||||
|
[FromQuery] bool? esAccionista
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!TienePermiso(PermisoVerComprobanteLiquidacionCanilla)) return Forbid();
|
if (!TienePermiso(PermisoVerComprobanteLiquidacionCanilla)) return Forbid();
|
||||||
|
|
||||||
|
// Pasar el nuevo parámetro al servicio
|
||||||
var (canillas, canillasAcc, canillasAll, canillasFechaLiq, canillasAccFechaLiq,
|
var (canillas, canillasAcc, canillasAll, canillasFechaLiq, canillasAccFechaLiq,
|
||||||
ctrlDevolucionesRemitos, ctrlDevolucionesParaDistCan, ctrlDevolucionesOtrosDias, error) =
|
ctrlDevolucionesRemitos, ctrlDevolucionesParaDistCan, ctrlDevolucionesOtrosDias, error) =
|
||||||
await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa);
|
await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa, esAccionista);
|
||||||
|
|
||||||
if (error != null) return BadRequest(new { message = error });
|
if (error != null) return BadRequest(new { message = error });
|
||||||
|
|
||||||
@@ -719,14 +724,20 @@ namespace GestionIntegral.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<IActionResult> GetReporteDistribucionCanillasPdf([FromQuery] DateTime fecha, [FromQuery] int idEmpresa, [FromQuery] bool soloTotales = false)
|
public async Task<IActionResult> GetReporteDistribucionCanillasPdf(
|
||||||
|
[FromQuery] DateTime fecha,
|
||||||
|
[FromQuery] int idEmpresa,
|
||||||
|
[FromQuery] bool? esAccionista,
|
||||||
|
[FromQuery] bool soloTotales = false
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!TienePermiso(PermisoVerComprobanteLiquidacionCanilla)) return Forbid();
|
if (!TienePermiso(PermisoVerComprobanteLiquidacionCanilla)) return Forbid();
|
||||||
|
|
||||||
|
// Pasar el nuevo parámetro al servicio
|
||||||
var (
|
var (
|
||||||
canillas, canillasAcc, canillasAll, canillasFechaLiq, canillasAccFechaLiq,
|
canillas, canillasAcc, canillasAll, canillasFechaLiq, canillasAccFechaLiq,
|
||||||
remitos, ctrlDevoluciones, _, error
|
remitos, ctrlDevoluciones, _, error
|
||||||
) = await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa);
|
) = await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa, esAccionista);
|
||||||
|
|
||||||
if (error != null) return BadRequest(new { message = error });
|
if (error != null) return BadRequest(new { message = error });
|
||||||
|
|
||||||
@@ -795,11 +806,11 @@ namespace GestionIntegral.Api.Controllers
|
|||||||
_, // canillasAll
|
_, // canillasAll
|
||||||
_, // canillasFechaLiq
|
_, // canillasFechaLiq
|
||||||
_, // canillasAccFechaLiq
|
_, // canillasAccFechaLiq
|
||||||
ctrlDevolucionesRemitosData, // Para SP_ObtenerCtrlDevoluciones -> DataSet "DSObtenerCtrlDevoluciones"
|
ctrlDevolucionesRemitosData,
|
||||||
ctrlDevolucionesParaDistCanData, // Para SP_DistCanillasCantidadEntradaSalida -> DataSet "DSCtrlDevoluciones"
|
ctrlDevolucionesParaDistCanData,
|
||||||
ctrlDevolucionesOtrosDiasData, // Para SP_DistCanillasCantidadEntradaSalidaOtrosDias -> DataSet "DSCtrlDevolucionesOtrosDias"
|
ctrlDevolucionesOtrosDiasData,
|
||||||
error
|
error
|
||||||
) = await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa); // Reutilizamos este método
|
) = await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa, null);
|
||||||
|
|
||||||
if (error != null) return BadRequest(new { message = error });
|
if (error != null) return BadRequest(new { message = error });
|
||||||
|
|
||||||
@@ -833,7 +844,7 @@ namespace GestionIntegral.Api.Controllers
|
|||||||
var (
|
var (
|
||||||
_, _, _, _, _, // Datos no utilizados
|
_, _, _, _, _, // Datos no utilizados
|
||||||
remitos, detalles, otrosDias, error
|
remitos, detalles, otrosDias, error
|
||||||
) = await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa);
|
) = await _reportesService.ObtenerReporteDistribucionCanillasAsync(fecha, idEmpresa, null);
|
||||||
|
|
||||||
if (error != null) return BadRequest(new { message = error });
|
if (error != null) return BadRequest(new { message = error });
|
||||||
|
|
||||||
|
|||||||
@@ -48,5 +48,7 @@ namespace GestionIntegral.Api.Data.Repositories.Reportes
|
|||||||
Task<IEnumerable<FacturasParaReporteDto>> GetDatosReportePublicidadAsync(string periodo);
|
Task<IEnumerable<FacturasParaReporteDto>> GetDatosReportePublicidadAsync(string periodo);
|
||||||
Task<IEnumerable<DistribucionSuscripcionDto>> GetDistribucionSuscripcionesActivasAsync(DateTime fechaDesde, DateTime fechaHasta);
|
Task<IEnumerable<DistribucionSuscripcionDto>> GetDistribucionSuscripcionesActivasAsync(DateTime fechaDesde, DateTime fechaHasta);
|
||||||
Task<IEnumerable<DistribucionSuscripcionDto>> GetDistribucionSuscripcionesBajasAsync(DateTime fechaDesde, DateTime fechaHasta);
|
Task<IEnumerable<DistribucionSuscripcionDto>> GetDistribucionSuscripcionesBajasAsync(DateTime fechaDesde, DateTime fechaHasta);
|
||||||
|
Task<IEnumerable<DetalleDistribucionCanillaDto>> GetDetalleDistribucionCanillasPubli_AllEmpresasAsync(DateTime fecha);
|
||||||
|
Task<IEnumerable<DetalleDistribucionCanillaDto>> GetDetalleDistribucionCanillasAccPubli_AllEmpresasAsync(DateTime fecha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,5 +653,39 @@ namespace GestionIntegral.Api.Data.Repositories.Reportes
|
|||||||
return Enumerable.Empty<DistribucionSuscripcionDto>();
|
return Enumerable.Empty<DistribucionSuscripcionDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<DetalleDistribucionCanillaDto>> GetDetalleDistribucionCanillasPubli_AllEmpresasAsync(DateTime fecha)
|
||||||
|
{
|
||||||
|
const string spName = "dbo.SP_DistCanillasEntradaSalidaPubli_AllEmpresas";
|
||||||
|
var parameters = new DynamicParameters();
|
||||||
|
parameters.Add("@fecha", fecha, DbType.DateTime);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = _dbConnectionFactory.CreateConnection();
|
||||||
|
return await connection.QueryAsync<DetalleDistribucionCanillaDto>(spName, parameters, commandType: CommandType.StoredProcedure, commandTimeout: 120);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error SP {SPName}", spName);
|
||||||
|
return Enumerable.Empty<DetalleDistribucionCanillaDto>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<DetalleDistribucionCanillaDto>> GetDetalleDistribucionCanillasAccPubli_AllEmpresasAsync(DateTime fecha)
|
||||||
|
{
|
||||||
|
const string spName = "dbo.SP_DistCanillasAccEntradaSalidaPubli_AllEmpresas";
|
||||||
|
var parameters = new DynamicParameters();
|
||||||
|
parameters.Add("@fecha", fecha, DbType.DateTime);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = _dbConnectionFactory.CreateConnection();
|
||||||
|
return await connection.QueryAsync<DetalleDistribucionCanillaDto>(spName, parameters, commandType: CommandType.StoredProcedure, commandTimeout: 120);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error SP {SPName}", spName);
|
||||||
|
return Enumerable.Empty<DetalleDistribucionCanillaDto>();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UserSecretsId>4923d7ee-0944-456c-abcd-d6ce13ba8485</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -27,16 +27,16 @@ namespace GestionIntegral.Api.Services.Reportes
|
|||||||
|
|
||||||
// Reporte Distribucion Canillas (MC005) - Este es un reporte más complejo
|
// Reporte Distribucion Canillas (MC005) - Este es un reporte más complejo
|
||||||
Task<(
|
Task<(
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> Canillas,
|
IEnumerable<DetalleDistribucionCanillaDto> Canillas,
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> CanillasAcc,
|
IEnumerable<DetalleDistribucionCanillaDto> CanillasAcc,
|
||||||
IEnumerable<DetalleDistribucionCanillaAllDto> CanillasAll,
|
IEnumerable<DetalleDistribucionCanillaAllDto> CanillasAll,
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> CanillasFechaLiq,
|
IEnumerable<DetalleDistribucionCanillaDto> CanillasFechaLiq,
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> CanillasAccFechaLiq,
|
IEnumerable<DetalleDistribucionCanillaDto> CanillasAccFechaLiq,
|
||||||
IEnumerable<ObtenerCtrlDevolucionesDto> CtrlDevolucionesRemitos, // Para SP_ObtenerCtrlDevoluciones
|
IEnumerable<ObtenerCtrlDevolucionesDto> CtrlDevolucionesRemitos,
|
||||||
IEnumerable<ControlDevolucionesReporteDto> CtrlDevolucionesParaDistCan, // Para SP_DistCanillasCantidadEntradaSalida
|
IEnumerable<ControlDevolucionesReporteDto> CtrlDevolucionesParaDistCan,
|
||||||
IEnumerable<DevueltosOtrosDiasDto> CtrlDevolucionesOtrosDias, // <--- NUEVO para SP_DistCanillasCantidadEntradaSalidaOtrosDias
|
IEnumerable<DevueltosOtrosDiasDto> CtrlDevolucionesOtrosDias,
|
||||||
string? Error
|
string? Error
|
||||||
)> ObtenerReporteDistribucionCanillasAsync(DateTime fecha, int idEmpresa);
|
)> ObtenerReporteDistribucionCanillasAsync(DateTime fecha, int idEmpresa, bool? esAccionista);
|
||||||
|
|
||||||
// Reporte Tiradas por Publicación y Secciones (RR008)
|
// Reporte Tiradas por Publicación y Secciones (RR008)
|
||||||
Task<(IEnumerable<TiradasPublicacionesSeccionesDto> Data, string? Error)> ObtenerTiradasPublicacionesSeccionesAsync(int idPublicacion, DateTime fechaDesde, DateTime fechaHasta, int idPlanta);
|
Task<(IEnumerable<TiradasPublicacionesSeccionesDto> Data, string? Error)> ObtenerTiradasPublicacionesSeccionesAsync(int idPublicacion, DateTime fechaDesde, DateTime fechaHasta, int idPlanta);
|
||||||
|
|||||||
@@ -218,30 +218,66 @@ namespace GestionIntegral.Api.Services.Reportes
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(
|
public async Task<(
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> Canillas,
|
IEnumerable<DetalleDistribucionCanillaDto> Canillas,
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> CanillasAcc,
|
IEnumerable<DetalleDistribucionCanillaDto> CanillasAcc,
|
||||||
IEnumerable<DetalleDistribucionCanillaAllDto> CanillasAll,
|
IEnumerable<DetalleDistribucionCanillaAllDto> CanillasAll,
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> CanillasFechaLiq,
|
IEnumerable<DetalleDistribucionCanillaDto> CanillasFechaLiq,
|
||||||
IEnumerable<DetalleDistribucionCanillaDto> CanillasAccFechaLiq,
|
IEnumerable<DetalleDistribucionCanillaDto> CanillasAccFechaLiq,
|
||||||
IEnumerable<ObtenerCtrlDevolucionesDto> CtrlDevolucionesRemitos,
|
IEnumerable<ObtenerCtrlDevolucionesDto> CtrlDevolucionesRemitos,
|
||||||
IEnumerable<ControlDevolucionesReporteDto> CtrlDevolucionesParaDistCan,
|
IEnumerable<ControlDevolucionesReporteDto> CtrlDevolucionesParaDistCan,
|
||||||
IEnumerable<DevueltosOtrosDiasDto> CtrlDevolucionesOtrosDias,
|
IEnumerable<DevueltosOtrosDiasDto> CtrlDevolucionesOtrosDias,
|
||||||
string? Error
|
string? Error
|
||||||
)> ObtenerReporteDistribucionCanillasAsync(DateTime fecha, int idEmpresa)
|
)> ObtenerReporteDistribucionCanillasAsync(DateTime fecha, int idEmpresa, bool? esAccionista)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var canillasTask = _reportesRepository.GetDetalleDistribucionCanillasPubliAsync(fecha, idEmpresa);
|
// Función helper para convertir fechas a UTC
|
||||||
var canillasAccTask = _reportesRepository.GetDetalleDistribucionCanillasAccPubliAsync(fecha, idEmpresa);
|
Func<IEnumerable<DetalleDistribucionCanillaDto>, IEnumerable<DetalleDistribucionCanillaDto>> toUtc =
|
||||||
|
items => items?.Select(c => { if (c.Fecha.HasValue) c.Fecha = DateTime.SpecifyKind(c.Fecha.Value.Date, DateTimeKind.Utc); return c; }).ToList()
|
||||||
|
?? Enumerable.Empty<DetalleDistribucionCanillaDto>();
|
||||||
|
|
||||||
|
// --- NUEVA LÓGICA PARA "TODAS LAS EMPRESAS" ---
|
||||||
|
if (idEmpresa == 0)
|
||||||
|
{
|
||||||
|
Task<IEnumerable<DetalleDistribucionCanillaDto>> canillasTask = Task.FromResult(Enumerable.Empty<DetalleDistribucionCanillaDto>());
|
||||||
|
Task<IEnumerable<DetalleDistribucionCanillaDto>> canillasAccTask = Task.FromResult(Enumerable.Empty<DetalleDistribucionCanillaDto>());
|
||||||
|
|
||||||
|
if (esAccionista == true) // Solo accionistas
|
||||||
|
{
|
||||||
|
canillasAccTask = _reportesRepository.GetDetalleDistribucionCanillasAccPubli_AllEmpresasAsync(fecha);
|
||||||
|
}
|
||||||
|
else // Solo canillitas (o si es null, por defecto canillitas)
|
||||||
|
{
|
||||||
|
canillasTask = _reportesRepository.GetDetalleDistribucionCanillasPubli_AllEmpresasAsync(fecha);
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.WhenAll(canillasTask, canillasAccTask);
|
||||||
|
|
||||||
|
return (
|
||||||
|
toUtc(await canillasTask),
|
||||||
|
toUtc(await canillasAccTask),
|
||||||
|
Enumerable.Empty<DetalleDistribucionCanillaAllDto>(), // El resumen no aplica
|
||||||
|
Enumerable.Empty<DetalleDistribucionCanillaDto>(), // Liquidaciones de otras fechas no aplican en esta vista simplificada
|
||||||
|
Enumerable.Empty<DetalleDistribucionCanillaDto>(),
|
||||||
|
Enumerable.Empty<ObtenerCtrlDevolucionesDto>(), // Control de devoluciones no aplica
|
||||||
|
Enumerable.Empty<ControlDevolucionesReporteDto>(),
|
||||||
|
Enumerable.Empty<DevueltosOtrosDiasDto>(),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- LÓGICA ORIGINAL PARA UNA EMPRESA ESPECÍFICA ---
|
||||||
|
var canillasTaskOriginal = _reportesRepository.GetDetalleDistribucionCanillasPubliAsync(fecha, idEmpresa);
|
||||||
|
var canillasAccTaskOriginal = _reportesRepository.GetDetalleDistribucionCanillasAccPubliAsync(fecha, idEmpresa);
|
||||||
var canillasAllTask = _reportesRepository.GetDetalleDistribucionCanillasAllPubliAsync(fecha, idEmpresa);
|
var canillasAllTask = _reportesRepository.GetDetalleDistribucionCanillasAllPubliAsync(fecha, idEmpresa);
|
||||||
var canillasFechaLiqTask = _reportesRepository.GetDetalleDistribucionCanillasPubliFechaLiqAsync(fecha, idEmpresa);
|
var canillasFechaLiqTask = _reportesRepository.GetDetalleDistribucionCanillasPubliFechaLiqAsync(fecha, idEmpresa);
|
||||||
var canillasAccFechaLiqTask = _reportesRepository.GetDetalleDistribucionCanillasAccPubliFechaLiqAsync(fecha, idEmpresa);
|
var canillasAccFechaLiqTask = _reportesRepository.GetDetalleDistribucionCanillasAccPubliFechaLiqAsync(fecha, idEmpresa);
|
||||||
var ctrlDevolucionesRemitosTask = _reportesRepository.GetReporteObtenerCtrlDevolucionesAsync(fecha, idEmpresa); // SP_ObtenerCtrlDevoluciones
|
var ctrlDevolucionesRemitosTask = _reportesRepository.GetReporteObtenerCtrlDevolucionesAsync(fecha, idEmpresa);
|
||||||
var ctrlDevolucionesParaDistCanTask = _reportesRepository.GetReporteCtrlDevolucionesParaDistCanAsync(fecha, idEmpresa); // SP_DistCanillasCantidadEntradaSalida
|
var ctrlDevolucionesParaDistCanTask = _reportesRepository.GetReporteCtrlDevolucionesParaDistCanAsync(fecha, idEmpresa);
|
||||||
var ctrlDevolucionesOtrosDiasTask = _reportesRepository.GetEntradaSalidaOtrosDiasAsync(fecha, idEmpresa); // SP_DistCanillasCantidadEntradaSalidaOtrosDias
|
var ctrlDevolucionesOtrosDiasTask = _reportesRepository.GetEntradaSalidaOtrosDiasAsync(fecha, idEmpresa);
|
||||||
|
|
||||||
await Task.WhenAll(
|
await Task.WhenAll(
|
||||||
canillasTask, canillasAccTask, canillasAllTask,
|
canillasTaskOriginal, canillasAccTaskOriginal, canillasAllTask,
|
||||||
canillasFechaLiqTask, canillasAccFechaLiqTask,
|
canillasFechaLiqTask, canillasAccFechaLiqTask,
|
||||||
ctrlDevolucionesRemitosTask, ctrlDevolucionesParaDistCanTask,
|
ctrlDevolucionesRemitosTask, ctrlDevolucionesParaDistCanTask,
|
||||||
ctrlDevolucionesOtrosDiasTask
|
ctrlDevolucionesOtrosDiasTask
|
||||||
@@ -250,13 +286,9 @@ namespace GestionIntegral.Api.Services.Reportes
|
|||||||
var detallesOriginales = await ctrlDevolucionesParaDistCanTask ?? Enumerable.Empty<ControlDevolucionesReporteDto>();
|
var detallesOriginales = await ctrlDevolucionesParaDistCanTask ?? Enumerable.Empty<ControlDevolucionesReporteDto>();
|
||||||
var detallesOrdenados = detallesOriginales.OrderBy(d => d.Tipo).ToList();
|
var detallesOrdenados = detallesOriginales.OrderBy(d => d.Tipo).ToList();
|
||||||
|
|
||||||
Func<IEnumerable<DetalleDistribucionCanillaDto>, IEnumerable<DetalleDistribucionCanillaDto>> toUtc =
|
|
||||||
items => items?.Select(c => { if (c.Fecha.HasValue) c.Fecha = DateTime.SpecifyKind(c.Fecha.Value.Date, DateTimeKind.Utc); return c; }).ToList()
|
|
||||||
?? Enumerable.Empty<DetalleDistribucionCanillaDto>();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
toUtc(await canillasTask),
|
toUtc(await canillasTaskOriginal),
|
||||||
toUtc(await canillasAccTask),
|
toUtc(await canillasAccTaskOriginal),
|
||||||
await canillasAllTask ?? Enumerable.Empty<DetalleDistribucionCanillaAllDto>(),
|
await canillasAllTask ?? Enumerable.Empty<DetalleDistribucionCanillaAllDto>(),
|
||||||
toUtc(await canillasFechaLiqTask),
|
toUtc(await canillasFechaLiqTask),
|
||||||
toUtc(await canillasAccFechaLiqTask),
|
toUtc(await canillasAccFechaLiqTask),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import reportesService from '../../services/Reportes/reportesService';
|
|||||||
import type { ReporteDistribucionCanillasResponseDto } from '../../models/dtos/Reportes/ReporteDistribucionCanillasResponseDto';
|
import type { ReporteDistribucionCanillasResponseDto } from '../../models/dtos/Reportes/ReporteDistribucionCanillasResponseDto';
|
||||||
import SeleccionaReporteDetalleDistribucionCanillas from './SeleccionaReporteDetalleDistribucionCanillas';
|
import SeleccionaReporteDetalleDistribucionCanillas from './SeleccionaReporteDetalleDistribucionCanillas';
|
||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
|
import { usePermissions } from '../../hooks/usePermissions';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
// Para el tipo del footer en DataGridSectionProps
|
// Para el tipo del footer en DataGridSectionProps
|
||||||
@@ -81,9 +82,12 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
const [currentParams, setCurrentParams] = useState<{
|
const [currentParams, setCurrentParams] = useState<{
|
||||||
fecha: string;
|
fecha: string;
|
||||||
idEmpresa: number;
|
idEmpresa: number;
|
||||||
|
esAccionista: boolean;
|
||||||
nombreEmpresa?: string;
|
nombreEmpresa?: string;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
const [pdfSoloTotales, setPdfSoloTotales] = useState(false);
|
const [pdfSoloTotales, setPdfSoloTotales] = useState(false);
|
||||||
|
const { tienePermiso, isSuperAdmin } = usePermissions();
|
||||||
|
const puedeVerReporte = isSuperAdmin || tienePermiso("MC005");
|
||||||
|
|
||||||
const initialTotals: TotalesComunes = { totalCantSalida: 0, totalCantEntrada: 0, vendidos: 0, totalRendir: 0 };
|
const initialTotals: TotalesComunes = { totalCantSalida: 0, totalCantEntrada: 0, vendidos: 0, totalRendir: 0 };
|
||||||
const [totalesCanillas, setTotalesCanillas] = useState<TotalesComunes>(initialTotals);
|
const [totalesCanillas, setTotalesCanillas] = useState<TotalesComunes>(initialTotals);
|
||||||
@@ -115,16 +119,29 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
const handleGenerarReporte = useCallback(async (params: {
|
const handleGenerarReporte = useCallback(async (params: {
|
||||||
fecha: string;
|
fecha: string;
|
||||||
idEmpresa: number;
|
idEmpresa: number;
|
||||||
|
esAccionista: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
|
if (!puedeVerReporte) {
|
||||||
|
setError("No tiene permiso para generar este reporte.");
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
setApiErrorParams(null);
|
setApiErrorParams(null);
|
||||||
const empresaService = (await import('../../services/Distribucion/empresaService')).default;
|
|
||||||
const empData = await empresaService.getEmpresaById(params.idEmpresa);
|
|
||||||
setCurrentParams({ ...params, nombreEmpresa: empData?.nombre });
|
|
||||||
setReportData(null);
|
|
||||||
|
|
||||||
// Resetear totales
|
let nombreEmpresa = `Empresa ID ${params.idEmpresa}`;
|
||||||
|
if (params.idEmpresa !== 0) {
|
||||||
|
const empresaService = (await import('../../services/Distribucion/empresaService')).default;
|
||||||
|
const empData = await empresaService.getEmpresaById(params.idEmpresa);
|
||||||
|
nombreEmpresa = empData?.nombre ?? nombreEmpresa;
|
||||||
|
} else {
|
||||||
|
nombreEmpresa = "TODAS";
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentParams({ ...params, nombreEmpresa });
|
||||||
|
setReportData(null);
|
||||||
setTotalesCanillas(initialTotals);
|
setTotalesCanillas(initialTotals);
|
||||||
setTotalesAccionistas(initialTotals);
|
setTotalesAccionistas(initialTotals);
|
||||||
setTotalesCanillasOtraFecha(initialTotals);
|
setTotalesCanillasOtraFecha(initialTotals);
|
||||||
@@ -140,7 +157,7 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
const processedData = {
|
const processedData = {
|
||||||
canillas: addIds(data.canillas, 'can'),
|
canillas: addIds(data.canillas, 'can'),
|
||||||
canillasAccionistas: addIds(data.canillasAccionistas, 'acc'),
|
canillasAccionistas: addIds(data.canillasAccionistas, 'acc'),
|
||||||
canillasTodos: addIds(data.canillasTodos, 'all'), // Aún necesita IDs para DataGridSection
|
canillasTodos: addIds(data.canillasTodos, 'all'),
|
||||||
canillasLiquidadasOtraFecha: addIds(data.canillasLiquidadasOtraFecha, 'canliq'),
|
canillasLiquidadasOtraFecha: addIds(data.canillasLiquidadasOtraFecha, 'canliq'),
|
||||||
canillasAccionistasLiquidadasOtraFecha: addIds(data.canillasAccionistasLiquidadasOtraFecha, 'accliq'),
|
canillasAccionistasLiquidadasOtraFecha: addIds(data.canillasAccionistasLiquidadasOtraFecha, 'accliq'),
|
||||||
controlDevolucionesDetalle: addIds(data.controlDevolucionesDetalle, 'cdd'),
|
controlDevolucionesDetalle: addIds(data.controlDevolucionesDetalle, 'cdd'),
|
||||||
@@ -167,7 +184,7 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [puedeVerReporte]);
|
||||||
|
|
||||||
const handleVolverAParametros = useCallback(() => {
|
const handleVolverAParametros = useCallback(() => {
|
||||||
setShowParamSelector(true);
|
setShowParamSelector(true);
|
||||||
@@ -188,10 +205,9 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
const exportedData = data.map(item => {
|
const exportedData = data.map(item => {
|
||||||
const row: Record<string, any> = {};
|
const row: Record<string, any> = {};
|
||||||
// Excluir el 'id' generado para DataGrid si existe
|
|
||||||
const { id, ...itemData } = item;
|
const { id, ...itemData } = item;
|
||||||
Object.keys(fields).forEach(key => {
|
Object.keys(fields).forEach(key => {
|
||||||
row[fields[key]] = (itemData as any)[key]; // Usar itemData
|
row[fields[key]] = (itemData as any)[key];
|
||||||
if (key === 'fecha' && (itemData as any)[key]) {
|
if (key === 'fecha' && (itemData as any)[key]) {
|
||||||
row[fields[key]] = new Date((itemData as any)[key]).toLocaleDateString('es-AR', { timeZone: 'UTC' });
|
row[fields[key]] = new Date((itemData as any)[key]).toLocaleDateString('es-AR', { timeZone: 'UTC' });
|
||||||
}
|
}
|
||||||
@@ -215,18 +231,18 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Definición de campos para la exportación
|
|
||||||
const fieldsCanillaAccionista = { publicacion: "Publicación", canilla: "Canilla", totalCantSalida: "Llevados", totalCantEntrada: "Devueltos", vendidos: "Vendidos", totalRendir: "A Rendir" };
|
const fieldsCanillaAccionista = { publicacion: "Publicación", canilla: "Canilla", totalCantSalida: "Llevados", totalCantEntrada: "Devueltos", vendidos: "Vendidos", totalRendir: "A Rendir" };
|
||||||
const fieldsCanillaAccionistaFechaLiq = { publicacion: "Publicación", canilla: "Canilla", fecha: "Fecha Mov.", totalCantSalida: "Llevados", totalCantEntrada: "Devueltos", vendidos: "Vendidos", totalRendir: "A Rendir" };
|
const fieldsCanillaAccionistaFechaLiq = { publicacion: "Publicación", canilla: "Canilla", fecha: "Fecha Mov.", totalCantSalida: "Llevados", totalCantEntrada: "Devueltos", vendidos: "Vendidos", totalRendir: "A Rendir" };
|
||||||
const fieldsTodos = { publicacion: "Publicación", tipoVendedor: "Tipo", totalCantSalida: "Llevados", totalCantEntrada: "Devueltos", vendidos: "Vendidos", totalRendir: "A Rendir" };
|
const fieldsTodos = { publicacion: "Publicación", tipoVendedor: "Tipo", totalCantSalida: "Llevados", totalCantEntrada: "Devueltos", vendidos: "Vendidos", totalRendir: "A Rendir" };
|
||||||
|
|
||||||
formatAndSheet(reportData.canillas, "Canillitas_Dia", fieldsCanillaAccionista);
|
formatAndSheet(reportData.canillas, "Canillitas_Dia", fieldsCanillaAccionista);
|
||||||
formatAndSheet(reportData.canillasAccionistas, "Accionistas_Dia", fieldsCanillaAccionista);
|
formatAndSheet(reportData.canillasAccionistas, "Accionistas_Dia", fieldsCanillaAccionista);
|
||||||
formatAndSheet(reportData.canillasTodos, "Resumen_Dia", fieldsTodos);
|
if (currentParams?.idEmpresa !== 0) {
|
||||||
|
formatAndSheet(reportData.canillasTodos, "Resumen_Dia", fieldsTodos);
|
||||||
|
}
|
||||||
formatAndSheet(reportData.canillasLiquidadasOtraFecha, "Canillitas_OtrasFechas", fieldsCanillaAccionistaFechaLiq);
|
formatAndSheet(reportData.canillasLiquidadasOtraFecha, "Canillitas_OtrasFechas", fieldsCanillaAccionistaFechaLiq);
|
||||||
formatAndSheet(reportData.canillasAccionistasLiquidadasOtraFecha, "Accionistas_OtrasFechas", fieldsCanillaAccionistaFechaLiq);
|
formatAndSheet(reportData.canillasAccionistasLiquidadasOtraFecha, "Accionistas_OtrasFechas", fieldsCanillaAccionistaFechaLiq);
|
||||||
|
|
||||||
|
|
||||||
let fileName = "ReporteDetalleDistribucionCanillitas";
|
let fileName = "ReporteDetalleDistribucionCanillitas";
|
||||||
if (currentParams) {
|
if (currentParams) {
|
||||||
fileName += `_${currentParams.nombreEmpresa?.replace(/\s+/g, '') ?? `Emp${currentParams.idEmpresa}`}`;
|
fileName += `_${currentParams.nombreEmpresa?.replace(/\s+/g, '') ?? `Emp${currentParams.idEmpresa}`}`;
|
||||||
@@ -265,8 +281,6 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [currentParams]);
|
}, [currentParams]);
|
||||||
|
|
||||||
|
|
||||||
// --- Definiciones de Columnas ---
|
|
||||||
const commonColumns: GridColDef[] = [
|
const commonColumns: GridColDef[] = [
|
||||||
{ field: 'publicacion', headerName: 'Publicación', width: 200, flex: 1.2 },
|
{ field: 'publicacion', headerName: 'Publicación', width: 200, flex: 1.2 },
|
||||||
{ field: 'canilla', headerName: 'Canillita', width: 220, flex: 1.3 },
|
{ field: 'canilla', headerName: 'Canillita', width: 220, flex: 1.3 },
|
||||||
@@ -295,8 +309,7 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
{ field: 'totalRendir', headerName: 'A Rendir', type: 'number', width: 150, align: 'right', headerAlign: 'right', valueFormatter: (value) => currencyFormatter(Number(value)) },
|
{ field: 'totalRendir', headerName: 'A Rendir', type: 'number', width: 150, align: 'right', headerAlign: 'right', valueFormatter: (value) => currencyFormatter(Number(value)) },
|
||||||
];
|
];
|
||||||
|
|
||||||
// --- Custom Footers ---
|
const createCustomFooterComponent = (totals: TotalesComunes, columnsDef: GridColDef[]): CustomFooterType => {
|
||||||
const createCustomFooterComponent = (totals: TotalesComunes, columnsDef: GridColDef[]): CustomFooterType => { // Especificar el tipo de retorno
|
|
||||||
const getCellStyle = (colConfig: GridColDef | undefined, isPlaceholder: boolean = false) => {
|
const getCellStyle = (colConfig: GridColDef | undefined, isPlaceholder: boolean = false) => {
|
||||||
if (!colConfig) return { width: 100, textAlign: 'right' as const, pr: isPlaceholder ? 0 : 1, fontWeight: 'bold' };
|
if (!colConfig) return { width: 100, textAlign: 'right' as const, pr: isPlaceholder ? 0 : 1, fontWeight: 'bold' };
|
||||||
const defaultWidth = colConfig.field === 'publicacion' ? 200 : (colConfig.field === 'canilla' || colConfig.field === 'tipoVendedor' ? 150 : 100);
|
const defaultWidth = colConfig.field === 'publicacion' ? 200 : (colConfig.field === 'canilla' || colConfig.field === 'tipoVendedor' ? 150 : 100);
|
||||||
@@ -310,10 +323,9 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line react/display-name
|
const FooterComponent: CustomFooterType = (props) => (
|
||||||
const FooterComponent: CustomFooterType = (props) => ( // El componente debe aceptar props
|
<GridFooterContainer {...props} sx={{
|
||||||
<GridFooterContainer {...props} sx={{ // Pasar props y combinar sx
|
...(props.sx as any),
|
||||||
...(props.sx as any), // Castear props.sx temporalmente si es necesario
|
|
||||||
justifyContent: 'space-between', alignItems: 'center', width: '100%',
|
justifyContent: 'space-between', alignItems: 'center', width: '100%',
|
||||||
borderTop: (theme) => `1px solid ${theme.palette.divider}`, minHeight: '52px',
|
borderTop: (theme) => `1px solid ${theme.palette.divider}`, minHeight: '52px',
|
||||||
}}>
|
}}>
|
||||||
@@ -339,6 +351,7 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
return FooterComponent;
|
return FooterComponent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Usar los componentes creados con useMemo
|
||||||
const FooterCanillas = useMemo(() => createCustomFooterComponent(totalesCanillas, commonColumns), [totalesCanillas]);
|
const FooterCanillas = useMemo(() => createCustomFooterComponent(totalesCanillas, commonColumns), [totalesCanillas]);
|
||||||
const FooterAccionistas = useMemo(() => createCustomFooterComponent(totalesAccionistas, commonColumns), [totalesAccionistas]);
|
const FooterAccionistas = useMemo(() => createCustomFooterComponent(totalesAccionistas, commonColumns), [totalesAccionistas]);
|
||||||
const FooterCanillasOtraFecha = useMemo(() => createCustomFooterComponent(totalesCanillasOtraFecha, commonColumnsWithFecha), [totalesCanillasOtraFecha]);
|
const FooterCanillasOtraFecha = useMemo(() => createCustomFooterComponent(totalesCanillasOtraFecha, commonColumnsWithFecha), [totalesCanillasOtraFecha]);
|
||||||
@@ -346,12 +359,16 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
const FooterResumen = useMemo(() => createCustomFooterComponent(totalesResumen, columnsTodos), [totalesResumen, columnsTodos]);
|
const FooterResumen = useMemo(() => createCustomFooterComponent(totalesResumen, columnsTodos), [totalesResumen, columnsTodos]);
|
||||||
|
|
||||||
if (showParamSelector) {
|
if (showParamSelector) {
|
||||||
|
if (!loading && !puedeVerReporte) {
|
||||||
|
return <Alert severity="error" sx={{ m: 2 }}>No tiene permiso para acceder a este reporte.</Alert>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ p: 2, display: 'flex', justifyContent: 'center', mt: 2 }}>
|
<Box sx={{ p: 2, display: 'flex', justifyContent: 'center', mt: 2 }}>
|
||||||
<Paper sx={{ width: '100%', maxWidth: 600 }} elevation={3}>
|
<Paper sx={{ width: '100%', maxWidth: 600 }} elevation={3}>
|
||||||
<SeleccionaReporteDetalleDistribucionCanillas
|
<SeleccionaReporteDetalleDistribucionCanillas
|
||||||
onGenerarReporte={handleGenerarReporte}
|
onGenerarReporte={handleGenerarReporte}
|
||||||
onCancel={handleVolverAParametros} // Aunque el componente no lo use directamente.
|
onCancel={handleVolverAParametros}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
apiErrorMessage={apiErrorParams}
|
apiErrorMessage={apiErrorParams}
|
||||||
/>
|
/>
|
||||||
@@ -360,17 +377,45 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderContent = () => {
|
||||||
|
if (loading) return <Box sx={{ display: 'flex', justifyContent: 'center', my: 2 }}><CircularProgress /></Box>;
|
||||||
|
if (error && !loading) return <Alert severity="info" sx={{ my: 2 }}>{error}</Alert>;
|
||||||
|
if (!reportData) return <Typography sx={{ mt: 2, fontStyle: 'italic' }}>No se encontraron datos.</Typography>;
|
||||||
|
|
||||||
|
if (currentParams?.idEmpresa === 0) {
|
||||||
|
if (currentParams.esAccionista) {
|
||||||
|
return <DataGridSection title="Accionistas (Todas las Empresas)" data={reportData.canillasAccionistas || []} columns={commonColumns} footerComponent={FooterAccionistas} />;
|
||||||
|
}
|
||||||
|
return <DataGridSection title="Canillitas (Todas las Empresas)" data={reportData.canillas || []} columns={commonColumns} footerComponent={FooterCanillas} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DataGridSection title="Canillitas" data={reportData.canillas || []} columns={commonColumns} footerComponent={FooterCanillas} />
|
||||||
|
<DataGridSection title="Accionistas" data={reportData.canillasAccionistas || []} columns={commonColumns} footerComponent={FooterAccionistas} />
|
||||||
|
<DataGridSection title="Resumen por Tipo de Vendedor" data={reportData.canillasTodos || []} columns={columnsTodos} footerComponent={FooterResumen} />
|
||||||
|
{reportData.canillasLiquidadasOtraFecha && reportData.canillasLiquidadasOtraFecha.length > 0 &&
|
||||||
|
<DataGridSection title="Canillitas (Liquidados de Otras Fechas)" data={reportData.canillasLiquidadasOtraFecha} columns={commonColumnsWithFecha} footerComponent={FooterCanillasOtraFecha} />}
|
||||||
|
{reportData.canillasAccionistasLiquidadasOtraFecha && reportData.canillasAccionistasLiquidadasOtraFecha.length > 0 &&
|
||||||
|
<DataGridSection title="Accionistas (Liquidados de Otras Fechas)" data={reportData.canillasAccionistasLiquidadasOtraFecha} columns={commonColumnsWithFecha} footerComponent={FooterAccionistasOtraFecha} />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ p: 2 }}>
|
<Box sx={{ p: 2 }}>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2, flexWrap: 'wrap', gap: 1 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2, flexWrap: 'wrap', gap: 1 }}>
|
||||||
<Typography variant="h5">Reporte: Detalle Distribución Canillitas ({currentParams?.nombreEmpresa}) - {currentParams?.fecha ? new Date(currentParams.fecha + 'T00:00:00').toLocaleDateString('es-AR', { timeZone: 'UTC' }) : ''}</Typography>
|
<Typography variant="h5">Reporte: Detalle Distribución ({currentParams?.nombreEmpresa}) - {currentParams?.fecha ? new Date(currentParams.fecha + 'T00:00:00').toLocaleDateString('es-AR', { timeZone: 'UTC' }) : ''}</Typography>
|
||||||
<Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
|
<Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
|
||||||
|
{currentParams?.idEmpresa !== 0 && (
|
||||||
|
<Button onClick={() => handleGenerarYAbrirPdf(true)} variant="contained" color="secondary" disabled={loadingPdf || !reportData || !!error} size="small">
|
||||||
|
{loadingPdf && pdfSoloTotales ? <CircularProgress size={20} color="inherit" /> : "PDF Totales"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button onClick={() => handleGenerarYAbrirPdf(false)} variant="contained" disabled={loadingPdf || !reportData || !!error} size="small">
|
<Button onClick={() => handleGenerarYAbrirPdf(false)} variant="contained" disabled={loadingPdf || !reportData || !!error} size="small">
|
||||||
{loadingPdf && !pdfSoloTotales ? <CircularProgress size={20} color="inherit" /> : "PDF Detalle"}
|
{loadingPdf && !pdfSoloTotales ? <CircularProgress size={20} color="inherit" /> : "PDF Detalle"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => handleGenerarYAbrirPdf(true)} variant="contained" color="secondary" disabled={loadingPdf || !reportData || !!error} size="small">
|
|
||||||
{loadingPdf && pdfSoloTotales ? <CircularProgress size={20} color="inherit" /> : "PDF Totales"}
|
|
||||||
</Button>
|
|
||||||
<Button onClick={handleExportToExcel} variant="outlined" disabled={!reportData || !!error} size="small">
|
<Button onClick={handleExportToExcel} variant="outlined" disabled={!reportData || !!error} size="small">
|
||||||
Exportar a Excel
|
Exportar a Excel
|
||||||
</Button>
|
</Button>
|
||||||
@@ -379,34 +424,7 @@ const ReporteDetalleDistribucionCanillasPage: React.FC = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
{renderContent()}
|
||||||
{loading && <Box sx={{ textAlign: 'center', my: 2 }}><CircularProgress /></Box>}
|
|
||||||
{error && !loading && <Alert severity="info" sx={{ my: 2 }}>{error}</Alert>}
|
|
||||||
|
|
||||||
{!loading && !error && reportData && (
|
|
||||||
<>
|
|
||||||
<DataGridSection title="Canillitas" data={reportData.canillas || []} columns={commonColumns} footerComponent={FooterCanillas} />
|
|
||||||
<DataGridSection title="Accionistas" data={reportData.canillasAccionistas || []} columns={commonColumns} footerComponent={FooterAccionistas} />
|
|
||||||
|
|
||||||
<DataGridSection
|
|
||||||
title="Resumen por Tipo de Vendedor"
|
|
||||||
data={reportData.canillasTodos || []}
|
|
||||||
columns={columnsTodos}
|
|
||||||
footerComponent={FooterResumen} // <-- PASAR EL FOOTER
|
|
||||||
height={220} // El height ya no es necesario si autoHeight está activado por tener footer
|
|
||||||
/>
|
|
||||||
|
|
||||||
{reportData.canillasLiquidadasOtraFecha && reportData.canillasLiquidadasOtraFecha.length > 0 &&
|
|
||||||
<DataGridSection title="Canillitas (Liquidados de Otras Fechas)" data={reportData.canillasLiquidadasOtraFecha} columns={commonColumnsWithFecha} footerComponent={FooterCanillasOtraFecha} />}
|
|
||||||
|
|
||||||
{reportData.canillasAccionistasLiquidadasOtraFecha && reportData.canillasAccionistasLiquidadasOtraFecha.length > 0 &&
|
|
||||||
<DataGridSection title="Accionistas (Liquidados de Otras Fechas)" data={reportData.canillasAccionistasLiquidadasOtraFecha} columns={commonColumnsWithFecha} footerComponent={FooterAccionistasOtraFecha} />}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{!loading && !error && reportData &&
|
|
||||||
Object.values(reportData).every(arr => !arr || arr.length === 0) &&
|
|
||||||
<Typography sx={{ mt: 2, fontStyle: 'italic' }}>No se encontraron datos para los criterios seleccionados.</Typography>
|
|
||||||
}
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
Box, Typography, TextField, Button, CircularProgress, Alert,
|
Box, Typography, TextField, Button, CircularProgress, Alert,
|
||||||
FormControl, InputLabel, Select, MenuItem
|
FormControl, InputLabel, Select, MenuItem, ToggleButtonGroup, ToggleButton
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import type { EmpresaDto } from '../../models/dtos/Distribucion/EmpresaDto';
|
import type { EmpresaDropdownDto } from '../../models/dtos/Distribucion/EmpresaDropdownDto';
|
||||||
import empresaService from '../../services/Distribucion/empresaService';
|
import empresaService from '../../services/Distribucion/empresaService';
|
||||||
|
|
||||||
interface SeleccionaReporteDetalleDistribucionCanillasProps {
|
interface SeleccionaReporteDetalleDistribucionCanillasProps {
|
||||||
onGenerarReporte: (params: {
|
onGenerarReporte: (params: {
|
||||||
fecha: string;
|
fecha: string;
|
||||||
idEmpresa: number;
|
idEmpresa: number;
|
||||||
// soloTotales: boolean; // Podríamos añadirlo si el usuario elige la versión del PDF
|
esAccionista: boolean; // Añadimos este parámetro
|
||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
@@ -24,9 +24,9 @@ const SeleccionaReporteDetalleDistribucionCanillas: React.FC<SeleccionaReporteDe
|
|||||||
}) => {
|
}) => {
|
||||||
const [fecha, setFecha] = useState<string>(new Date().toISOString().split('T')[0]);
|
const [fecha, setFecha] = useState<string>(new Date().toISOString().split('T')[0]);
|
||||||
const [idEmpresa, setIdEmpresa] = useState<number | string>('');
|
const [idEmpresa, setIdEmpresa] = useState<number | string>('');
|
||||||
// const [soloTotales, setSoloTotales] = useState<boolean>(false); // Si se añade la opción
|
const [esAccionista, setEsAccionista] = useState<boolean>(false); // Nuevo estado
|
||||||
|
|
||||||
const [empresas, setEmpresas] = useState<EmpresaDto[]>([]);
|
const [empresas, setEmpresas] = useState<EmpresaDropdownDto[]>([]);
|
||||||
const [loadingDropdowns, setLoadingDropdowns] = useState(false);
|
const [loadingDropdowns, setLoadingDropdowns] = useState(false);
|
||||||
const [localErrors, setLocalErrors] = useState<{ [key: string]: string | null }>({});
|
const [localErrors, setLocalErrors] = useState<{ [key: string]: string | null }>({});
|
||||||
|
|
||||||
@@ -34,8 +34,9 @@ const SeleccionaReporteDetalleDistribucionCanillas: React.FC<SeleccionaReporteDe
|
|||||||
const fetchEmpresas = async () => {
|
const fetchEmpresas = async () => {
|
||||||
setLoadingDropdowns(true);
|
setLoadingDropdowns(true);
|
||||||
try {
|
try {
|
||||||
const data = await empresaService.getAllEmpresas(); // Asume que este servicio existe
|
const data = await empresaService.getEmpresasDropdown();
|
||||||
setEmpresas(data);
|
// Añadimos la opción "TODAS" al principio
|
||||||
|
setEmpresas([{ idEmpresa: 0, nombre: 'TODAS' }, ...data]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error al cargar empresas:", error);
|
console.error("Error al cargar empresas:", error);
|
||||||
setLocalErrors(prev => ({ ...prev, dropdowns: 'Error al cargar empresas.' }));
|
setLocalErrors(prev => ({ ...prev, dropdowns: 'Error al cargar empresas.' }));
|
||||||
@@ -49,7 +50,8 @@ const SeleccionaReporteDetalleDistribucionCanillas: React.FC<SeleccionaReporteDe
|
|||||||
const validate = (): boolean => {
|
const validate = (): boolean => {
|
||||||
const errors: { [key: string]: string | null } = {};
|
const errors: { [key: string]: string | null } = {};
|
||||||
if (!fecha) errors.fecha = 'La fecha es obligatoria.';
|
if (!fecha) errors.fecha = 'La fecha es obligatoria.';
|
||||||
if (!idEmpresa) errors.idEmpresa = 'Debe seleccionar una empresa.';
|
// El idEmpresa ya no puede estar vacío, porque se preselecciona "TODAS" o una empresa
|
||||||
|
if (idEmpresa === '') errors.idEmpresa = 'Debe seleccionar una empresa.';
|
||||||
setLocalErrors(errors);
|
setLocalErrors(errors);
|
||||||
return Object.keys(errors).length === 0;
|
return Object.keys(errors).length === 0;
|
||||||
};
|
};
|
||||||
@@ -59,14 +61,14 @@ const SeleccionaReporteDetalleDistribucionCanillas: React.FC<SeleccionaReporteDe
|
|||||||
onGenerarReporte({
|
onGenerarReporte({
|
||||||
fecha,
|
fecha,
|
||||||
idEmpresa: Number(idEmpresa),
|
idEmpresa: Number(idEmpresa),
|
||||||
// soloTotales // Si se añade la opción
|
esAccionista // Pasamos el nuevo parámetro
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ p: 2, border: '1px solid #ccc', borderRadius: '4px', minWidth: 380 }}>
|
<Box sx={{ p: 2, border: '1px solid #ccc', borderRadius: '4px', minWidth: 420 }}>
|
||||||
<Typography variant="h6" gutterBottom>
|
<Typography variant="h6" gutterBottom>
|
||||||
Parámetros: Detalle Distribución Canillitas
|
Parámetros: Detalle Distribución Canillas
|
||||||
</Typography>
|
</Typography>
|
||||||
<TextField
|
<TextField
|
||||||
label="Fecha"
|
label="Fecha"
|
||||||
@@ -89,26 +91,32 @@ const SeleccionaReporteDetalleDistribucionCanillas: React.FC<SeleccionaReporteDe
|
|||||||
value={idEmpresa}
|
value={idEmpresa}
|
||||||
onChange={(e) => { setIdEmpresa(e.target.value as number); setLocalErrors(p => ({ ...p, idEmpresa: null })); }}
|
onChange={(e) => { setIdEmpresa(e.target.value as number); setLocalErrors(p => ({ ...p, idEmpresa: null })); }}
|
||||||
>
|
>
|
||||||
<MenuItem value="" disabled><em>Seleccione una empresa</em></MenuItem>
|
|
||||||
{empresas.map((e) => (
|
{empresas.map((e) => (
|
||||||
<MenuItem key={e.idEmpresa} value={e.idEmpresa}>{e.nombre}</MenuItem>
|
<MenuItem key={e.idEmpresa} value={e.idEmpresa}>{e.nombre}</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
{localErrors.idEmpresa && <Typography color="error" variant="caption" sx={{ml:1.5}}>{localErrors.idEmpresa}</Typography>}
|
{localErrors.idEmpresa && <Typography color="error" variant="caption" sx={{ml:1.5}}>{localErrors.idEmpresa}</Typography>}
|
||||||
</FormControl>
|
</FormControl>
|
||||||
{/*
|
|
||||||
<FormControlLabel
|
{/* Selector condicional para Canillitas/Accionistas */}
|
||||||
control={
|
{idEmpresa === 0 && (
|
||||||
<Checkbox
|
<Box sx={{ mt: 2, display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
|
||||||
checked={soloTotales}
|
<Typography variant="subtitle2" sx={{ mb: 1, fontWeight: 'medium' }}>
|
||||||
onChange={(e) => setSoloTotales(e.target.checked)}
|
Mostrar para todas las empresas
|
||||||
|
</Typography>
|
||||||
|
<ToggleButtonGroup
|
||||||
|
value={esAccionista ? 'accionistas' : 'canillitas'}
|
||||||
|
exclusive
|
||||||
|
onChange={(_, value) => { if (value !== null) setEsAccionista(value === 'accionistas'); }}
|
||||||
|
aria-label="Tipo de Vendedor"
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
/>
|
color="primary"
|
||||||
}
|
>
|
||||||
label="Generar solo resumen de totales (PDF)"
|
<ToggleButton value="canillitas">Canillitas</ToggleButton>
|
||||||
sx={{ mt: 1, mb: 1 }}
|
<ToggleButton value="accionistas">Accionistas</ToggleButton>
|
||||||
/>
|
</ToggleButtonGroup>
|
||||||
*/}
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
{apiErrorMessage && <Alert severity="error" sx={{ mt: 2 }}>{apiErrorMessage}</Alert>}
|
{apiErrorMessage && <Alert severity="error" sx={{ mt: 2 }}>{apiErrorMessage}</Alert>}
|
||||||
{localErrors.dropdowns && <Alert severity="warning" sx={{ mt: 1 }}>{localErrors.dropdowns}</Alert>}
|
{localErrors.dropdowns && <Alert severity="warning" sx={{ mt: 1 }}>{localErrors.dropdowns}</Alert>}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import type { NovedadesCanillasReporteDto } from '../../models/dtos/Reportes/Nov
|
|||||||
import type { CanillaGananciaReporteDto } from '../../models/dtos/Reportes/CanillaGananciaReporteDto';
|
import type { CanillaGananciaReporteDto } from '../../models/dtos/Reportes/CanillaGananciaReporteDto';
|
||||||
import type { ListadoDistCanMensualDiariosDto } from '../../models/dtos/Reportes/ListadoDistCanMensualDiariosDto';
|
import type { ListadoDistCanMensualDiariosDto } from '../../models/dtos/Reportes/ListadoDistCanMensualDiariosDto';
|
||||||
import type { ListadoDistCanMensualPubDto } from '../../models/dtos/Reportes/ListadoDistCanMensualPubDto';
|
import type { ListadoDistCanMensualPubDto } from '../../models/dtos/Reportes/ListadoDistCanMensualPubDto';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
interface GetExistenciaPapelParams {
|
interface GetExistenciaPapelParams {
|
||||||
fechaDesde: string; // yyyy-MM-dd
|
fechaDesde: string; // yyyy-MM-dd
|
||||||
@@ -210,23 +211,42 @@ const getVentaMensualSecretariaTirDevoPdf = async (params: { fechaDesde: string;
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getReporteDistribucionCanillas = async (params: {
|
const getReporteDistribucionCanillas = async (params: {
|
||||||
fecha: string;
|
fecha: string;
|
||||||
idEmpresa: number;
|
idEmpresa: number;
|
||||||
|
esAccionista?: boolean; // Hacerlo opcional
|
||||||
}): Promise<ReporteDistribucionCanillasResponseDto> => {
|
}): Promise<ReporteDistribucionCanillasResponseDto> => {
|
||||||
const response = await apiClient.get<ReporteDistribucionCanillasResponseDto>('/reportes/distribucion-canillas', { params });
|
try {
|
||||||
return response.data;
|
const response = await apiClient.get<ReporteDistribucionCanillasResponseDto>('/reportes/distribucion-canillas', { params });
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error al obtener datos del reporte de distribución de canillas:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getReporteDistribucionCanillasPdf = async (params: {
|
const getReporteDistribucionCanillasPdf = async (params: {
|
||||||
fecha: string;
|
fecha: string;
|
||||||
idEmpresa: number;
|
idEmpresa: number;
|
||||||
soloTotales: boolean; // Nuevo parámetro
|
esAccionista?: boolean; // Opcional
|
||||||
|
soloTotales: boolean;
|
||||||
}): Promise<Blob> => {
|
}): Promise<Blob> => {
|
||||||
const response = await apiClient.get('/reportes/distribucion-canillas/pdf', { // La ruta no necesita cambiar si el backend lo maneja
|
try {
|
||||||
params, // soloTotales se enviará como query param si el backend lo espera así
|
const response = await apiClient.get('/reportes/distribucion-canillas/pdf', {
|
||||||
responseType: 'blob',
|
params,
|
||||||
});
|
responseType: 'blob'
|
||||||
return response.data;
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error al generar PDF del reporte de distribución de canillas:', error);
|
||||||
|
if (axios.isAxiosError(error) && error.response?.data) {
|
||||||
|
// Si el error es un JSON dentro de un Blob, hay que leerlo
|
||||||
|
if (error.response.data.type === 'application/json') {
|
||||||
|
const errorJson = JSON.parse(await error.response.data.text());
|
||||||
|
throw new Error(errorJson.message || "Error al generar PDF");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTiradasPublicacionesSecciones = async (params: {
|
const getTiradasPublicacionesSecciones = async (params: {
|
||||||
|
|||||||
Reference in New Issue
Block a user