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,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;
}
}

View File

@@ -0,0 +1,18 @@
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class CanillaDto
{
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 string NombreZona { get; set; } = string.Empty; // Para mostrar en la UI
public bool Accionista { get; set; }
public string? Obs { get; set; }
public int Empresa { get; set; } // Podría traer el nombre de la empresa si es relevante
public string NombreEmpresa { get; set;} = string.Empty;
public bool Baja { get; set; }
public string? FechaBaja { get; set; } // Formato string para la UI
}
}

View File

@@ -0,0 +1,33 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class CreateCanillaDto
{
public int? Legajo { get; set; }
[Required(ErrorMessage = "El nombre y apellido son obligatorios.")]
[StringLength(100)]
public string NomApe { get; set; } = string.Empty;
[StringLength(150)]
public string? Parada { get; set; }
[Required(ErrorMessage = "La zona es obligatoria.")]
[Range(1, int.MaxValue, ErrorMessage = "Debe seleccionar una zona válida.")]
public int IdZona { get; set; }
[Required]
public bool Accionista { get; set; } = false;
[StringLength(150)]
public string? Obs { get; set; }
[Required(ErrorMessage = "La empresa es obligatoria.")]
// Asumimos que Empresa 0 es válido para accionistas según el contexto.
// Si Empresa 0 es un placeholder, entonces Range(1, int.MaxValue)
public int Empresa { get; set; } = 0; // Default 0 según la tabla
// Baja y FechaBaja se manejan por una acción separada, no en creación.
}
}

View File

