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

130 lines
3.4 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);
}
}
private decimal printed;
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;
}
}
public decimal Value
{
get
{
return Price * Quantity * (1 - discount) * (1 + ServiceCharge) * (1 + Tax);
}
}
public decimal Additional
{
get
{
return Quantity - printed;
}
}
public bool isNew;
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 = 0;
isNew = true;
Modifiers = new List<Modifier>();
}
}
}