2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.Serialization;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using FluentNHibernate.Mapping;
|
|
|
|
|
using System.Collections.Generic;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
namespace Tanshu.Accounts.Entities
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public class Inventory
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual int InventoryID { get; set; }
|
|
|
|
|
public virtual Voucher Voucher { get; set; }
|
|
|
|
|
public virtual Product Product { get; set; }
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
private decimal quantity;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual decimal Quantity
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
get { return quantity; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
quantity = value;
|
|
|
|
|
if (amount != null)
|
|
|
|
|
CalculateAmount();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
private decimal rate;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual decimal Rate
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
get { return rate; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
rate = value;
|
|
|
|
|
if (amount != null)
|
|
|
|
|
CalculateAmount();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
decimal tax;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual decimal Tax
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
get { return tax; }
|
|
|
|
|
set
|
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
tax = value;
|
|
|
|
|
if (amount != null)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
CalculateAmount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
decimal discount;
|
|
|
|
|
public virtual decimal Discount
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
get { return discount; }
|
|
|
|
|
set
|
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
discount = value;
|
|
|
|
|
if (amount != null)
|
|
|
|
|
CalculateAmount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private decimal serviceCharge;
|
|
|
|
|
public virtual decimal ServiceCharge
|
|
|
|
|
{
|
|
|
|
|
get { return serviceCharge; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
discount = value;
|
|
|
|
|
if (amount != null)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
CalculateAmount();
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
public virtual IList<InventoryModifier> InventoryModifier { get; set; }
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
decimal? amount;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public virtual decimal Amount
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (!amount.HasValue)
|
|
|
|
|
CalculateAmount();
|
|
|
|
|
return amount.Value;
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
set
|
|
|
|
|
{ }
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
protected void CalculateAmount()
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
amount = quantity * rate * (1 + tax) * (1 + serviceCharge) * (1 - discount);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public Inventory()
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
InventoryModifier = new List<InventoryModifier>();
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|