@@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class CreateDistribuidorDto
{
[Required(ErrorMessage = "El nombre del distribuidor es obligatorio.")]
[StringLength(100)]
public string Nombre { get; set; } = string.Empty;
[StringLength(100)]
public string? Contacto { get; set; }
[Required(ErrorMessage = "El número de documento es obligatorio.")]
[StringLength(11)] // CUIT/CUIL suele tener 11 dígitos
public string NroDoc { get; set; } = string.Empty;
public int? IdZona { get; set; } // Puede ser nulo si el distribuidor no tiene zona
[StringLength(30)]
public string? Calle { get; set; }
[StringLength(8)]
public string? Numero { get; set; }
[StringLength(3)]
public string? Piso { get; set; }
[StringLength(4)]
public string? Depto { get; set; }
[StringLength(40)]
public string? Telefono { get; set; }
[StringLength(40)]
[EmailAddress(ErrorMessage = "Formato de email inválido.")]
public string? Email { get; set; }
[StringLength(50)]
public string? Localidad { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class CreateOtroDestinoDto
{
[Required(ErrorMessage = "El nombre del destino es obligatorio.")]
[StringLength(100, ErrorMessage = "El nombre no puede exceder los 100 caracteres.")]
public string Nombre { get; set; } = string.Empty;
[StringLength(250, ErrorMessage = "La observación no puede exceder los 250 caracteres.")]
public string? Obs { get; set; }
}
}

View File

@@ -0,0 +1,30 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class CreatePrecioDto
{
[Required(ErrorMessage = "El ID de la publicación es obligatorio.")]
public int IdPublicacion { get; set; }
[Required(ErrorMessage = "La fecha de Vigencia Desde es obligatoria.")]
public DateTime VigenciaD { get; set; } // Recibir como DateTime desde el cliente
// VigenciaH se calculará o se dejará null inicialmente.
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Lunes { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Martes { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Miercoles { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Jueves { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Viernes { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Sabado { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Domingo { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class CreatePublicacionDto
{
[Required(ErrorMessage = "El nombre de la publicación es obligatorio.")]
[StringLength(50)]
public string Nombre { get; set; } = string.Empty;
[StringLength(150)]
public string? Observacion { get; set; }
[Required(ErrorMessage = "La empresa es obligatoria.")]
[Range(1, int.MaxValue, ErrorMessage = "Debe seleccionar una empresa válida.")]
public int IdEmpresa { get; set; }
[Required]
public bool CtrlDevoluciones { get; set; } = false;
public bool Habilitada { get; set; } = true; // Default true en UI
}
}

View File

@@ -0,0 +1,19 @@
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class DistribuidorDto
{
public int IdDistribuidor { get; set; }
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? NombreZona { get; set; } // Para mostrar en UI
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,9 @@
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class OtroDestinoDto
{
public int IdDestino { get; set; }
public string Nombre { get; set; } = string.Empty;
public string? Obs { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class PrecioDto
{
public int IdPrecio { get; set; }
public int IdPublicacion { get; set; }
public string VigenciaD { get; set; } = string.Empty; // string yyyy-MM-dd para la UI
public string? VigenciaH { get; set; } // string yyyy-MM-dd para la UI
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; }
}
}

View File

@@ -0,0 +1,13 @@
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class PublicacionDto
{
public int IdPublicacion { get; set; }
public string Nombre { get; set; } = string.Empty;
public string? Observacion { get; set; }
public int IdEmpresa { get; set; }
public string NombreEmpresa { get; set; } = string.Empty; // Para mostrar en UI
public bool CtrlDevoluciones { get; set; }
public bool Habilitada { get; set; } // Simplificamos a bool, el backend manejará el default si es null
}
}

View File

@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class ToggleBajaCanillaDto
{
[Required]
public bool DarDeBaja { get; set; } // True para dar de baja, False para reactivar
}
}

View File

@@ -0,0 +1,31 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class UpdateCanillaDto
{
public int? Legajo { get; set; }
[Required(ErrorMessage = "El nombre y apellido son obligatorios.")]
[StringLength(100)]
public string NomApe { get; set; } = string.Empty;
[StringLength(150)]
public string? Parada { get; set; }
[Required(ErrorMessage = "La zona es obligatoria.")]
[Range(1, int.MaxValue, ErrorMessage = "Debe seleccionar una zona válida.")]
public int IdZona { get; set; }
[Required]
public bool Accionista { get; set; }
[StringLength(150)]
public string? Obs { get; set; }
[Required(ErrorMessage = "La empresa es obligatoria.")]
public int Empresa { get; set; }
// Baja y FechaBaja se manejan por una acción separada.
}
}

View File

@@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class UpdateDistribuidorDto
{
[Required(ErrorMessage = "El nombre del distribuidor es obligatorio.")]
[StringLength(100)]
public string Nombre { get; set; } = string.Empty;
[StringLength(100)]
public string? Contacto { get; set; }
[Required(ErrorMessage = "El número de documento es obligatorio.")]
[StringLength(11)]
public string NroDoc { get; set; } = string.Empty;
public int? IdZona { get; set; }
[StringLength(30)]
public string? Calle { get; set; }
[StringLength(8)]
public string? Numero { get; set; }
[StringLength(3)]
public string? Piso { get; set; }
[StringLength(4)]
public string? Depto { get; set; }
[StringLength(40)]
public string? Telefono { get; set; }
[StringLength(40)]
[EmailAddress(ErrorMessage = "Formato de email inválido.")]
public string? Email { get; set; }
[StringLength(50)]
public string? Localidad { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class UpdateOtroDestinoDto
{
[Required(ErrorMessage = "El nombre del destino es obligatorio.")]
[StringLength(100, ErrorMessage = "El nombre no puede exceder los 100 caracteres.")]
public string Nombre { get; set; } = string.Empty;
[StringLength(250, ErrorMessage = "La observación no puede exceder los 250 caracteres.")]
public string? Obs { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class UpdatePrecioDto // Para actualizar un IdPrecio específico
{
// IdPublicacion no se puede cambiar una vez creado el precio (se borraría y crearía uno nuevo)
// VigenciaD tampoco se debería cambiar directamente, se maneja creando nuevos periodos.
[Required(ErrorMessage = "La fecha de Vigencia Hasta es obligatoria si se modifica un periodo existente para cerrarlo.")]
public DateTime? VigenciaH { get; set; } // Para cerrar un periodo
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Lunes { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Martes { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Miercoles { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Jueves { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Viernes { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Sabado { get; set; }
[Range(0, 999999.99, ErrorMessage = "El precio debe ser un valor positivo.")]
public decimal? Domingo { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Distribucion
{
public class UpdatePublicacionDto
{
[Required(ErrorMessage = "El nombre de la publicación es obligatorio.")]
[StringLength(50)]
public string Nombre { get; set; } = string.Empty;
[StringLength(150)]
public string? Observacion { get; set; }
[Required(ErrorMessage = "La empresa es obligatoria.")]
[Range(1, int.MaxValue, ErrorMessage = "Debe seleccionar una empresa válida.")]
public int IdEmpresa { get; set; }
[Required]
public bool CtrlDevoluciones { get; set; }
[Required] // En la actualización, el estado de Habilitada debe ser explícito
public bool Habilitada { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class ActualizarPermisosPerfilRequestDto
{
[Required]
[MinLength(0)] // Puede que un perfil no tenga ningún permiso.
public List<int> PermisosIds { get; set; } = new List<int>();
}
}

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class CreatePerfilDto
{
[Required(ErrorMessage = "El nombre del perfil es obligatorio.")]
[StringLength(20, ErrorMessage = "El nombre del perfil no puede exceder los 20 caracteres.")]
public string NombrePerfil { get; set; } = string.Empty;
[StringLength(150, ErrorMessage = "La descripción no puede exceder los 150 caracteres.")]
public string? Descripcion { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class CreatePermisoDto
{
[Required(ErrorMessage = "El módulo es obligatorio.")]
[StringLength(50, ErrorMessage = "El módulo no puede exceder los 50 caracteres.")]
public string Modulo { get; set; } = string.Empty;
[Required(ErrorMessage = "La descripción del permiso es obligatoria.")]
[StringLength(150, ErrorMessage = "La descripción no puede exceder los 150 caracteres.")]
public string DescPermiso { get; set; } = string.Empty;
[Required(ErrorMessage = "El código de acceso es obligatorio.")]
[StringLength(10, ErrorMessage = "El código de acceso no puede exceder los 10 caracteres.")]
// Podrías añadir una RegularExpression si los codAcc tienen un formato específico
public string CodAcc { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,34 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class CreateUsuarioRequestDto
{
[Required(ErrorMessage = "El nombre de usuario es obligatorio.")]
[StringLength(20, MinimumLength = 3, ErrorMessage = "El nombre de usuario debe tener entre 3 y 20 caracteres.")]
public string User { get; set; } = string.Empty;
[Required(ErrorMessage = "La contraseña es obligatoria.")]
[StringLength(50, MinimumLength = 6, ErrorMessage = "La contraseña debe tener al menos 6 caracteres.")]
public string Password { get; set; } = string.Empty; // Contraseña en texto plano para la creación
[Required(ErrorMessage = "El nombre es obligatorio.")]
[StringLength(50)]
public string Nombre { get; set; } = string.Empty;
[Required(ErrorMessage = "El apellido es obligatorio.")]
[StringLength(50)]
public string Apellido { get; set; } = string.Empty;
[Required(ErrorMessage = "El perfil es obligatorio.")]
[Range(1, int.MaxValue, ErrorMessage = "Debe seleccionar un perfil válido.")]
public int IdPerfil { get; set; }
public bool Habilitada { get; set; } = true;
public bool SupAdmin { get; set; } = false;
public bool DebeCambiarClave { get; set; } = true; // Por defecto, forzar cambio al primer login
[StringLength(10)]
public string VerLog { get; set; } = "1.0.0.0"; // Valor por defecto
}
}

View File

@@ -0,0 +1,9 @@
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class PerfilDto
{
public int Id { get; set; }
public string NombrePerfil { get; set; } = string.Empty;
public string? Descripcion { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class PermisoAsignadoDto
{
public int Id { get; set; }
public string Modulo { get; set; } = string.Empty;
public string DescPermiso { get; set; } = string.Empty;
public string CodAcc { get; set; } = string.Empty;
public bool Asignado { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class PermisoDto
{
public int Id { get; set; }
public string Modulo { get; set; } = string.Empty;
public string DescPermiso { get; set; } = string.Empty;
public string CodAcc { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class SetPasswordRequestDto
{
[Required]
[StringLength(50, MinimumLength = 6, ErrorMessage = "La nueva contraseña debe tener al menos 6 caracteres.")]
public string NewPassword { get; set; } = string.Empty;
public bool ForceChangeOnNextLogin { get; set; } = true;
}
}

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class UpdatePerfilDto
{
[Required(ErrorMessage = "El nombre del perfil es obligatorio.")]
[StringLength(20, ErrorMessage = "El nombre del perfil no puede exceder los 20 caracteres.")]
public string NombrePerfil { get; set; } = string.Empty;
[StringLength(150, ErrorMessage = "La descripción no puede exceder los 150 caracteres.")]
public string? Descripcion { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class UpdatePermisoDto
{
[Required(ErrorMessage = "El módulo es obligatorio.")]
[StringLength(50, ErrorMessage = "El módulo no puede exceder los 50 caracteres.")]
public string Modulo { get; set; } = string.Empty;
[Required(ErrorMessage = "La descripción del permiso es obligatoria.")]
[StringLength(150, ErrorMessage = "La descripción no puede exceder los 150 caracteres.")]
public string DescPermiso { get; set; } = string.Empty;
[Required(ErrorMessage = "El código de acceso es obligatorio.")]
[StringLength(10, ErrorMessage = "El código de acceso no puede exceder los 10 caracteres.")]
public string CodAcc { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,34 @@
using System.ComponentModel.DataAnnotations;
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class UpdateUsuarioRequestDto
{
// User no se puede cambiar usualmente, o requiere un proceso separado.
// Si se permite cambiar, añadir validaciones. Por ahora lo omitimos del DTO de update.
[Required(ErrorMessage = "El nombre es obligatorio.")]
[StringLength(50)]
public string Nombre { get; set; } = string.Empty;
[Required(ErrorMessage = "El apellido es obligatorio.")]
[StringLength(50)]
public string Apellido { get; set; } = string.Empty;
[Required(ErrorMessage = "El perfil es obligatorio.")]
[Range(1, int.MaxValue, ErrorMessage = "Debe seleccionar un perfil válido.")]
public int IdPerfil { get; set; }
[Required(ErrorMessage = "El estado Habilitada es obligatorio.")]
public bool Habilitada { get; set; }
[Required(ErrorMessage = "El estado SupAdmin es obligatorio.")]
public bool SupAdmin { get; set; }
[Required(ErrorMessage = "El estado DebeCambiarClave es obligatorio.")]
public bool DebeCambiarClave { get; set; }
[StringLength(10)]
public string VerLog { get; set; } = "1.0.0.0";
}
}

View File

@@ -0,0 +1,16 @@
namespace GestionIntegral.Api.Dtos.Usuarios
{
public class UsuarioDto // Para listar y ver detalles
{
public int Id { get; set; }
public string User { get; set; } = string.Empty;
public bool Habilitada { get; set; }
public bool SupAdmin { get; set; }
public string Nombre { get; set; } = string.Empty;
public string Apellido { get; set; } = string.Empty;
public int IdPerfil { get; set; }
public string NombrePerfil { get; set; } = string.Empty; // Para mostrar en la UI
public bool DebeCambiarClave { get; set; }
public string VerLog { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,14 @@
namespace GestionIntegral.Api.Models.Usuarios
{
public class Perfil
{
// Columna: id (PK, Identity)
public int Id { get; set; }
// Columna: perfil (varchar(20), NOT NULL)
public string NombrePerfil { get; set; } = string.Empty; // Renombrado de 'perfil' para evitar conflicto
// Columna: descPerfil (varchar(150), NULL)
public string? Descripcion { get; set; } // Renombrado de 'descPerfil'
}
}

View File

@@ -0,0 +1,12 @@
namespace GestionIntegral.Api.Models.Usuarios
{
public class PerfilHistorico
{
public int IdPerfil { get; set; } // FK a gral_Perfiles.id
public string NombrePerfil { get; set; } = string.Empty;
public string? Descripcion { get; set; }
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,17 @@
namespace GestionIntegral.Api.Models.Usuarios
{
public class Permiso
{
// Columna: id (PK, Identity)
public int Id { get; set; }
// Columna: modulo (varchar(50), NOT NULL)
public string Modulo { get; set; } = string.Empty;
// Columna: descPermiso (varchar(150), NOT NULL)
public string DescPermiso { get; set; } = string.Empty;
// Columna: codAcc (varchar(10), NOT NULL, UNIQUE)
public string CodAcc { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,14 @@
namespace GestionIntegral.Api.Models.Usuarios
{
public class PermisoHistorico
{
public int IdHist { get; set; } // PK de la tabla de historial
public int IdPermiso { get; set; } // FK a gral_Permisos.id
public string Modulo { get; set; } = string.Empty;
public string DescPermiso { get; set; } = string.Empty;
public string CodAcc { get; set; } = string.Empty;
public int IdUsuario { get; set; }
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}

View File

@@ -1,4 +1,4 @@
namespace GestionIntegral.Api.Models
namespace GestionIntegral.Api.Models.Usuarios
{
public class Usuario
{

View File

@@ -0,0 +1,33 @@
namespace GestionIntegral.Api.Models.Usuarios
{
public class UsuarioHistorico
{
public int IdHist { get; set; }
public int IdUsuario { get; set; } // FK al usuario modificado
public string? UserAnt { get; set; }
public string UserNvo { get; set; } = string.Empty;
public bool? HabilitadaAnt { get; set; }
public bool HabilitadaNva { get; set; }
public bool? SupAdminAnt { get; set; }
public bool SupAdminNvo { get; set; }
public string? NombreAnt { get; set; }
public string NombreNvo { get; set; } = string.Empty;
public string? ApellidoAnt { get; set; }
public string ApellidoNvo { get; set; } = string.Empty;
public int? IdPerfilAnt { get; set; }
public int IdPerfilNvo { get; set; }
public bool? DebeCambiarClaveAnt { get; set; }
public bool DebeCambiarClaveNva { get; set; }
public int Id_UsuarioMod { get; set; } // Quién hizo el cambio
public DateTime FechaMod { get; set; }
public string TipoMod { get; set; } = string.Empty;
}
}