feat: Implementación CRUD Canillitas, Distribuidores y Precios de Publicación

Backend API:
- Canillitas (`dist_dtCanillas`):
  - Implementado CRUD completo (Modelos, DTOs, Repositorio, Servicio, Controlador).
  - Lógica para manejo de `Accionista`, `Baja`, `FechaBaja`.
  - Auditoría en `dist_dtCanillas_H`.
  - Validación de legajo único y lógica de empresa vs accionista.
- Distribuidores (`dist_dtDistribuidores`):
  - Implementado CRUD completo (Modelos, DTOs, Repositorio, Servicio, Controlador).
  - Auditoría en `dist_dtDistribuidores_H`.
  - Creación de saldos iniciales para el nuevo distribuidor en todas las empresas.
  - Verificación de NroDoc único y Nombre opcionalmente único.
- Precios de Publicación (`dist_Precios`):
  - Implementado CRUD básico (Modelos, DTOs, Repositorio, Servicio, Controlador).
  - Endpoints anidados bajo `/publicaciones/{idPublicacion}/precios`.
  - Lógica de negocio para cerrar período de precio anterior al crear uno nuevo.
  - Lógica de negocio para reabrir período de precio anterior al eliminar el último.
  - Auditoría en `dist_Precios_H`.
- Auditoría en Eliminación de Publicaciones:
  - Extendido `PublicacionService.EliminarAsync` para eliminar en cascada registros de precios, recargos, porcentajes de pago (distribuidores y canillitas) y secciones de publicación.
  - Repositorios correspondientes (`PrecioRepository`, `RecargoZonaRepository`, `PorcPagoRepository`, `PorcMonCanillaRepository`, `PubliSeccionRepository`) actualizados con métodos `DeleteByPublicacionIdAsync` que registran en sus respectivas tablas `_H` (si existen y se implementó la lógica).
  - Asegurada la correcta propagación del `idUsuario` para la auditoría en cascada.
- Correcciones de Nulabilidad:
  - Ajustados los métodos `MapToDto` y su uso en `CanillaService` y `PublicacionService` para manejar correctamente tipos anulables.

Frontend React:
- Canillitas:
  - `canillaService.ts`.
  - `CanillaFormModal.tsx` con selectores para Zona y Empresa, y lógica de Accionista.
  - `GestionarCanillitasPage.tsx` con filtros, paginación, y acciones (editar, toggle baja).
- Distribuidores:
  - `distribuidorService.ts`.
  - `DistribuidorFormModal.tsx` con múltiples campos y selector de Zona.
  - `GestionarDistribuidoresPage.tsx` con filtros, paginación, y acciones (editar, eliminar).
- Precios de Publicación:
  - `precioService.ts`.
  - `PrecioFormModal.tsx` para crear/editar períodos de precios (VigenciaD, VigenciaH opcional, precios por día).
  - `GestionarPreciosPublicacionPage.tsx` accesible desde la gestión de publicaciones, para listar y gestionar los períodos de precios de una publicación específica.
- Layout:
  - Reemplazado el uso de `Grid` por `Box` con Flexbox en `CanillaFormModal`, `GestionarCanillitasPage` (filtros), `DistribuidorFormModal` y `PrecioFormModal` para resolver problemas de tipos y mejorar la consistencia del layout de formularios.
- Navegación:
  - Actualizadas las rutas y pestañas para los nuevos módulos y sub-módulos.
This commit is contained in:
2025-05-20 12:38:55 -03:00
parent daf84d2708
commit b6ba52f074
228 changed files with 10745 additions and 178 deletions

View File

@@ -0,0 +1,16 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class Canilla
{
public int IdCanilla { get; set; } // Id_Canilla (PK, Identity)
public int? Legajo { get; set; } // Legajo (int, NULL)
public string NomApe { get; set; } = string.Empty; // NomApe (varchar(100), NOT NULL)
public string? Parada { get; set; } // Parada (varchar(150), NULL)
public int IdZona { get; set; } // Id_Zona (int, NOT NULL)
public bool Accionista { get; set; } // Accionista (bit, NOT NULL)
public string? Obs { get; set; } // Obs (varchar(150), NULL)
public int Empresa { get; set; } // Empresa (int, NOT NULL, DEFAULT 0)
public bool Baja { get; set; } // Baja (bit, NOT NULL, DEFAULT 0)
public DateTime? FechaBaja { get; set; } // FechaBaja (datetime2(0), NULL)
}
}

