using System; using System.Runtime.Serialization; namespace Tanshu.Accounts.Contracts { public class InventoryBO { public Guid InventoryID { get; set; } public Guid VoucherID { get; set; } public Guid ProductID { get; set; } public string ProductName { get; set; } private decimal quantity; public decimal Quantity { get { return quantity; } set { quantity = value; amount = null; } } private decimal rate; public decimal Rate { get { return rate; } set { rate = value; amount = null; } } decimal vat; public decimal Vat { get { return vat; } set { vat = value; amount = null; } } decimal serviceTax; public decimal ServiceTax { get { return serviceTax; } set { serviceTax = value; amount = null; } } decimal discount; public decimal Discount { get { return discount; } set { discount = value; amount = null; } } decimal? amount; public decimal Amount { get { if (!amount.HasValue) CalculateAmount(); return amount.Value; } } private void CalculateAmount() { amount = quantity * rate * (1 + vat + serviceTax) * (1 - discount); } } }