34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
|
|
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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|