narsil/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs

106 lines
2.9 KiB
C#
Raw Normal View History

2010-03-02 17:56:21 +00:00
using System;
using Tanshu.Accounts.Entities;
using System.Collections.Generic;
2010-03-02 17:56:21 +00:00
namespace Tanshu.Accounts.Contracts
{
public class BillItemValue
2010-03-02 17:56:21 +00:00
{
public int ProductID { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public decimal Quantity { get; set; }
private decimal _discount;
public Product Product { get; private set; }
2010-03-02 17:56:21 +00:00
public decimal Discount
{
get { return _discount; }
2010-03-02 17:56:21 +00:00
set
{
if (value < 0)
throw new ArgumentException("Discount has to be non-negative greater than or equal to zero.");
if (value > 1)
2010-03-02 17:56:21 +00:00
throw new ArgumentException("Discount has to be less than one.");
_discount = value;
2010-03-02 17:56:21 +00:00
}
}
public decimal Tax { get; set; }
public decimal TaxAmount
{
get
{
return Quantity * Price * (1 - _discount) * (1 + ServiceCharge) * Tax;
}
}
public decimal ServiceCharge { get; set; }
public decimal ServiceChargeAmount
{
get
{
return Quantity * Price * (1 - _discount) * ServiceCharge;
2010-03-02 17:56:21 +00:00
}
}
2010-03-02 17:56:21 +00:00
public decimal DiscountAmount
{
get
{
return Quantity * Price * _discount;
2010-03-02 17:56:21 +00:00
}
}
2010-03-02 17:56:21 +00:00
public decimal GrossAmount
{
get
{
return Quantity * Price * (1 - _discount);
2010-03-02 17:56:21 +00:00
}
}
public bool Printed { get; set; }
2010-03-02 17:56:21 +00:00
public decimal Value
{
get
{
return Price * Quantity * (1 - _discount) * (1 + ServiceCharge) * (1 + Tax);
}
}
2010-03-02 17:56:21 +00:00
public string Display
{
get
{
var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
if (_discount != 0)
output += string.Format(" - {0:#.##%}", _discount);
foreach (var item in Modifiers)
output += string.Format("\n\r -- {0}", item.Name);
2010-03-02 17:56:21 +00:00
return output;
//if (Price == 0)
// return string.Format(" -- {0}", Name);
//string output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
//if (discount != 0)
// output += string.Format(" - {0:#.##%}", discount);
//return output;
2010-03-02 17:56:21 +00:00
}
}
public override string ToString()
{
return string.Format("{0} - {1}", ProductID, Name);
}
public IList<Modifier> Modifiers { get; set; }
public BillItemValue(Product product)
{
Quantity = 1;
Printed = false;
Modifiers = new List<Modifier>();
Product = product;
}
2010-03-02 17:56:21 +00:00
}
}