2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
|
using System.Collections.Generic;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Contracts
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public class BillItemValue
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public int ProductID { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
2011-01-31 20:33:22 +00:00
|
|
|
|
public decimal Price { get; set; }
|
2011-08-28 12:17:15 +00:00
|
|
|
|
public decimal FullPrice { get; set; }
|
2011-01-31 20:33:22 +00:00
|
|
|
|
public decimal Quantity { get; set; }
|
2011-06-23 12:47:48 +00:00
|
|
|
|
private decimal _discount;
|
|
|
|
|
public Product Product { get; private set; }
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public decimal Discount
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
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.");
|
2011-06-23 12:47:48 +00:00
|
|
|
|
if (value > 1)
|
2010-03-02 17:56:21 +00:00
|
|
|
|
throw new ArgumentException("Discount has to be less than one.");
|
2011-06-23 12:47:48 +00:00
|
|
|
|
_discount = value;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public decimal Tax { get; set; }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public decimal TaxAmount
|
2011-01-17 14:55:43 +00:00
|
|
|
|
{
|
2011-01-30 07:14:05 +00:00
|
|
|
|
get
|
2011-01-17 14:55:43 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Quantity * Price * (1 - _discount) * (1 + ServiceCharge) * Tax;
|
2011-01-17 14:55:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public decimal ServiceCharge { get; set; }
|
2011-01-17 14:55:43 +00:00
|
|
|
|
public decimal ServiceChargeAmount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Quantity * Price * (1 - _discount) * ServiceCharge;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public decimal DiscountAmount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Quantity * Price * _discount;
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
public decimal GrossAmount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Quantity * Price * (1 - _discount);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public bool Printed { get; set; }
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public decimal Value
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Price * Quantity * (1 - _discount) * (1 + ServiceCharge) * (1 + Tax);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-02 17:56:21 +00:00
|
|
|
|
|
|
|
|
|
public string Display
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
|
|
|
|
|
if (_discount != 0)
|
|
|
|
|
output += string.Format(" - {0:#.##%}", _discount);
|
2011-08-23 07:10:05 +00:00
|
|
|
|
if (Modifiers != null)
|
|
|
|
|
foreach (var item in Modifiers)
|
|
|
|
|
output += string.Format("\n\r -- {0}", item.Name);
|
2010-03-02 17:56:21 +00:00
|
|
|
|
return output;
|
2011-01-31 20:33:22 +00:00
|
|
|
|
|
|
|
|
|
//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
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-31 20:33:22 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return string.Format("{0} - {1}", ProductID, Name);
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
public IList<Modifier> Modifiers { get; set; }
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public BillItemValue(Product product)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
|
|
|
|
Modifiers = new List<Modifier>();
|
2011-08-23 07:10:05 +00:00
|
|
|
|
if (product != null)
|
|
|
|
|
{
|
|
|
|
|
Product = product;
|
|
|
|
|
ProductID = product.ProductID;
|
|
|
|
|
Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")";
|
|
|
|
|
Quantity = 1;
|
2011-08-28 12:17:15 +00:00
|
|
|
|
Price = product.Price;
|
|
|
|
|
FullPrice = product.FullPrice;
|
2011-08-23 07:10:05 +00:00
|
|
|
|
Tax = product.Tax.Rate;
|
|
|
|
|
ServiceCharge = product.ServiceCharge;
|
|
|
|
|
Discount = 0;
|
|
|
|
|
Printed = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public BillItemValue()
|
|
|
|
|
{
|
|
|
|
|
Product = null;
|
|
|
|
|
ProductID = 0;
|
|
|
|
|
Discount = 0;
|
|
|
|
|
Name = "== New Kot ==";
|
|
|
|
|
Price = 0;
|
2011-08-28 12:17:15 +00:00
|
|
|
|
FullPrice = 0;
|
2011-08-23 07:10:05 +00:00
|
|
|
|
Printed = true;
|
|
|
|
|
Quantity = 0;
|
|
|
|
|
Tax = -1;
|
|
|
|
|
ServiceCharge = 0;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-08-23 07:10:05 +00:00
|
|
|
|
|
|
|
|
|
public BillItemValue(Kot kot)
|
|
|
|
|
{
|
|
|
|
|
Product = null;
|
|
|
|
|
ProductID = kot.KotID;
|
|
|
|
|
Discount = 0;
|
|
|
|
|
Name = string.Format("Kot: {0} / {1:dd-MMM HH:mm} ({2})", kot.Code, kot.Date, kot.User.Name);
|
|
|
|
|
Price = 0;
|
2011-08-28 12:17:15 +00:00
|
|
|
|
FullPrice = 0;
|
2011-08-23 07:10:05 +00:00
|
|
|
|
Printed = true;
|
|
|
|
|
Quantity = 0;
|
|
|
|
|
Tax = -1;
|
|
|
|
|
ServiceCharge = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-02 17:56:21 +00:00
|
|
|
|
}
|
2011-08-23 07:10:05 +00:00
|
|
|
|
}
|