narsil/Tanshu.Accounts.PointOfSale/Controllers/BillDict.cs
tanshu 69617949bd Important! : Need to update to new schema using SQL Scripts
Important! : This version will not work.  It is pre-alpha and saved in case of catastrophic failure
Refactor: Remove dependency on Fluent Nhibernate.
Refactor: All Primary keys are now Guids.
Refactor: Class Mappings changed from AutoMap to Explicit Mappings.
Breakage: All Cascading is now disabled and entities must be explicitly saved/updated/deleted
Breakage: Auto Commiting is now off and "SaveChanges()" needs to be called on all BIs.
Refactor: Changed the pattern where all relevant db code for an operation is basically in the same function.
Chore: Removed Advance and Payments options.
2014-10-12 15:11:45 +05:30

46 lines
1.8 KiB
C#

using Tanshu.Accounts.Contracts;
using Tanshu.Common;
using Tanshu.Accounts.Entities;
namespace Tanshu.Accounts.PointOfSale
{
public class BillDict : OrderedDictionary<BillItemKey, BillItemValue>
{
public delegate void ItemChangedHandler();
public event ItemChangedHandler ItemChanged;
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.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);
this.Add(key, item);
}
}
}
}
}