narsil/Tanshu.Accounts.Contracts/Data Contracts/InventoryBO.cs

100 lines
2.3 KiB
C#
Raw Normal View History

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