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; } private decimal quantity; public decimal Quantity { get { return quantity; } set { quantity = value; if (amount != null) CalculateAmount(); } } private decimal rate; public decimal Rate { get { return rate; } set { rate = value; if (amount != null) CalculateAmount(); } } decimal vat; public decimal Vat { get { return vat; } set { vat = value; if (amount != null) CalculateAmount(); } } decimal serviceTax; public decimal ServiceTax { get { return serviceTax; } set { serviceTax = value; if (amount != null) CalculateAmount(); } } decimal discount; public decimal Discount { get { return discount; } set { discount = value; if (amount != null) CalculateAmount(); } } decimal? amount; public decimal Amount { get { if (!amount.HasValue) CalculateAmount(); return amount.Value; } } private void CalculateAmount() { amount = quantity * rate * (1 + vat + serviceTax) * (1 - discount); } } }