Breaking Change: Changed Kot/Voucher Table Name to Guid Foreign key

Breaking Change: Renamed Discontinued to IsActive and added NA field to products.
Cleanup: Removed not used attributes
Change: RoleConstants changed to simple string
Feature: Table Create/Edit/Reorder and Modifier Create/Edit Form
Feature: Bills now show the Tax name from the database and not a hack
This commit is contained in:
tanshu
2014-10-16 16:41:55 +05:30
parent 69617949bd
commit da929ad036
76 changed files with 3472 additions and 1175 deletions

View File

@ -109,7 +109,7 @@ namespace Tanshu.Accounts.PointOfSale
}
public void SetDiscount()
{
if (!Session.IsAllowed(RoleConstants.DISCOUNT))
if (!Session.IsAllowed("Discount"))
throw new PermissionException("Not Allowed to give Discount");
using (var bi = new ProductGroupBI())
@ -149,7 +149,7 @@ namespace Tanshu.Accounts.PointOfSale
return;
if (!prompt)
quantity += item.Quantity;
if (quantity < 0 && !Session.IsAllowed(RoleConstants.EDIT_PRINTED_PRODUCT))
if (quantity < 0 && !Session.IsAllowed("Edit Printed Product"))
return;
var total = quantity + _bill.Where(x => x.Key.ProductID == item.ProductID && x.Key.BillItemType == BillItemType.Product && x.Value.Printed).Sum(x => x.Value.Quantity);
if (total < 0)
@ -162,13 +162,13 @@ namespace Tanshu.Accounts.PointOfSale
var item = CurrentProduct;
if (item == null)
throw new ValidationException("No Product Selected");
if (!Session.IsAllowed(RoleConstants.CHANGE_RATE))
if (!Session.IsAllowed("Change Rate"))
throw new PermissionException("Rate Change not Allowed");
var rate = item.Price;
if (!GetInput("Price", ref rate))
return;
if (rate == 0 && !Session.IsAllowed(RoleConstants.ZERO_RATE))
throw new PermissionException("Zero Rate not Allowed");
if (rate == 0 && !Session.IsAllowed("NC Product"))
throw new PermissionException("NC of Product is not Allowed");
foreach (var sub in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.ProductID == item.ProductID))
sub.Value.Price = rate;
@ -275,10 +275,6 @@ namespace Tanshu.Accounts.PointOfSale
_saleForm.ShowAmount(discountAmount, grossAmount, serviceChargeAmount, taxAmount, valueAmount,
_bill.Values.ToList());
}
private static bool Allowed(BillItemValue item, RoleConstants role)
{
return item != null && Session.IsAllowed(role);
}
private static bool Allowed(BillItemValue item)
{
return item != null;
@ -323,7 +319,7 @@ namespace Tanshu.Accounts.PointOfSale
return null;
}
if (isPrinted && (!Session.IsAllowed(RoleConstants.EDIT_PRINTED_BILL)))
if (isPrinted && (!Session.IsAllowed("Edit Printed Bill")))
return null;
amount = _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty).Sum(x => x.Value.GrossAmount);
@ -362,7 +358,7 @@ namespace Tanshu.Accounts.PointOfSale
using (var frm = new PaxForm())
{
frm.ShowDialog();
_billInfo.TableID = tableName;
_billInfo.Table = table;
_billInfo.Pax = frm.Pax;
_saleForm.ShowInfo(_billInfo);
}
@ -404,7 +400,7 @@ namespace Tanshu.Accounts.PointOfSale
return;
if (!_billInfo.Printed)
return;
if (!Session.IsAllowed(RoleConstants.SETTLE_BILL))
if (!Session.IsAllowed("Settle Bill"))
return;
IDictionary<SettleOption, decimal> options;
var amount = -1 * _billInfo.Kots.Sum(x => x.Inventories.Sum(y => y.Amount));
@ -419,6 +415,7 @@ namespace Tanshu.Accounts.PointOfSale
using (var bi = new VoucherSettlementBI())
{
bi.SettleVoucher(Session.User, _billInfo.VoucherID, options);
bi.SaveChanges();
}
ClearBill();
}
@ -428,7 +425,7 @@ namespace Tanshu.Accounts.PointOfSale
{
using (var bi = new FoodTableBI())
{
using (var frm = new MoveTableForm(bi.List(), allowMerge))
using (var frm = new MoveTableForm(bi.List(x=>x.IsActive), allowMerge))
{
frm.ShowDialog();
if (frm.Selection != null)
@ -449,7 +446,7 @@ namespace Tanshu.Accounts.PointOfSale
var table = GetTableForMove(true);
if (table == null)
return;
if (table.Name == _billInfo.TableID)
if (table.FoodTableID == _billInfo.Table.FoodTableID)
return;
if (table.VoucherID != null)
if (IsPrintedOrVoid(table.VoucherID.Value))
@ -464,7 +461,7 @@ namespace Tanshu.Accounts.PointOfSale
voucherID = MergeKot(kot, table);
else if (table.VoucherID == null && kotCount == 1)
//Move Table
voucherID = MoveTable(table.Name);
voucherID = MoveTable(table.FoodTableID);
else if (table.VoucherID != null && kotCount == 1)
//Merge Table
voucherID = MergeTable(table);
@ -473,7 +470,7 @@ namespace Tanshu.Accounts.PointOfSale
}
internal void MoveTable()
{
if (_billInfo.VoucherID == null)
if (_billInfo.VoucherID == Guid.Empty)
return;
var allowMerge = !IsPrintedOrVoid(_billInfo);
@ -481,28 +478,28 @@ namespace Tanshu.Accounts.PointOfSale
var table = GetTableForMove(allowMerge);
if (table == null)
return;
if (table.Name == _billInfo.TableID)
if (table.FoodTableID == _billInfo.Table.FoodTableID)
return;
if (table.VoucherID.HasValue)
if (IsPrintedOrVoid(table.VoucherID.Value))
return;
LoadBill(table.VoucherID.HasValue ? MergeTable(table) : MoveTable(table.Name));
LoadBill(table.VoucherID.HasValue ? MergeTable(table) : MoveTable(table.FoodTableID));
}
private Guid MoveKot(BillItemKey kot, FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MOVE_KOT))
if (!Session.IsAllowed("Move Kot to New Table"))
return Guid.Empty;
using (var bi = new VoucherBI())
{
var newVoucherID = bi.MoveKot(kot.KotID, table.Name);
var newVoucherID = bi.MoveKot(kot.KotID, table.FoodTableID);
bi.SaveChanges();
return newVoucherID;
}
}
private static Guid MergeKot(BillItemKey kot, FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MERGE_KOT))
if (!Session.IsAllowed("Merge Kots"))
return Guid.Empty;
using (var bi = new VoucherBI())
{
@ -511,20 +508,20 @@ namespace Tanshu.Accounts.PointOfSale
return newVoucherID;
}
}
private Guid MoveTable(string tableName)
private Guid MoveTable(Guid tableID)
{
if (!Session.IsAllowed(RoleConstants.MOVE_TABLE))
if (!Session.IsAllowed("Move Table"))
return Guid.Empty;
using (var bi = new VoucherBI())
{
var newVoucherID = bi.Move(_billInfo.TableID, tableName);
var newVoucherID = bi.Move(_billInfo.Table.FoodTableID, tableID);
bi.SaveChanges();
return newVoucherID;
}
}
private Guid MergeTable(FoodTable table)
{
if (!Session.IsAllowed(RoleConstants.MERGE_TABLE))
if (!Session.IsAllowed("Merge Tables"))
return Guid.Empty;
using (var bi = new VoucherBI())
{
@ -539,7 +536,7 @@ namespace Tanshu.Accounts.PointOfSale
public void SaveKot()
{
#region Check if Allowed
if (!Session.IsAllowed(RoleConstants.PRINT_KOT))
if (!Session.IsAllowed("Print Kot"))
return;
if (_billInfo.VoucherID != Guid.Empty && IsPrintedOrVoid(_billInfo))
return;
@ -563,7 +560,7 @@ namespace Tanshu.Accounts.PointOfSale
public void SaveBill()
{
#region Check if Allowed
if (!Session.IsAllowed(RoleConstants.PRINT_BILL))
if (!Session.IsAllowed("Print Bill"))
throw new PermissionException("Printing not allowed");
if (_bill.Count == 1) //new kot only
return;
@ -625,7 +622,7 @@ namespace Tanshu.Accounts.PointOfSale
if (_billInfo.VoucherID == Guid.Empty || isVoid)
return; // must be existing non void bill
if (!Session.IsAllowed(RoleConstants.SPLIT_BILL))
if (!Session.IsAllowed("Split Bill"))
return;
#endregion
@ -655,7 +652,7 @@ namespace Tanshu.Accounts.PointOfSale
var voucherFirst = new Voucher(Session.User)
{
Customer = _billInfo.Customer,
TableID = table.Name,
Table = table,
Waiter = _billInfo.Waiter,
Printed = isPrinted,
Void = false,
@ -672,7 +669,7 @@ namespace Tanshu.Accounts.PointOfSale
var voucherSecond = new Voucher(Session.User)
{
Customer = _billInfo.Customer,
TableID = _billInfo.TableID,
Table = _billInfo.Table,
Waiter = _billInfo.Waiter,
Printed = isPrinted,
Void = false,
@ -705,7 +702,7 @@ namespace Tanshu.Accounts.PointOfSale
// return;
if (_billInfo.Void)
return;
if (!Session.IsAllowed(RoleConstants.VOID_BILL))
if (!Session.IsAllowed("Void Bill"))
return;
if (MessageBox.Show("Are you sure you want to void this bill?", "Void Bill", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
return;
@ -752,7 +749,7 @@ namespace Tanshu.Accounts.PointOfSale
var newVoucher = new Voucher(Session.User)
{
Customer = _billInfo.Customer,
TableID = _billInfo.TableID,
Table = _billInfo.Table,
Waiter = _billInfo.Waiter,
Printed = true,
Void = false,

View File

@ -7,7 +7,6 @@ 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)
{