51d518d2a0
The functions now only do one thing.
63 lines
1.9 KiB
C#
63 lines
1.9 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)
|
|
{
|
|
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);
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
} |