Ya perdí el hilo de los cambios pero ahi van.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class ControlDevolucionesDto
|
||||
{
|
||||
public int IdControl { get; set; }
|
||||
public int IdEmpresa { get; set; }
|
||||
public string NombreEmpresa { get; set; } = string.Empty;
|
||||
public string Fecha { get; set; } = string.Empty; // yyyy-MM-dd
|
||||
public int Entrada { get; set; }
|
||||
public int Sobrantes { get; set; }
|
||||
public string? Detalle { get; set; }
|
||||
public int SinCargo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class CreateBulkEntradaSalidaCanillaDto
|
||||
{
|
||||
[Required(ErrorMessage = "El ID del canillita es obligatorio.")]
|
||||
public int IdCanilla { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "La fecha del movimiento es obligatoria.")]
|
||||
public DateTime Fecha { get; set; } // Fecha común para todos los ítems
|
||||
|
||||
[Required(ErrorMessage = "Debe haber al menos un ítem de movimiento.")]
|
||||
[MinLength(1, ErrorMessage = "Debe agregar al menos una publicación.")]
|
||||
public List<EntradaSalidaCanillaItemDto> Items { get; set; } = new List<EntradaSalidaCanillaItemDto>();
|
||||
|
||||
// Validar que no haya publicaciones duplicadas en la lista de items
|
||||
[CustomValidation(typeof(CreateBulkEntradaSalidaCanillaDto), nameof(ValidateNoDuplicatePublications))]
|
||||
public string? DuplicateError { get; set; }
|
||||
|
||||
public static ValidationResult? ValidateNoDuplicatePublications(CreateBulkEntradaSalidaCanillaDto dto, ValidationContext context)
|
||||
{
|
||||
if (dto.Items != null)
|
||||
{
|
||||
var duplicatePublications = dto.Items
|
||||
.GroupBy(item => item.IdPublicacion)
|
||||
.Where(group => group.Count() > 1)
|
||||
.Select(group => group.Key)
|
||||
.ToList();
|
||||
|
||||
if (duplicatePublications.Any())
|
||||
{
|
||||
return new ValidationResult($"No puede agregar la misma publicación varias veces. Publicaciones duplicadas: {string.Join(", ", duplicatePublications)}");
|
||||
}
|
||||
}
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class CreateControlDevolucionesDto
|
||||
{
|
||||
[Required]
|
||||
public int IdEmpresa { get; set; }
|
||||
[Required]
|
||||
public DateTime Fecha { get; set; }
|
||||
[Required, Range(0, int.MaxValue)] // Entrada puede ser 0 si solo hay sobrantes/sin cargo
|
||||
public int Entrada { get; set; }
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int Sobrantes { get; set; }
|
||||
[StringLength(250)]
|
||||
public string? Detalle { get; set; }
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int SinCargo { get; set; } = 0; // Default 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class CreateEntradaSalidaCanillaDto
|
||||
{
|
||||
[Required]
|
||||
public int IdPublicacion { get; set; }
|
||||
[Required]
|
||||
public int IdCanilla { get; set; }
|
||||
[Required]
|
||||
public DateTime Fecha { get; set; } // Fecha del movimiento (retiro/devolución)
|
||||
[Required, Range(0, int.MaxValue)] // Puede retirar 0 si es solo para registrar devolución
|
||||
public int CantSalida { get; set; }
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int CantEntrada { get; set; }
|
||||
[StringLength(150)]
|
||||
public string? Observacion { get; set; }
|
||||
// Liquidado, FechaLiquidado, UserLiq se manejan por una acción de "Liquidar" separada.
|
||||
// IdPrecio, IdRecargo, IdPorcMon se determinan en el backend.
|
||||
|
||||
[CustomValidation(typeof(CreateEntradaSalidaCanillaDto), nameof(ValidateCantidades))]
|
||||
public string? CantidadesError { get; set; } // Dummy para validación
|
||||
|
||||
public static ValidationResult? ValidateCantidades(CreateEntradaSalidaCanillaDto dto, ValidationContext context)
|
||||
{
|
||||
if (dto.CantEntrada > dto.CantSalida)
|
||||
{
|
||||
return new ValidationResult("La cantidad de entrada (devolución) no puede ser mayor a la cantidad de salida (retiro).");
|
||||
}
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class EntradaSalidaCanillaDto
|
||||
{
|
||||
public int IdParte { get; set; }
|
||||
public int IdPublicacion { get; set; }
|
||||
public string NombrePublicacion { get; set; } = string.Empty;
|
||||
public int IdCanilla { get; set; }
|
||||
public string NomApeCanilla { get; set; } = string.Empty;
|
||||
public bool CanillaEsAccionista { get; set; }
|
||||
public string Fecha { get; set; } = string.Empty; // yyyy-MM-dd
|
||||
public int CantSalida { get; set; }
|
||||
public int CantEntrada { get; set; }
|
||||
public int Vendidos { get; set; } // Calculado
|
||||
public string? Observacion { get; set; }
|
||||
public bool Liquidado { get; set; }
|
||||
public string? FechaLiquidado { get; set; } // yyyy-MM-dd
|
||||
public int? UserLiq { get; set; }
|
||||
public string? NombreUserLiq { get; set; } // Para mostrar en UI
|
||||
public decimal MontoARendir { get; set; } // Calculado por el backend
|
||||
public decimal PrecioUnitarioAplicado { get; set; } // Info para UI
|
||||
public decimal RecargoAplicado { get; set; } // Info para UI
|
||||
public decimal PorcentajeOMontoCanillaAplicado { get; set; } // Info para UI
|
||||
public bool EsPorcentajeCanilla { get; set; } // Info para UI
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class EntradaSalidaCanillaItemDto
|
||||
{
|
||||
[Required(ErrorMessage = "El ID de la publicación es obligatorio.")]
|
||||
public int IdPublicacion { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "La cantidad de salida es obligatoria.")]
|
||||
[Range(0, int.MaxValue, ErrorMessage = "La cantidad de salida debe ser un número positivo o cero.")]
|
||||
public int CantSalida { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "La cantidad de entrada es obligatoria.")]
|
||||
[Range(0, int.MaxValue, ErrorMessage = "La cantidad de entrada debe ser un número positivo o cero.")]
|
||||
public int CantEntrada { get; set; }
|
||||
|
||||
[StringLength(150)]
|
||||
public string? Observacion { get; set; } // Observación por línea
|
||||
|
||||
// Validar que CantEntrada no sea mayor que CantSalida
|
||||
[CustomValidation(typeof(EntradaSalidaCanillaItemDto), nameof(ValidateCantidades))]
|
||||
public string? CantidadesError { get; set; }
|
||||
|
||||
public static ValidationResult? ValidateCantidades(EntradaSalidaCanillaItemDto item, ValidationContext context)
|
||||
{
|
||||
if (item.CantEntrada > item.CantSalida)
|
||||
{
|
||||
return new ValidationResult("La cantidad de entrada (devolución) no puede ser mayor a la cantidad de salida (retiro) para esta publicación.", new[] { nameof(CantEntrada) });
|
||||
}
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class LiquidarMovimientosCanillaRequestDto // Para liquidar uno o más movimientos
|
||||
{
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<int> IdsPartesALiquidar { get; set; } = new List<int>();
|
||||
[Required]
|
||||
public DateTime FechaLiquidacion { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class UpdateControlDevolucionesDto
|
||||
{
|
||||
// IdEmpresa y Fecha no deberían cambiar para un registro existente. Si cambian, es un nuevo registro.
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int Entrada { get; set; }
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int Sobrantes { get; set; }
|
||||
[StringLength(250)]
|
||||
public string? Detalle { get; set; }
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int SinCargo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Similar a E/S Distribuidores, la edición es limitada para no afectar cálculos complejos ya hechos.
|
||||
// Principalmente para corregir cantidades si aún no está liquidado.
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace GestionIntegral.Api.Dtos.Distribucion
|
||||
{
|
||||
public class UpdateEntradaSalidaCanillaDto
|
||||
{
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int CantSalida { get; set; }
|
||||
[Required, Range(0, int.MaxValue)]
|
||||
public int CantEntrada { get; set; }
|
||||
[StringLength(150)]
|
||||
public string? Observacion { get; set; }
|
||||
|
||||
[CustomValidation(typeof(UpdateEntradaSalidaCanillaDto), nameof(ValidateCantidades))]
|
||||
public string? CantidadesError { get; set; } // Dummy para validación
|
||||
|
||||
public static ValidationResult? ValidateCantidades(UpdateEntradaSalidaCanillaDto dto, ValidationContext context)
|
||||
{
|
||||
if (dto.CantEntrada > dto.CantSalida)
|
||||
{
|
||||
return new ValidationResult("La cantidad de entrada no puede ser mayor a la de salida.");
|
||||
}
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user