111 lines
2.8 KiB
C#
111 lines
2.8 KiB
C#
using System;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace SHERPA.BBM.DatabaseModels
|
|
{
|
|
// <Auto-Generated>
|
|
// This is here so CodeMaid doesn't reorganize this document
|
|
// </Auto-Generated>
|
|
/// <summary>
|
|
/// Tabella delle Risorse
|
|
/// </summary>
|
|
[Table("Resources")]
|
|
public class ResourcesModel
|
|
{
|
|
#region Public Properties
|
|
|
|
[Key, Column("ResourceId", Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int ResourceId { get; set; }
|
|
|
|
[Column("DocId")]
|
|
public int DocId { get; set; }
|
|
|
|
[Column("Anno")]
|
|
public int Anno { get; set; } = DateTime.Today.Year;
|
|
|
|
[Column("Ordinal")]
|
|
public int Ordinal { get; set; } = 0;
|
|
|
|
[Column("ItemId")]
|
|
public int ItemId { get; set; }
|
|
|
|
[Column("QtyPrev")]
|
|
public double QtyPrev { get; set; } = 1;
|
|
|
|
[Column("QtyOff")]
|
|
public double QtyOff { get; set; } = 1;
|
|
|
|
[NotMapped]
|
|
public double StdPrice
|
|
{
|
|
get
|
|
{
|
|
return UnitPriceOff * QtyOff;
|
|
}
|
|
}
|
|
|
|
[Column("UnitPriceOff")]
|
|
public double UnitPriceOff { get; set; }
|
|
[Column("FinalPrice")]
|
|
public double FinalPrice { get; set; }
|
|
|
|
[Column("Note")]
|
|
public string Note { get; set; } = "";
|
|
|
|
[NotMapped]
|
|
[DisplayFormat(DataFormatString = "{0:P2}", ApplyFormatInEditMode = true)]
|
|
[Range(0, 1, ErrorMessage = "Percentuale fino a 1=100%")]
|
|
public double PercReduction
|
|
{
|
|
get
|
|
{
|
|
double answ = 0;
|
|
if (StdPrice > 0)
|
|
{
|
|
answ = (StdPrice - FinalPrice) / StdPrice;
|
|
}
|
|
return Math.Round(answ, 4);
|
|
}
|
|
set
|
|
{
|
|
if (value > 0 && value < 1)
|
|
{
|
|
FinalPrice = StdPrice * (1 - value);
|
|
}
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public double PriceReduction
|
|
{
|
|
get
|
|
{
|
|
double answ = 0;
|
|
if (StdPrice > 0)
|
|
{
|
|
answ = (StdPrice - FinalPrice);
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
if (value > 0 && value <= StdPrice)
|
|
{
|
|
var fPrice = StdPrice - value;
|
|
FinalPrice = fPrice > 0 ? fPrice : 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
[ForeignKey("ItemId")]
|
|
public virtual ItemsModel Item { get; set; }
|
|
|
|
[ForeignKey("DocId")]
|
|
public virtual DocsModel Document { get; set; }
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |