116 lines
3.1 KiB
C#
116 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static EgwCoreLib.Lux.Core.Enums;
|
|
|
|
namespace EgwCoreLib.Lux.Data.DbModel.Sales
|
|
{
|
|
/// <summary>
|
|
/// Classe dei template di oggetti gestiti
|
|
/// </summary>
|
|
[Table("sales_template")]
|
|
public class TemplateModel
|
|
{
|
|
/// <summary>
|
|
/// ID del record
|
|
/// </summary>
|
|
[Key]
|
|
public int TemplateID { get; set; }
|
|
|
|
/// <summary>
|
|
/// Environment del template
|
|
/// </summary>
|
|
public EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS Envir { get; set; } = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
|
|
|
|
|
|
/// <summary>
|
|
/// SourceType dell'Item
|
|
/// </summary>
|
|
public ItemSourceType SourceType { get; set; } = ItemSourceType.ND;
|
|
|
|
/// <summary>
|
|
/// Denominazione
|
|
/// </summary>
|
|
public string Name { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Descrizione
|
|
/// </summary>
|
|
public string Description { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Numero Item compresi
|
|
/// </summary>
|
|
[NotMapped]
|
|
public double NumItems
|
|
{
|
|
get => TemplateRowNav?.Sum(x => x.Qty) ?? 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Numero ProdItem compresi
|
|
/// </summary>
|
|
[NotMapped]
|
|
public double NumProdItems
|
|
{
|
|
get => TemplateRowNav?.Sum(x => x.ProdItemQtyTot) ?? 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Numero Item compresi
|
|
/// </summary>
|
|
[NotMapped]
|
|
public int NumRows
|
|
{
|
|
get => TemplateRowNav?.Count ?? 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Costo totale offerta (rock bottom)
|
|
/// </summary>
|
|
[NotMapped]
|
|
public double TotalCost
|
|
{
|
|
get => TemplateRowNav?.Sum(x => x.TotalCost) ?? 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Prezzo totale offerta (compreso di amrginalità)
|
|
/// </summary>
|
|
[NotMapped]
|
|
public double TotalPrice
|
|
{
|
|
get => TemplateRowNav?.Sum(x => x.TotalPrice) ?? 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sconto massimo applicabile
|
|
/// </summary>
|
|
[NotMapped]
|
|
public double MaxDiscount
|
|
{
|
|
get => (TotalCost > 0 && TotalPrice > TotalCost) ? (TotalPrice - TotalCost) / TotalPrice : 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Navigazione Customer
|
|
/// </summary>
|
|
[ForeignKey("CustomerID")]
|
|
public virtual CustomerModel CustomerNav { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Navigazione Dealer
|
|
/// </summary>
|
|
[ForeignKey("DealerID")]
|
|
public virtual DealerModel DealerNav { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Navigazione alle righe offerta
|
|
/// </summary>
|
|
public virtual ICollection<TemplateRowModel> TemplateRowNav { get; set; } = new List<TemplateRowModel>();
|
|
}
|
|
} |