View File

@@ -0,0 +1,21 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class CanillaHistorico
{
public int IdCanilla { get; set; }
public int? Legajo { get; set; }
public string NomApe { get; set; } = string.Empty;
public string? Parada { get; set; }
public int IdZona { get; set; }
public bool Accionista { get; set; }
public string? Obs { get; set; }
public int Empresa { get; set; }
public bool Baja { get; set; }
public DateTime? FechaBaja { get; set; }
// Campos de Auditoría
public int Id_Usuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,18 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class Distribuidor
{
public int IdDistribuidor { get; set; } // Id_Distribuidor (PK, Identity)
public string Nombre { get; set; } = string.Empty; // Nombre (varchar(100), NOT NULL)
public string? Contacto { get; set; } // Contacto (varchar(100), NULL)
public string NroDoc { get; set; } = string.Empty; // NroDoc (varchar(11), NOT NULL)
public int? IdZona { get; set; } // Id_Zona (int, NULL) - Puede no tener zona asignada
public string? Calle { get; set; }
public string? Numero { get; set; }
public string? Piso { get; set; }
public string? Depto { get; set; }
public string? Telefono { get; set; }
public string? Email { get; set; }
public string? Localidad { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class DistribuidorHistorico
{
public int IdDistribuidor { get; set; } // FK
public string Nombre { get; set; } = string.Empty;
public string? Contacto { get; set; }
public string NroDoc { get; set; } = string.Empty;
public int? IdZona { get; set; }
public string? Calle { get; set; }
public string? Numero { get; set; }
public string? Piso { get; set; }
public string? Depto { get; set; }
public string? Telefono { get; set; }
public string? Email { get; set; }
public string? Localidad { get; set; }
// Campos de Auditoría
public int Id_Usuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,12 @@
namespace GestionIntegral.Api.Models.Empresas
{
public class EmpresaHistorico
{
public int IdEmpresa { get; set; }
public string Nombre { get; set; } = string.Empty;
public string? Detalle { get; set; }
public int IdUsuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,14 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class OtroDestino
{
// Columna: Id_Destino (PK, Identity)
public int IdDestino { get; set; }
// Columna: Nombre (varchar(100), NOT NULL)
public string Nombre { get; set; } = string.Empty;
// Columna: Obs (varchar(250), NULL)
public string? Obs { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class OtroDestinoHistorico
{
// Columna: Id_Destino (int, FK)
public int IdDestino { get; set; }
// Columna: Nombre (varchar(100), NOT NULL)
public string Nombre { get; set; } = string.Empty;
// Columna: Obs (varchar(250), NULL)
public string? Obs { get; set; }
// Columnas de Auditoría
public int IdUsuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty; // "Insertada", "Modificada", "Eliminada"
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace GestionIntegral.Api.Models.Distribucion
{
public class PorcMonCanilla // Corresponde a dist_PorcMonPagoCanilla
{
public int IdPorcMon { get; set; } // Id_PorcMon
public int IdPublicacion { get; set; }
public int IdCanilla { get; set; }
public DateTime VigenciaD { get; set; }
public DateTime? VigenciaH { get; set; }
public decimal PorcMon { get; set; } // Columna PorcMon en DB
public bool EsPorcentaje { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
namespace GestionIntegral.Api.Models.Distribucion
{
public class PorcMonCanillaHistorico
{
public int Id_PorcMon { get; set; } // Coincide con la columna
public int Id_Publicacion { get; set; }
public int Id_Canilla { get; set; }
public DateTime VigenciaD { get; set; }
public DateTime? VigenciaH { get; set; }
public decimal PorcMon { get; set; }
public bool EsPorcentaje { get; set; }
public int Id_Usuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace GestionIntegral.Api.Models.Distribucion
{
public class PorcPago // Corresponde a dist_PorcPago
{
public int IdPorcentaje { get; set; } // Id_Porcentaje
public int IdPublicacion { get; set; }
public int IdDistribuidor { get; set; }
public DateTime VigenciaD { get; set; } // smalldatetime se mapea a DateTime
public DateTime? VigenciaH { get; set; }
public decimal Porcentaje { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
namespace GestionIntegral.Api.Models.Distribucion
{
public class PorcPagoHistorico
{
public int IdPorcentaje { get; set; } // Id_Porcentaje
public int IdPublicacion { get; set; }
public int IdDistribuidor { get; set; }
public DateTime VigenciaD { get; set; }
public DateTime? VigenciaH { get; set; }
public decimal Porcentaje { get; set; }
public int IdUsuario { get; set; } // Coincide con Id_Usuario en la tabla _H
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,17 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class Precio
{
public int IdPrecio { get; set; } // Id_Precio (PK, Identity)
public int IdPublicacion { get; set; } // Id_Publicacion (FK, NOT NULL)
public DateTime VigenciaD { get; set; } // VigenciaD (datetime2(0), NOT NULL)
public DateTime? VigenciaH { get; set; } // VigenciaH (datetime2(0), NULL)
public decimal? Lunes { get; set; } // Lunes (decimal(14,2), NULL, DEFAULT 0)
public decimal? Martes { get; set; }
public decimal? Miercoles { get; set; }
public decimal? Jueves { get; set; }
public decimal? Viernes { get; set; }
public decimal? Sabado { get; set; }
public decimal? Domingo { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class PrecioHistorico
{
public int IdPrecio { get; set; } // FK a dist_Precios.Id_Precio
public int IdPublicacion { get; set; }
public DateTime VigenciaD { get; set; }
public DateTime? VigenciaH { get; set; }
public decimal? Lunes { get; set; }
public decimal? Martes { get; set; }
public decimal? Miercoles { get; set; }
public decimal? Jueves { get; set; }
public decimal? Viernes { get; set; }
public decimal? Sabado { get; set; }
public decimal? Domingo { get; set; }
// Campos de Auditoría
public int Id_Usuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,10 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class PubliSeccion
{
public int IdSeccion { get; set; } // Id_Seccion
public int IdPublicacion { get; set; }
public string Nombre { get; set; } = string.Empty;
public bool Estado { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace GestionIntegral.Api.Models.Distribucion
{
public class PubliSeccionHistorico
{
public int Id_Seccion { get; set; } // Coincide con la columna
public int Id_Publicacion { get; set; }
public string Nombre { get; set; } = string.Empty;
public bool Estado { get; set; }
public int Id_Usuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,12 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class Publicacion
{
public int IdPublicacion { get; set; } // Id_Publicacion (PK, Identity)
public string Nombre { get; set; } = string.Empty; // Nombre (varchar(50), NOT NULL)
public string? Observacion { get; set; } // Observacion (varchar(150), NULL)
public int IdEmpresa { get; set; } // Id_Empresa (int, NOT NULL)
public bool CtrlDevoluciones { get; set; } // CtrlDevoluciones (bit, NOT NULL, DEFAULT 0)
public bool? Habilitada { get; set; } // Habilitada (bit, NULL, DEFAULT 1) - ¡OJO! En la tabla es NULLABLE con DEFAULT 1
}
}

View File

@@ -0,0 +1,17 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class PublicacionHistorico
{
// No hay PK autoincremental explícita en el script de _H
public int IdPublicacion { get; set; }
public string Nombre { get; set; } = string.Empty;
public string? Observacion { get; set; }
public int IdEmpresa { get; set; }
public bool? Habilitada { get; set; } // Coincide con la tabla _H
// Campos de Auditoría
public int Id_Usuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace GestionIntegral.Api.Models.Distribucion
{
public class RecargoZona
{
public int IdRecargo { get; set; } // Id_Recargo (PK, Identity)
public int IdPublicacion { get; set; } // Id_Publicacion (FK, NOT NULL)
public int IdZona { get; set; } // Id_Zona (FK, NOT NULL)
public DateTime VigenciaD { get; set; } // VigenciaD (datetime2(0), NOT NULL)
public DateTime? VigenciaH { get; set; } // VigenciaH (datetime2(0), NULL)
public decimal Valor { get; set; } // Valor (decimal(14,2), NOT NULL, DEFAULT 0)
}
}

View File

@@ -0,0 +1,15 @@
namespace GestionIntegral.Api.Models.Distribucion
{
public class RecargoZonaHistorico
{
public int IdRecargo { get; set; }
public int IdPublicacion { get; set; }
public int IdZona { get; set; }
public DateTime VigenciaD { get; set; }
public DateTime? VigenciaH { get; set; }
public decimal Valor { get; set; }
public int IdUsuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}