narsil/Tanshu.Accounts.Contracts/Data Contracts Display/BillInventoryBO.cs
tanshu 3ca8b29e04 Regression: BillItemKey added the compare methods back
Regression: PrintLocation added the compare methods back
Breaking: Kot.Code is now integers
Breaking: Kot Update is now via Stored Procedure to get DB Values
Breaking: Reprints Insert is now via Stored Procedure to get DV Values
Breaking: Voucher.BillID and KotID are now integers
Breaking: Voucher Insert/Update is now via Stored Procedures to get DV Values also Dirty Checking for Voucher has been overwritten to set dirty for LastEditDate update
Fix: Login forms simplified
Feature: PrintLocation and Products are cached application wide.
2014-11-02 13:33:31 +05:30

169 lines
5.2 KiB
C#

using System;
using Tanshu.Accounts.Entities;
using System.Collections.Generic;
namespace Tanshu.Accounts.Contracts
{
public class BillItemValue
{
public Guid ProductID { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public decimal FullPrice { get; set; }
public decimal Quantity { get; set; }
private decimal _discount;
public Product Product { get; private set; }
public bool IsKot { get; private set; }
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.");
if (value > 1)
throw new ArgumentException("Discount has to be less than one.");
_discount = value;
}
}
public bool IsScTaxable { get; set; }
public Tax ServiceTax { get; set; }
public decimal ServiceTaxRate { get; set; }
public decimal ServiceTaxAmount
{
get
{
if (IsScTaxable)
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * ServiceTaxRate;
return Quantity * Price * (1 - Discount) * ServiceTaxRate;
}
}
public Tax Vat { get; set; }
public decimal VatRate { get; set; }
public decimal VatAmount
{
get
{
if (IsScTaxable)
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * VatRate;
return Quantity * Price * (1 - Discount) * VatRate;
}
}
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
{
if (IsScTaxable)
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge) * (1 + ServiceTaxRate + VatRate);
return Quantity * Price * (1 - Discount) * (1 + ServiceCharge + ServiceTaxRate + VatRate);
}
}
public string Display
{
get
{
var output = string.Format("{0} @ Rs. {1:#.##}", Name, Price);
if (_discount != 0)
output += string.Format(" - {0:#.##%}", _discount);
if (Modifiers != null)
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 BillItemValue(Product product)
{
Modifiers = new List<Modifier>();
if (product != null)
{
Product = product;
ProductID = product.ProductID;
Name = product.Units == string.Empty ? product.Name : product.Name + " (" + product.Units + ")";
Quantity = 1;
Price = product.Price;
FullPrice = product.FullPrice;
IsScTaxable = product.IsScTaxable;
ServiceTax = product.ServiceTax;
Vat = product.Vat;
ServiceTaxRate = product.ServiceTax.Rate;
VatRate = product.Vat.Rate;
ServiceCharge = product.ServiceCharge;
Discount = 0;
Printed = false;
IsKot = false;
}
}
public BillItemValue()
{
Product = null;
ProductID = Guid.Empty;
Discount = 0;
Name = "== New Kot ==";
Price = 0;
FullPrice = 0;
Printed = true;
Quantity = 0;
ServiceCharge = 0;
IsKot = true;
}
public BillItemValue(Kot kot)
{
Product = null;
ProductID = kot.KotID;
Discount = 0;
Name = string.Format("Kot: S-{0} / {1:dd-MMM HH:mm} ({2})", kot.Code, kot.Date, kot.User.Name);
Price = 0;
FullPrice = 0;
Printed = true;
Quantity = 0;
ServiceCharge = 0;
IsKot = true;
}
}
}