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

151 lines
3.8 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
using System;
using System.Runtime.Serialization;
namespace Tanshu.Accounts.Contracts
{
public class SalesBillItemBO
{
public Guid productID;
public string Name { get; set; }
private decimal price;
private decimal quantity;
private decimal discount;
private decimal printed;
public SalesBillItemBO()
{
quantity = 1;
discount = 0;
printed = 0;
serviceCharge = 0.1M;
}
2010-03-02 17:56:21 +00:00
public decimal Price
{
get { return price; }
set
{
2011-01-09 23:36:24 +00:00
if (value < 0)
2010-03-02 17:56:21 +00:00
throw new ArgumentException("Price has to be non-negative greater than zero.");
else
price = value;
}
}
public decimal Quantity
{
get { return quantity; }
set
{
if (value <= 0)
throw new ArgumentException("Quantity has to be non-negative greater than zero.");
quantity = value;
}
}
public decimal Discount
{
get { return discount; }
set
{
if (value < 0)
throw new ArgumentException("Discount has to be non-negative greater than or equal to zero.");
else if (value > 1)
throw new ArgumentException("Discount has to be less than one.");
else
discount = value;
}
}
public decimal Tax { get; set; }
private decimal serviceCharge;
public decimal ServiceCharge
{
get { return serviceCharge; }
set
{
if (value < 0)
throw new ArgumentException("Service Charge has to be non-negative greater than or equal to zero.");
else if (value > 1)
throw new ArgumentException("Service Charge has to be less than one.");
else
serviceCharge = value;
}
}
#region Calculated Amounts
public decimal ServiceChargeAmount
{
get
{
return quantity * price * (1 - discount) * serviceCharge;
}
}
2010-03-02 17:56:21 +00:00
public decimal TaxAmount
{
get
{
return quantity * price * (1 - discount) * (1 + serviceCharge) * Tax;
2010-03-02 17:56:21 +00:00
}
}
public decimal DiscountAmount
{
get
{
return quantity * price * discount;
}
}
public decimal GrossAmount
{
get
{
return quantity * price * (1 - discount);
}
}
public decimal Value
{
get
{
return price * quantity * (1 - discount) * (1 + serviceCharge) * (1 + Tax);
}
}
2010-03-02 17:56:21 +00:00
#endregion
2010-03-02 17:56:21 +00:00
public decimal Printed
{
get { return printed; }
set
{
if (value < 0)
throw new ArgumentException("Printed has to be non-negative greater than or equal to zero.");
else
printed = value;
}
}
2010-03-02 17:56:21 +00:00
public decimal Additional
{
get
{
return quantity - printed;
}
}
public bool isNew = true;
public string Display
{
get
{
string output = string.Format("{0} @ Rs. {1:#.##}", Name, price);
if (discount != 0)
output += string.Format(" - {0:#.##%}", discount);
2010-03-02 17:56:21 +00:00
return output;
}
}
}
}