Refactor: Instead of a concept of Price/FullPrice, happy hour is now a checkbox in the product.

This needed major refactor in all parts dealing with product or inventory.
This commit is contained in:
tanshu
2016-04-11 12:31:52 +05:30
parent 69cb7d8bce
commit 20eac3c216
35 changed files with 861 additions and 435 deletions

View File

@ -4,7 +4,8 @@ namespace Tanshu.Accounts.Contracts
{
public enum BillItemType
{
Product,
RegularProduct,
HappyHourProduct,
Kot
}
public class BillItemKey
@ -18,15 +19,15 @@ namespace Tanshu.Accounts.Contracts
public BillItemKey(Guid kotID)
: this(Guid.Empty, kotID, BillItemType.Kot)
{ }
public BillItemKey(Guid productID, Guid kotID)
: this(productID, kotID, BillItemType.Product)
public BillItemKey(Guid productID, Guid kotID, bool IsHappyHour)
: this(productID, kotID, IsHappyHour? BillItemType.HappyHourProduct : BillItemType.RegularProduct)
{ }
private Guid _productID;
public Guid ProductID
{
get { return BillItemType == BillItemType.Product ? _productID : Guid.Empty; }
private set { _productID = BillItemType == BillItemType.Product ? value : Guid.Empty; }
get { return BillItemType != BillItemType.Kot ? _productID : Guid.Empty; }
private set { _productID = BillItemType != BillItemType.Kot ? value : Guid.Empty; }
}
public Guid KotID { get; private set; }
@ -35,7 +36,7 @@ namespace Tanshu.Accounts.Contracts
public override int GetHashCode()
{
return BillItemType.GetHashCode() ^ KotID.GetHashCode() ^ ProductID.GetHashCode();
return BillItemType.GetHashCode() ^ KotID.GetHashCode() ^ ProductID.GetHashCode() ^ BillItemType.GetHashCode();
}
public static bool operator ==(BillItemKey a, BillItemKey b)
{
@ -50,7 +51,7 @@ namespace Tanshu.Accounts.Contracts
if (a.BillItemType != b.BillItemType)
return false;
return a.KotID == b.KotID && a.BillItemType == b.BillItemType && a.ProductID == b.ProductID;
return a.KotID == b.KotID && a.BillItemType == b.BillItemType && a.ProductID == b.ProductID && a.BillItemType == b.BillItemType;
}
public static bool operator !=(BillItemKey a, BillItemKey b)
{