100 lines
2.3 KiB
C#
100 lines
2.3 KiB
C#
using System;
|
|
using System.Runtime.Serialization;
|
|
using FluentNHibernate.Mapping;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Tanshu.Accounts.Entities
|
|
{
|
|
public class Inventory
|
|
{
|
|
public virtual int InventoryID { get; set; }
|
|
public virtual Voucher Voucher { get; set; }
|
|
public virtual Product Product { get; set; }
|
|
|
|
private decimal quantity;
|
|
public virtual decimal Quantity
|
|
{
|
|
get { return quantity; }
|
|
set
|
|
{
|
|
quantity = value;
|
|
if (amount != null)
|
|
CalculateAmount();
|
|
}
|
|
}
|
|
|
|
private decimal rate;
|
|
public virtual decimal Rate
|
|
{
|
|
get { return rate; }
|
|
set
|
|
{
|
|
rate = value;
|
|
if (amount != null)
|
|
CalculateAmount();
|
|
}
|
|
}
|
|
|
|
decimal tax;
|
|
public virtual decimal Tax
|
|
{
|
|
get { return tax; }
|
|
set
|
|
{
|
|
tax = value;
|
|
if (amount != null)
|
|
CalculateAmount();
|
|
}
|
|
}
|
|
|
|
decimal discount;
|
|
public virtual decimal Discount
|
|
{
|
|
get { return discount; }
|
|
set
|
|
{
|
|
discount = value;
|
|
if (amount != null)
|
|
CalculateAmount();
|
|
}
|
|
}
|
|
|
|
private decimal serviceCharge;
|
|
public virtual decimal ServiceCharge
|
|
{
|
|
get { return serviceCharge; }
|
|
set
|
|
{
|
|
discount = value;
|
|
if (amount != null)
|
|
CalculateAmount();
|
|
}
|
|
|
|
}
|
|
|
|
public virtual IList<InventoryModifier> InventoryModifier { get; set; }
|
|
|
|
decimal? amount;
|
|
public virtual decimal Amount
|
|
{
|
|
get
|
|
{
|
|
if (!amount.HasValue)
|
|
CalculateAmount();
|
|
return amount.Value;
|
|
}
|
|
set
|
|
{ }
|
|
}
|
|
|
|
protected void CalculateAmount()
|
|
{
|
|
amount = quantity * rate * (1 + tax) * (1 + serviceCharge) * (1 - discount);
|
|
}
|
|
public Inventory()
|
|
{
|
|
InventoryModifier = new List<InventoryModifier>();
|
|
}
|
|
}
|
|
}
|