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

105 lines
2.9 KiB
C#

using System;
using System.Runtime.Serialization;
using Tanshu.Accounts.Entities;
using System.Collections.Generic;
namespace Tanshu.Accounts.Contracts
{
public class BillInventory
{
public int ProductID { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public decimal Quantity { get; set; }
private decimal discount = 0;
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; }
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;
}
}
public decimal DiscountAmount
{
get
{
return Quantity * Price * discount;
}
}
public decimal GrossAmount
{
get
{
return Quantity * Price * (1 - discount);
}
}
public bool Printed {get; set;}
public decimal Value
{
get
{
return Price * Quantity * (1 - discount) * (1 + ServiceCharge) * (1 + Tax);
}
}
public string Display
{
get
{
string 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);
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;
}
}
public override string ToString()
{
return string.Format("{0} - {1}", ProductID, Name);
}
public IList<Modifier> Modifiers { get; set; }
public BillInventory()
{
Quantity = 1;
Printed = false;
Modifiers = new List<Modifier>();
}
}
}