Refactor: Refactored the bill inventory in the hope of making it less
error prone and more understandable.
Refactor: Also upgrade path to moving from Price/FullPrice to HasHappyHour/
IsHappyHour
Must have a few errors.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using System.Linq;
|
||||
using Tanshu.Accounts.Contracts;
|
||||
using Tanshu.Common;
|
||||
using Tanshu.Accounts.Entities;
|
||||
|
||||
@ -7,7 +8,8 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
public class BillDict : OrderedDictionary<BillItemKey, BillItemValue>
|
||||
{
|
||||
public delegate void ItemChangedHandler();
|
||||
public void Load(Voucher voucher) {
|
||||
public void Load(Voucher voucher)
|
||||
{
|
||||
foreach (var kot in voucher.Kots)
|
||||
{
|
||||
var kotKey = new BillItemKey(kot.KotID);
|
||||
@ -16,30 +18,45 @@ namespace Tanshu.Accounts.PointOfSale
|
||||
foreach (var inv in kot.Inventories)
|
||||
{
|
||||
var key = new BillItemKey(inv.Product.ProductID, kot.KotID);
|
||||
var item = new BillItemValue(inv.Product)
|
||||
{
|
||||
ProductID = inv.Product.ProductID,
|
||||
Discount = inv.Discount,
|
||||
Name =
|
||||
inv.Product.Units == string.Empty
|
||||
? inv.Product.Name
|
||||
: inv.Product.Name + " (" + inv.Product.Units + ")",
|
||||
Price = inv.Price,
|
||||
Printed = true,
|
||||
Quantity = inv.Quantity,
|
||||
IsScTaxable = inv.IsScTaxable,
|
||||
ServiceTaxRate = inv.ServiceTaxRate,
|
||||
VatRate = inv.VatRate,
|
||||
ServiceTax = inv.ServiceTax,
|
||||
Vat = inv.Vat,
|
||||
ServiceCharge = inv.ServiceCharge,
|
||||
};
|
||||
foreach (var mod in inv.InventoryModifier)
|
||||
item.Modifiers.Add(mod.Modifier);
|
||||
var item = new BillItemValue(inv);
|
||||
this.Add(key, item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public decimal Tax
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.ServiceTaxAmount + i.Value.inventory.VatAmount);
|
||||
}
|
||||
}
|
||||
public decimal Discount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.DiscountAmount);
|
||||
}
|
||||
}
|
||||
public decimal ServiceCharge
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.ServiceChargeAmount);
|
||||
}
|
||||
}
|
||||
public decimal NetAmount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.Net);
|
||||
}
|
||||
}
|
||||
public decimal Amount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.Amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user