Files
2023-09-04 15:27:11 +02:00

121 lines
3.2 KiB
C#

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
#nullable disable
namespace SHERPA.BBM.CORE.DbModels
{
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
/// <summary>
/// Tabella dei Documenti
/// </summary>
[Table("Docs")]
public partial class DocsModel
{
public DocsModel()
{
FattNav = new HashSet<Fatt2DocModel>();
ResNav = new HashSet<ResourcesModel>();
}
[Key, Column("DocId", Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int DocId { get; set; }
[Column("CodDoc"), MaxLength(50)]
public string CodDoc { get; set; } = "EGW.D.0000.0000.00";
[Column("Anno")]
public int Anno { get; set; } = DateTime.Today.Year;
[Column("NegotiationId")]
public int NegotiationId { get; set; }
[Column("Descript"), MaxLength(250)]
public string Descript { get; set; } = "";
[Column("NumDoc")]
public int NumDoc { get; set; } = 0;
[Column("DocType")]
public BbmDocType DocType { get; set; } = BbmDocType.Quotazione;
[Column("DataIns")]
public DateTime DataIns { get; set; } = DateTime.Now;
[Column("IsActive")]
public bool IsActive { get; set; } = false;
[Column("IsDraft")]
public bool IsDraft { get; set; } = false;
[Column("IsReversed")]
public bool IsReversed { get; set; } = false;
[Column("IsLocked")]
public bool IsLocked { get; set; } = false;
[Column("Note"), MaxLength(500)]
public string Note { get; set; } = "";
[NotMapped]
public int DocIdSource { get; set; } = 0;
[NotMapped]
public decimal Importo
{
get
{
decimal answ = 0;
if (ResNav != null && ResNav.Count > 0)
{
answ = (decimal)ResNav.Sum(r => r.FinalPrice);
}
return answ;
}
}
[NotMapped]
public decimal Fatturato
{
get
{
decimal answ = 0;
if (ResNav != null && ResNav.Count > 0)
{
answ = FattNav.Sum(f => f.Importo);
}
return answ;
}
}
[NotMapped]
public decimal Incassato
{
get
{
decimal answ = 0;
if (ResNav != null && ResNav.Count > 0)
{
answ = FattNav.Sum(f => f.Incassato);
}
return answ;
}
}
[NotMapped, Precision(18, 6)]
public decimal ImportoReq
{
get => (IsDraft || IsReversed) ? 0 : Importo;
}
[ForeignKey("NegotiationId")]
public virtual NegotiationsModel NegotNav { get; set; }
public virtual ICollection<Fatt2DocModel> FattNav { get; set; }
public virtual ICollection<ResourcesModel> ResNav { get; set; }
}
}