narsil/Tanshu.Accounts.PointOfSale/Controllers/BillDict.cs

65 lines
2.0 KiB
C#

using System.Linq;
using Tanshu.Accounts.Contracts;
using Tanshu.Common;
using Tanshu.Accounts.Entities;
using System;
namespace Tanshu.Accounts.PointOfSale
{
public class BillDict : OrderedDictionary<BillItemKey, BillItemValue>
{
public delegate void ItemChangedHandler();
public void Load(Voucher voucher)
{
this.Clear();
foreach (var kot in voucher.Kots)
{
var kotKey = new BillItemKey(kot.KotID);
var kotItem = new BillItemValue(kot);
this.Add(kotKey, kotItem);
foreach (var inv in kot.Inventories)
{
var key = new BillItemKey(inv.Product.ProductID, kot.KotID, inv.IsHappyHour);
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 Math.Round(this.Where(x => x.Key.BillItemType != BillItemType.Kot).Sum(i => i.Value.inventory.Amount));
}
}
}
}