add new
This commit is contained in:
101
RS_system/Models/Articulo.cs
Normal file
101
RS_system/Models/Articulo.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("articulos")]
|
||||
public class Articulo
|
||||
{
|
||||
public enum TipoControlInventario
|
||||
{
|
||||
UNITARIO, // 1 record = 1 physical item (Laptop, Projector)
|
||||
LOTE // 1 record = N items (Chairs, Cables)
|
||||
}
|
||||
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("tipo_control")]
|
||||
[Required]
|
||||
public string TipoControl { get; set; } = nameof(TipoControlInventario.UNITARIO);
|
||||
|
||||
[Column("cantidad_global")]
|
||||
public int CantidadGlobal { get; set; } = 1; // Cache/Total for LOTE. Always 1 for UNITARIO.
|
||||
|
||||
[Column("codigo")]
|
||||
[Required(ErrorMessage = "El código es obligatorio")]
|
||||
[StringLength(50, ErrorMessage = "El código no puede exceder los 50 caracteres")]
|
||||
public string Codigo { get; set; } = string.Empty;
|
||||
|
||||
[Column("nombre")]
|
||||
[Required(ErrorMessage = "El nombre es obligatorio")]
|
||||
[StringLength(100, ErrorMessage = "El nombre no puede exceder los 100 caracteres")]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(500, ErrorMessage = "La descripción no puede exceder los 500 caracteres")]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[Column("marca")]
|
||||
[StringLength(100)]
|
||||
public string? Marca { get; set; }
|
||||
|
||||
[Column("modelo")]
|
||||
[StringLength(100)]
|
||||
public string? Modelo { get; set; }
|
||||
|
||||
[Column("numero_serie")]
|
||||
[StringLength(100)]
|
||||
public string? NumeroSerie { get; set; }
|
||||
|
||||
[Column("precio")]
|
||||
[Range(0, 99999999.99)]
|
||||
public decimal Precio { get; set; } = 0;
|
||||
|
||||
[Column("fecha_adquisicion")]
|
||||
public DateOnly? FechaAdquisicion { get; set; }
|
||||
|
||||
[Column("imagen_url")]
|
||||
public string? ImagenUrl { get; set; }
|
||||
|
||||
// Foreign Keys
|
||||
|
||||
[Column("categoria_id")]
|
||||
public int CategoriaId { get; set; }
|
||||
|
||||
[Column("estado_id")]
|
||||
public int EstadoId { get; set; }
|
||||
|
||||
[Column("ubicacion_id")]
|
||||
public int UbicacionId { get; set; }
|
||||
|
||||
// Audit & Control
|
||||
|
||||
[Column("activo")]
|
||||
public bool Activo { get; set; } = true;
|
||||
|
||||
[Column("eliminado")]
|
||||
public bool Eliminado { get; set; } = false;
|
||||
|
||||
[Column("creado_en")]
|
||||
public DateTime CreadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("actualizado_en")]
|
||||
public DateTime ActualizadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("creado_por")]
|
||||
[StringLength(100)]
|
||||
public string? CreadoPor { get; set; }
|
||||
|
||||
// Navigation Properties
|
||||
|
||||
[ForeignKey("CategoriaId")]
|
||||
public virtual Categoria? Categoria { get; set; }
|
||||
|
||||
[ForeignKey("EstadoId")]
|
||||
public virtual EstadoArticulo? Estado { get; set; }
|
||||
|
||||
[ForeignKey("UbicacionId")]
|
||||
public virtual Ubicacion? Ubicacion { get; set; }
|
||||
}
|
||||
37
RS_system/Models/Categoria.cs
Normal file
37
RS_system/Models/Categoria.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("categorias")]
|
||||
public class Categoria
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("nombre")]
|
||||
[Required(ErrorMessage = "El nombre es obligatorio")]
|
||||
[StringLength(100, ErrorMessage = "El nombre no puede exceder los 100 caracteres")]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(500, ErrorMessage = "La descripción no puede exceder los 500 caracteres")]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[Column("activo")]
|
||||
public bool Activo { get; set; } = true;
|
||||
|
||||
[Column("eliminado")]
|
||||
public bool Eliminado { get; set; } = false;
|
||||
|
||||
[Column("creado_en")]
|
||||
public DateTime CreadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("actualizado_en")]
|
||||
public DateTime ActualizadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("creado_por")]
|
||||
[StringLength(100)]
|
||||
public string? CreadoPor { get; set; }
|
||||
}
|
||||
30
RS_system/Models/CategoriaEgreso.cs
Normal file
30
RS_system/Models/CategoriaEgreso.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("categorias_egreso")]
|
||||
public class CategoriaEgreso
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("nombre")]
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(255)]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[Column("activa")]
|
||||
public bool Activa { get; set; } = true;
|
||||
|
||||
[Column("fecha_creacion")]
|
||||
public DateTime FechaCreacion { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation property
|
||||
public virtual ICollection<MovimientoGeneral> Movimientos { get; set; } = new List<MovimientoGeneral>();
|
||||
}
|
||||
30
RS_system/Models/CategoriaIngreso.cs
Normal file
30
RS_system/Models/CategoriaIngreso.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("categorias_ingreso")]
|
||||
public class CategoriaIngreso
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("nombre")]
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(255)]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[Column("activa")]
|
||||
public bool Activa { get; set; } = true;
|
||||
|
||||
[Column("fecha_creacion")]
|
||||
public DateTime FechaCreacion { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation property
|
||||
public virtual ICollection<MovimientoGeneral> Movimientos { get; set; } = new List<MovimientoGeneral>();
|
||||
}
|
||||
42
RS_system/Models/Colaboracion.cs
Normal file
42
RS_system/Models/Colaboracion.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("colaboraciones", Schema = "public")]
|
||||
public class Colaboracion
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("miembro_id")]
|
||||
public long MiembroId { get; set; }
|
||||
|
||||
[Column("fecha_registro")]
|
||||
public DateTime FechaRegistro { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Required]
|
||||
[Column("monto_total")]
|
||||
public decimal MontoTotal { get; set; }
|
||||
|
||||
[Column("observaciones")]
|
||||
public string? Observaciones { get; set; }
|
||||
|
||||
[MaxLength(100)]
|
||||
[Column("registrado_por")]
|
||||
public string? RegistradoPor { get; set; }
|
||||
|
||||
[Column("creado_en")]
|
||||
public DateTime CreadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("actualizado_en")]
|
||||
public DateTime ActualizadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation properties
|
||||
[ForeignKey("MiembroId")]
|
||||
public Miembro Miembro { get; set; } = null!;
|
||||
|
||||
public ICollection<DetalleColaboracion> Detalles { get; set; } = new List<DetalleColaboracion>();
|
||||
}
|
||||
49
RS_system/Models/ContabilidadRegistro.cs
Normal file
49
RS_system/Models/ContabilidadRegistro.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
public enum TipoMovimientoContable
|
||||
{
|
||||
Ingreso,
|
||||
Egreso
|
||||
}
|
||||
|
||||
[Table("contabilidad_registros")]
|
||||
public class ContabilidadRegistro
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("reporte_mensual_id")]
|
||||
public long? ReporteMensualId { get; set; }
|
||||
|
||||
[ForeignKey("ReporteMensualId")]
|
||||
public virtual ReporteMensualContable? ReporteMensual { get; set; }
|
||||
|
||||
[Column("grupo_trabajo_id")]
|
||||
[Required]
|
||||
public long GrupoTrabajoId { get; set; }
|
||||
|
||||
[ForeignKey("GrupoTrabajoId")]
|
||||
public virtual GrupoTrabajo GrupoTrabajo { get; set; }
|
||||
|
||||
[Column("tipo")]
|
||||
[Required]
|
||||
public TipoMovimientoContable Tipo { get; set; }
|
||||
|
||||
[Column("monto", TypeName = "decimal(18,2)")]
|
||||
[Required]
|
||||
public decimal Monto { get; set; }
|
||||
|
||||
|
||||
[Column("fecha")]
|
||||
[Required]
|
||||
public DateTime Fecha { get; set; }
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(200)]
|
||||
public string Descripcion { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
44
RS_system/Models/DetalleColaboracion.cs
Normal file
44
RS_system/Models/DetalleColaboracion.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("detalle_colaboraciones", Schema = "public")]
|
||||
public class DetalleColaboracion
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("colaboracion_id")]
|
||||
public long ColaboracionId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("tipo_colaboracion_id")]
|
||||
public long TipoColaboracionId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Range(1, 12)]
|
||||
[Column("mes")]
|
||||
public int Mes { get; set; }
|
||||
|
||||
[Required]
|
||||
[Range(2000, 2100)]
|
||||
[Column("anio")]
|
||||
public int Anio { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("monto")]
|
||||
public decimal Monto { get; set; }
|
||||
|
||||
[Column("creado_en")]
|
||||
public DateTime CreadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation properties
|
||||
[ForeignKey("ColaboracionId")]
|
||||
public Colaboracion Colaboracion { get; set; } = null!;
|
||||
|
||||
[ForeignKey("TipoColaboracionId")]
|
||||
public TipoColaboracion TipoColaboracion { get; set; } = null!;
|
||||
}
|
||||
41
RS_system/Models/EstadoArticulo.cs
Normal file
41
RS_system/Models/EstadoArticulo.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("estados_articulos")]
|
||||
public class EstadoArticulo
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("nombre")]
|
||||
[Required(ErrorMessage = "El nombre es obligatorio")]
|
||||
[StringLength(50, ErrorMessage = "El nombre no puede exceder los 50 caracteres")]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(200, ErrorMessage = "La descripción no puede exceder los 200 caracteres")]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[Column("color")]
|
||||
[StringLength(20)]
|
||||
public string? Color { get; set; } = "secondary"; // success, warning, danger, info, primary, secondary
|
||||
|
||||
[Column("activo")]
|
||||
public bool Activo { get; set; } = true;
|
||||
|
||||
[Column("eliminado")]
|
||||
public bool Eliminado { get; set; } = false;
|
||||
|
||||
[Column("creado_en")]
|
||||
public DateTime CreadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("actualizado_en")]
|
||||
public DateTime ActualizadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("creado_por")]
|
||||
[StringLength(100)]
|
||||
public string? CreadoPor { get; set; }
|
||||
}
|
||||
31
RS_system/Models/Existencia.cs
Normal file
31
RS_system/Models/Existencia.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("existencias")]
|
||||
public class Existencia
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("articulo_id")]
|
||||
public int ArticuloId { get; set; }
|
||||
|
||||
[Column("ubicacion_id")]
|
||||
public int UbicacionId { get; set; }
|
||||
|
||||
[Column("cantidad")]
|
||||
public int Cantidad { get; set; } = 0;
|
||||
|
||||
[Column("actualizado_en")]
|
||||
public DateTime ActualizadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation
|
||||
[ForeignKey("ArticuloId")]
|
||||
public virtual Articulo? Articulo { get; set; }
|
||||
|
||||
[ForeignKey("UbicacionId")]
|
||||
public virtual Ubicacion? Ubicacion { get; set; }
|
||||
}
|
||||
59
RS_system/Models/MovimientoGeneral.cs
Normal file
59
RS_system/Models/MovimientoGeneral.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
public enum TipoMovimientoGeneral
|
||||
{
|
||||
Ingreso = 1,
|
||||
Egreso = 2
|
||||
}
|
||||
|
||||
[Table("movimientos_generales")]
|
||||
public class MovimientoGeneral
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("reporte_mensual_general_id")]
|
||||
public long? ReporteMensualGeneralId { get; set; }
|
||||
|
||||
[ForeignKey("ReporteMensualGeneralId")]
|
||||
public virtual ReporteMensualGeneral? ReporteMensualGeneral { get; set; }
|
||||
|
||||
[Column("tipo")]
|
||||
[Required]
|
||||
public int Tipo { get; set; }
|
||||
|
||||
[Column("categoria_ingreso_id")]
|
||||
public long? CategoriaIngresoId { get; set; }
|
||||
|
||||
[ForeignKey("CategoriaIngresoId")]
|
||||
public virtual CategoriaIngreso? CategoriaIngreso { get; set; }
|
||||
|
||||
[Column("categoria_egreso_id")]
|
||||
public long? CategoriaEgresoId { get; set; }
|
||||
|
||||
[ForeignKey("CategoriaEgresoId")]
|
||||
public virtual CategoriaEgreso? CategoriaEgreso { get; set; }
|
||||
|
||||
[Column("monto", TypeName = "decimal(18,2)")]
|
||||
[Required]
|
||||
public decimal Monto { get; set; }
|
||||
|
||||
[Column("fecha")]
|
||||
[Required]
|
||||
public DateTime Fecha { get; set; }
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(200)]
|
||||
public string Descripcion { get; set; } = string.Empty;
|
||||
|
||||
[Column("numero_comprobante")]
|
||||
[StringLength(50)]
|
||||
public string? NumeroComprobante { get; set; }
|
||||
|
||||
// Navigation property
|
||||
public virtual ICollection<MovimientoGeneralAdjunto> Adjuntos { get; set; } = new List<MovimientoGeneralAdjunto>();
|
||||
}
|
||||
36
RS_system/Models/MovimientoGeneralAdjunto.cs
Normal file
36
RS_system/Models/MovimientoGeneralAdjunto.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("movimientos_generales_adjuntos")]
|
||||
public class MovimientoGeneralAdjunto
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("movimiento_general_id")]
|
||||
[Required]
|
||||
public long MovimientoGeneralId { get; set; }
|
||||
|
||||
[ForeignKey("MovimientoGeneralId")]
|
||||
public virtual MovimientoGeneral MovimientoGeneral { get; set; }
|
||||
|
||||
[Column("nombre_archivo")]
|
||||
[Required]
|
||||
[StringLength(255)]
|
||||
public string NombreArchivo { get; set; } = string.Empty;
|
||||
|
||||
[Column("ruta_archivo")]
|
||||
[Required]
|
||||
[StringLength(500)]
|
||||
public string RutaArchivo { get; set; } = string.Empty;
|
||||
|
||||
[Column("tipo_contenido")]
|
||||
[StringLength(100)]
|
||||
public string? TipoContenido { get; set; }
|
||||
|
||||
[Column("fecha_subida")]
|
||||
public DateTime FechaSubida { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
80
RS_system/Models/MovimientoInventario.cs
Normal file
80
RS_system/Models/MovimientoInventario.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
public enum TipoMovimiento
|
||||
{
|
||||
ENTRADA, // Nueva adquisición (aunque se crea al crear art, podría usarse para reingresos)
|
||||
SALIDA, // Salida temporal
|
||||
TRASLADO, // Cambio de ubicación
|
||||
BAJA, // Retiro permanente (daño, robo, venta)
|
||||
REPARACION, // Envío a taller
|
||||
AJUSTE, // Corrección de inventario
|
||||
CAMBIO_ESTADO, // Cambio de condición física
|
||||
PRESTAMO, // Préstamo a persona
|
||||
DEVOLUCION
|
||||
}
|
||||
|
||||
[Table("movimientos_inventario")]
|
||||
public class MovimientoInventario
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("articulo_id")]
|
||||
[Required]
|
||||
public int ArticuloId { get; set; }
|
||||
|
||||
[Column("tipo_movimiento")]
|
||||
[Required]
|
||||
public string TipoMovimiento { get; set; } = string.Empty;
|
||||
|
||||
[Column("cantidad")]
|
||||
public int Cantidad { get; set; } = 1; // Default 1 for UNITARIO
|
||||
|
||||
[Column("fecha")]
|
||||
public DateTime Fecha { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Ubicaciones
|
||||
[Column("ubicacion_origen_id")]
|
||||
public int? UbicacionOrigenId { get; set; }
|
||||
|
||||
[Column("ubicacion_destino_id")]
|
||||
public int? UbicacionDestinoId { get; set; }
|
||||
|
||||
// Estados
|
||||
[Column("estado_anterior_id")]
|
||||
public int? EstadoAnteriorId { get; set; }
|
||||
|
||||
[Column("estado_nuevo_id")]
|
||||
public int? EstadoNuevoId { get; set; }
|
||||
|
||||
[Column("TipMov")]
|
||||
public int? TipMov { get; set; }
|
||||
|
||||
[Column("observacion")]
|
||||
[StringLength(500)]
|
||||
public string? Observacion { get; set; }
|
||||
|
||||
[Column("usuario_id")]
|
||||
[StringLength(100)]
|
||||
public string? UsuarioId { get; set; } // Username or User ID
|
||||
|
||||
// Navigation Properties
|
||||
[ForeignKey("ArticuloId")]
|
||||
public virtual Articulo? Articulo { get; set; }
|
||||
|
||||
[ForeignKey("UbicacionOrigenId")]
|
||||
public virtual Ubicacion? UbicacionOrigen { get; set; }
|
||||
|
||||
[ForeignKey("UbicacionDestinoId")]
|
||||
public virtual Ubicacion? UbicacionDestino { get; set; }
|
||||
|
||||
[ForeignKey("EstadoAnteriorId")]
|
||||
public virtual EstadoArticulo? EstadoAnterior { get; set; }
|
||||
|
||||
[ForeignKey("EstadoNuevoId")]
|
||||
public virtual EstadoArticulo? EstadoNuevo { get; set; }
|
||||
}
|
||||
89
RS_system/Models/Prestamo.cs
Normal file
89
RS_system/Models/Prestamo.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("prestamos")]
|
||||
public class Prestamo
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("articulo_id")]
|
||||
[Required]
|
||||
public int ArticuloId { get; set; }
|
||||
|
||||
[Column("cantidad")]
|
||||
[Required]
|
||||
public int Cantidad { get; set; }
|
||||
|
||||
[Column("persona_nombre")]
|
||||
[Required]
|
||||
[StringLength(200)]
|
||||
public string PersonaNombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("persona_identificacion")]
|
||||
[StringLength(50)]
|
||||
public string? PersonaIdentificacion { get; set; }
|
||||
|
||||
[Column("fecha_prestamo")]
|
||||
public DateTime FechaPrestamo { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("fecha_devolucion_estimada")]
|
||||
public DateTime? FechaDevolucionEstimada { get; set; }
|
||||
|
||||
[Column("fecha_devolucion_real")]
|
||||
public DateTime? FechaDevolucionReal { get; set; }
|
||||
|
||||
[Column("estado")]
|
||||
[Required]
|
||||
public string Estado { get; set; } = "ACTIVO"; // ACTIVO, DEVUELTO, ATRASADO
|
||||
|
||||
[Column("observacion")]
|
||||
[StringLength(500)]
|
||||
public string? Observacion { get; set; }
|
||||
|
||||
[Column("usuario_id")]
|
||||
[StringLength(100)]
|
||||
public string? UsuarioId { get; set; }
|
||||
|
||||
// Navigation Properties
|
||||
[ForeignKey("ArticuloId")]
|
||||
public virtual Articulo? Articulo { get; set; }
|
||||
|
||||
// Navigation Property for detailed items
|
||||
public virtual ICollection<PrestamoDetalle> Detalles { get; set; } = new List<PrestamoDetalle>();
|
||||
}
|
||||
|
||||
[Table("prestamo_detalles")]
|
||||
public class PrestamoDetalle
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("prestamo_id")]
|
||||
[Required]
|
||||
public long PrestamoId { get; set; }
|
||||
|
||||
[Column("codigo_articulo_individual")]
|
||||
[Required]
|
||||
[StringLength(100)]
|
||||
public string CodigoArticuloIndividual { get; set; } = string.Empty;
|
||||
|
||||
[Column("estado")]
|
||||
[Required]
|
||||
public string Estado { get; set; } = "PRESTADO"; // PRESTADO, DEVUELTO
|
||||
|
||||
[Column("fecha_devolucion")]
|
||||
public DateTime? FechaDevolucion { get; set; }
|
||||
|
||||
[Column("observacion")]
|
||||
[StringLength(300)]
|
||||
public string? Observacion { get; set; }
|
||||
|
||||
// Navigation Properties
|
||||
[ForeignKey("PrestamoId")]
|
||||
public virtual Prestamo? Prestamo { get; set; }
|
||||
}
|
||||
44
RS_system/Models/ReporteMensualContable.cs
Normal file
44
RS_system/Models/ReporteMensualContable.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("reportes_mensuales_contables")]
|
||||
public class ReporteMensualContable
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("grupo_trabajo_id")]
|
||||
[Required]
|
||||
public long GrupoTrabajoId { get; set; }
|
||||
|
||||
[ForeignKey("GrupoTrabajoId")]
|
||||
public virtual GrupoTrabajo GrupoTrabajo { get; set; }
|
||||
|
||||
[Column("mes")]
|
||||
[Required]
|
||||
public int Mes { get; set; }
|
||||
|
||||
[Column("anio")]
|
||||
[Required]
|
||||
public int Anio { get; set; }
|
||||
|
||||
[Column("saldo_inicial", TypeName = "decimal(18,2)")]
|
||||
public decimal SaldoInicial { get; set; }
|
||||
|
||||
|
||||
[Column("fecha_creacion")]
|
||||
public DateTime FechaCreacion { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("cerrado")]
|
||||
public bool Cerrado { get; set; } = false;
|
||||
|
||||
// Navigation property for details
|
||||
public virtual ICollection<ContabilidadRegistro> Registros { get; set; } = new List<ContabilidadRegistro>();
|
||||
|
||||
// Helper properties for display
|
||||
[NotMapped]
|
||||
public string NombreMes => new DateTime(Anio, Mes, 1).ToString("MMMM", new System.Globalization.CultureInfo("es-ES"));
|
||||
}
|
||||
36
RS_system/Models/ReporteMensualGeneral.cs
Normal file
36
RS_system/Models/ReporteMensualGeneral.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("reportes_mensuales_generales")]
|
||||
public class ReporteMensualGeneral
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Column("mes")]
|
||||
[Required]
|
||||
public int Mes { get; set; }
|
||||
|
||||
[Column("anio")]
|
||||
[Required]
|
||||
public int Anio { get; set; }
|
||||
|
||||
[Column("saldo_inicial", TypeName = "decimal(18,2)")]
|
||||
public decimal SaldoInicial { get; set; }
|
||||
|
||||
[Column("fecha_creacion")]
|
||||
public DateTime FechaCreacion { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("cerrado")]
|
||||
public bool Cerrado { get; set; } = false;
|
||||
|
||||
// Navigation property for details
|
||||
public virtual ICollection<MovimientoGeneral> Movimientos { get; set; } = new List<MovimientoGeneral>();
|
||||
|
||||
// Helper properties for display
|
||||
[NotMapped]
|
||||
public string NombreMes => new DateTime(Anio, Mes, 1).ToString("MMMM", new System.Globalization.CultureInfo("es-ES"));
|
||||
}
|
||||
39
RS_system/Models/TipoColaboracion.cs
Normal file
39
RS_system/Models/TipoColaboracion.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("tipos_colaboracion", Schema = "public")]
|
||||
public class TipoColaboracion
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
[Column("nombre")]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("descripcion")]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[Column("monto_sugerido")]
|
||||
[Required]
|
||||
public decimal MontoSugerido { get; set; }
|
||||
|
||||
[Column("activo")]
|
||||
public bool Activo { get; set; } = true;
|
||||
|
||||
[Column("orden")]
|
||||
public int Orden { get; set; }
|
||||
|
||||
[Column("creado_en")]
|
||||
public DateTime CreadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("actualizado_en")]
|
||||
public DateTime ActualizadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation properties
|
||||
public ICollection<DetalleColaboracion> Detalles { get; set; } = new List<DetalleColaboracion>();
|
||||
}
|
||||
41
RS_system/Models/Ubicacion.cs
Normal file
41
RS_system/Models/Ubicacion.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Rs_system.Models;
|
||||
|
||||
[Table("ubicaciones")]
|
||||
public class Ubicacion
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("nombre")]
|
||||
[Required(ErrorMessage = "El nombre es obligatorio")]
|
||||
[StringLength(100, ErrorMessage = "El nombre no puede exceder los 100 caracteres")]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[Column("descripcion")]
|
||||
[StringLength(200, ErrorMessage = "La descripción no puede exceder los 200 caracteres")]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[Column("responsable")]
|
||||
[StringLength(100, ErrorMessage = "El nombre del responsable no puede exceder los 100 caracteres")]
|
||||
public string? Responsable { get; set; }
|
||||
|
||||
[Column("activo")]
|
||||
public bool Activo { get; set; } = true;
|
||||
|
||||
[Column("eliminado")]
|
||||
public bool Eliminado { get; set; } = false;
|
||||
|
||||
[Column("creado_en")]
|
||||
public DateTime CreadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("actualizado_en")]
|
||||
public DateTime ActualizadoEn { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[Column("creado_por")]
|
||||
[StringLength(100)]
|
||||
public string? CreadoPor { get; set; }
|
||||
}
|
||||
68
RS_system/Models/ViewModels/ArticuloViewModel.cs
Normal file
68
RS_system/Models/ViewModels/ArticuloViewModel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Rs_system.Models;
|
||||
|
||||
namespace Rs_system.Models.ViewModels;
|
||||
|
||||
public class ArticuloViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "El código es obligatorio")]
|
||||
[StringLength(50, ErrorMessage = "El código no puede exceder los 50 caracteres")]
|
||||
public string Codigo { get; set; } = string.Empty;
|
||||
|
||||
[Required(ErrorMessage = "El nombre es obligatorio")]
|
||||
[StringLength(100, ErrorMessage = "El nombre no puede exceder los 100 caracteres")]
|
||||
public string Nombre { get; set; } = string.Empty;
|
||||
|
||||
[StringLength(500, ErrorMessage = "La descripción no puede exceder los 500 caracteres")]
|
||||
public string? Descripcion { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string? Marca { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string? Modelo { get; set; }
|
||||
|
||||
[Display(Name = "Número de Serie")]
|
||||
[StringLength(100)]
|
||||
public string? NumeroSerie { get; set; }
|
||||
|
||||
[Range(0, 99999999.99)]
|
||||
public decimal Precio { get; set; } = 0;
|
||||
|
||||
[Display(Name = "Fecha de Adquisición")]
|
||||
public DateOnly? FechaAdquisicion { get; set; }
|
||||
|
||||
public string? ImagenUrl { get; set; }
|
||||
|
||||
[Display(Name = "Imagen")]
|
||||
public IFormFile? ImagenFile { get; set; }
|
||||
|
||||
[Display(Name = "Tipo de Control")]
|
||||
public string? TipoControl { get; set; } = "UNITARIO"; // Default for View
|
||||
|
||||
[Display(Name = "Cantidad Inicial")]
|
||||
[Range(1, 100000)]
|
||||
public int CantidadInicial { get; set; } = 1;
|
||||
|
||||
public int CategoriaId { get; set; }
|
||||
|
||||
[Display(Name = "Estado")]
|
||||
[Required(ErrorMessage = "El estado es obligatorio")]
|
||||
public int EstadoId { get; set; }
|
||||
|
||||
[Display(Name = "Ubicación")]
|
||||
[Required(ErrorMessage = "La ubicación es obligatoria")]
|
||||
public int UbicacionId { get; set; }
|
||||
|
||||
public bool Activo { get; set; } = true;
|
||||
|
||||
// Display properties for lists/details
|
||||
public string? CategoriaNombre { get; set; }
|
||||
public string? EstadoNombre { get; set; }
|
||||
public string? EstadoColor { get; set; }
|
||||
public string? UbicacionNombre { get; set; }
|
||||
public int CantidadGlobal { get; set; }
|
||||
}
|
||||
41
RS_system/Models/ViewModels/EstadoCuentaViewModel.cs
Normal file
41
RS_system/Models/ViewModels/EstadoCuentaViewModel.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace Rs_system.Models.ViewModels;
|
||||
|
||||
public class EstadoCuentaViewModel
|
||||
{
|
||||
public long MiembroId { get; set; }
|
||||
public string NombreMiembro { get; set; } = string.Empty;
|
||||
public DateTime FechaConsulta { get; set; }
|
||||
|
||||
public List<HistorialPorTipo> HistorialPorTipos { get; set; } = new();
|
||||
public decimal TotalAportado { get; set; }
|
||||
}
|
||||
|
||||
public class HistorialPorTipo
|
||||
{
|
||||
public string TipoNombre { get; set; } = string.Empty;
|
||||
public List<RegistroMensual> Registros { get; set; } = new();
|
||||
public decimal TotalTipo { get; set; }
|
||||
}
|
||||
|
||||
public class RegistroMensual
|
||||
{
|
||||
public int Mes { get; set; }
|
||||
public int Anio { get; set; }
|
||||
public decimal Monto { get; set; }
|
||||
public DateTime FechaRegistro { get; set; }
|
||||
|
||||
public string MesTexto => ObtenerMesTexto();
|
||||
|
||||
private string ObtenerMesTexto()
|
||||
{
|
||||
try
|
||||
{
|
||||
var fecha = new DateTime(Anio, Mes, 1);
|
||||
return fecha.ToString("MMMM yyyy", new System.Globalization.CultureInfo("es-ES"));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return $"{Mes}/{Anio}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Rs_system.Models;
|
||||
|
||||
namespace Rs_system.Models.ViewModels;
|
||||
|
||||
public class RegistrarColaboracionViewModel
|
||||
{
|
||||
[Required(ErrorMessage = "Debe seleccionar un miembro")]
|
||||
public long MiembroId { get; set; }
|
||||
|
||||
[Display(Name = "Mes Inicial")]
|
||||
[Required(ErrorMessage = "Debe seleccionar el mes inicial")]
|
||||
[Range(1, 12, ErrorMessage = "Mes debe estar entre 1 y 12")]
|
||||
public int MesInicial { get; set; }
|
||||
|
||||
[Display(Name = "Año Inicial")]
|
||||
[Required(ErrorMessage = "Debe seleccionar el año inicial")]
|
||||
[Range(2000, 2100, ErrorMessage = "Año debe estar entre 2000 y 2100")]
|
||||
public int AnioInicial { get; set; }
|
||||
|
||||
[Display(Name = "Mes Final")]
|
||||
[Required(ErrorMessage = "Debe seleccionar el mes final")]
|
||||
[Range(1, 12, ErrorMessage = "Mes debe estar entre 1 y 12")]
|
||||
public int MesFinal { get; set; }
|
||||
|
||||
[Display(Name = "Año Final")]
|
||||
[Required(ErrorMessage = "Debe seleccionar el año final")]
|
||||
[Range(2000, 2100, ErrorMessage = "Año debe estar entre 2000 y 2100")]
|
||||
public int AnioFinal { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Debe seleccionar al menos un tipo de colaboración")]
|
||||
public List<long> TiposSeleccionados { get; set; } = new();
|
||||
|
||||
[Required(ErrorMessage = "Debe ingresar el monto total")]
|
||||
[Range(0.01, 999999.99, ErrorMessage = "El monto total debe ser mayor a 0")]
|
||||
[Display(Name = "Monto Total Entregado")]
|
||||
public decimal MontoTotal { get; set; }
|
||||
|
||||
[Display(Name = "Tipo de Colaboración Prioritaria")]
|
||||
public long? TipoPrioritario { get; set; }
|
||||
|
||||
[MaxLength(500, ErrorMessage = "Las observaciones no pueden exceder 500 caracteres")]
|
||||
[Display(Name = "Observaciones")]
|
||||
public string? Observaciones { get; set; }
|
||||
|
||||
// Para cargar en el formulario
|
||||
public List<TipoColaboracion> TiposDisponibles { get; set; } = new();
|
||||
|
||||
// Propiedad calculada: Total de meses
|
||||
public int TotalMeses
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var fechaInicial = new DateTime(AnioInicial, MesInicial, 1);
|
||||
var fechaFinal = new DateTime(AnioFinal, MesFinal, 1);
|
||||
|
||||
if (fechaFinal < fechaInicial)
|
||||
return 0;
|
||||
|
||||
return ((AnioFinal - AnioInicial) * 12) + (MesFinal - MesInicial) + 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Propiedad calculada: Monto sugerido total basado en los tipos seleccionados
|
||||
public decimal MontoSugeridoTotal
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TiposDisponibles == null || !TiposSeleccionados.Any())
|
||||
return 0;
|
||||
|
||||
var tiposSeleccionadosData = TiposDisponibles
|
||||
.Where(t => TiposSeleccionados.Contains(t.Id))
|
||||
.ToList();
|
||||
|
||||
var montoSugeridoPorMes = tiposSeleccionadosData.Sum(t => t.MontoSugerido);
|
||||
return montoSugeridoPorMes * TotalMeses;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace Rs_system.Models.ViewModels;
|
||||
|
||||
public class ReporteColaboracionesViewModel
|
||||
{
|
||||
public DateTime FechaInicio { get; set; }
|
||||
public DateTime FechaFin { get; set; }
|
||||
public decimal TotalRecaudado { get; set; }
|
||||
|
||||
public List<DesglosePorTipo> DesglosePorTipos { get; set; } = new();
|
||||
public List<DetalleMovimiento> Movimientos { get; set; } = new();
|
||||
}
|
||||
|
||||
public class DesglosePorTipo
|
||||
{
|
||||
public string TipoNombre { get; set; } = string.Empty;
|
||||
public int CantidadMeses { get; set; }
|
||||
public decimal TotalRecaudado { get; set; }
|
||||
}
|
||||
|
||||
public class DetalleMovimiento
|
||||
{
|
||||
public long ColaboracionId { get; set; }
|
||||
public DateTime Fecha { get; set; }
|
||||
public string NombreMiembro { get; set; } = string.Empty;
|
||||
public string TiposColaboracion { get; set; } = string.Empty;
|
||||
public string PeriodoCubierto { get; set; } = string.Empty;
|
||||
public decimal Monto { get; set; }
|
||||
}
|
||||
39
RS_system/Models/ViewModels/UltimoPagoViewModel.cs
Normal file
39
RS_system/Models/ViewModels/UltimoPagoViewModel.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
namespace Rs_system.Models.ViewModels;
|
||||
|
||||
public class UltimoPagoViewModel
|
||||
{
|
||||
public long TipoId { get; set; }
|
||||
public string NombreTipo { get; set; }
|
||||
public int UltimoMes { get; set; }
|
||||
public int UltimoAnio { get; set; }
|
||||
public DateTime FechaUltimoPago { get; set; }
|
||||
|
||||
public string UltimoPeriodoTexto
|
||||
{
|
||||
get
|
||||
{
|
||||
if (UltimoMes == 0 || UltimoAnio == 0) return "Sin pagos registrados";
|
||||
return $"{ObtenerNombreMes(UltimoMes)} {UltimoAnio}";
|
||||
}
|
||||
}
|
||||
|
||||
private string ObtenerNombreMes(int mes)
|
||||
{
|
||||
return mes switch
|
||||
{
|
||||
1 => "Enero",
|
||||
2 => "Febrero",
|
||||
3 => "Marzo",
|
||||
4 => "Abril",
|
||||
5 => "Mayo",
|
||||
6 => "Junio",
|
||||
7 => "Julio",
|
||||
8 => "Agosto",
|
||||
9 => "Septiembre",
|
||||
10 => "Octubre",
|
||||
11 => "Noviembre",
|
||||
12 => "Diciembre",
|
||||
_ => ""
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user