0f323f8fab
Signed-off-by: unknown <tanshu@.(none)>
104 lines
2.4 KiB
C#
104 lines
2.4 KiB
C#
using System;
|
|
using System.Runtime.Serialization;
|
|
using FluentNHibernate.Mapping;
|
|
using System.Collections.Generic;
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
namespace Tanshu.Accounts.Entities
|
|
{
|
|
public class Inventory
|
|
{
|
|
public virtual int InventoryID { get; set; }
|
|
[NotNull]
|
|
public virtual Voucher Voucher { get; set; }
|
|
[NotNull]
|
|
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();
|
|
}
|
|
|
|
}
|
|
|
|
[Cascade]
|
|
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>();
|
|
}
|
|
}
|
|
}
|