Chore: Removed Waiter as it was not ever used.

Refactor: Changed the user list form to a normal form.
Feature: Service Charge disabled setting removes it from the Product Form.
This commit is contained in:
tanshu
2016-01-18 16:13:43 +05:30
parent caf9b3106c
commit 69560cfb07
30 changed files with 776 additions and 528 deletions

View File

@ -18,11 +18,6 @@ namespace Tanshu.Accounts.PointOfSale
private Guid? _editVoucherID;
private ISaleForm _saleForm;
public Waiter Waiter
{
get { return _voucher.Waiter; }
set { _voucher.Waiter = value; }
}
public BillController(Guid? editVoucherID)
{
this._editVoucherID = editVoucherID;
@ -30,8 +25,6 @@ namespace Tanshu.Accounts.PointOfSale
_voucher = new Voucher(Session.User);
using (var bi = new CustomerBI())
_voucher.Customer = bi.Get(x => x.CustomerID == Constants.CASH_CUSTOMER);
using (var bi = new WaiterBI())
_voucher.Waiter = bi.Get(x => x.WaiterID == Constants.WAITER);
}
public BillItemValue CurrentProduct
{
@ -203,63 +196,6 @@ namespace Tanshu.Accounts.PointOfSale
return form.Customer;
}
}
public void ShowWaiters(bool reset)
{
if (reset)
{
using (var bi = new WaiterBI())
_voucher.Waiter = bi.Get(x => x.WaiterID == Constants.WAITER);
}
else
{
using (var selectWaiter = new SelectWaiter(WaiterBI.StaticList, true))
{
selectWaiter.WaiterEvent += selectWaiter_waiterEvent;
selectWaiter.ShowDialog();
if (selectWaiter.SelectedItem != null)
{
_voucher.Waiter = selectWaiter.SelectedItem;
}
else
{
using (var bi = new WaiterBI())
_voucher.Waiter = bi.Get(x => x.WaiterID == Constants.WAITER);
}
}
}
_saleForm.SetWaiterDisplay(_voucher.Waiter.Name);
}
private Waiter selectWaiter_waiterEvent(object sender, SelectorEventArgs<Waiter> e)
{
var waiter = e.Item;
//if (!Thread.CurrentPrincipal.IsInRole("Waiter/Master"))
// return waiter;
using (var bi = new WaiterBI())
{
switch (e.Action)
{
case SelectorAction.Insert: // Add
bi.Insert(waiter);
bi.SaveChanges();
e.Handled = true;
return waiter;
case SelectorAction.Update: // Edit
bi.Update(waiter);
bi.SaveChanges();
e.Handled = true;
return waiter;
case SelectorAction.Delete: // Delete
bi.Delete(x => x.WaiterID == waiter.WaiterID);
bi.SaveChanges();
e.Handled = true;
return bi.Get(x => x.WaiterID == Constants.WAITER);
default:
e.Handled = true;
return bi.Get(x => x.WaiterID == Constants.WAITER);
}
}
}
private void ShowAmount()
{
var taxAmount = _bill.Values.Sum(b => b.ServiceTaxAmount + b.VatAmount);
@ -351,7 +287,6 @@ namespace Tanshu.Accounts.PointOfSale
{
_voucher = new Voucher(Session.User);
ShowCustomers(true);
ShowWaiters(true);
_bill.Clear();
var newKotKey = new BillItemKey(Guid.Empty);
var newKotItem = new BillItemValue();
@ -547,7 +482,7 @@ namespace Tanshu.Accounts.PointOfSale
{
#region Check if Allowed
if (!Session.IsAllowed("Print Bill"))
return; // throw new PermissionException("Printing not allowed");
return;
if (_bill.Count == 1) //new kot only
return;
bool isPrinted = false, isVoid = false;
@ -587,15 +522,27 @@ namespace Tanshu.Accounts.PointOfSale
}
public void SplitBill()
{
bool isPrinted = false;
#region Permissions
bool isPrinted, isVoid;
IsPrintedOrVoid(_voucher, out isPrinted, out isVoid);
if (_voucher.VoucherID == Guid.Empty || isVoid)
return; // must be existing non void bill
if (!Session.IsAllowed("Split Bill"))
return;
if (_voucher.VoucherID == Guid.Empty)
return; // must be existing non void bill
using (var bi = new VoucherBI())
{
var dbVoucher = bi.Get(x => x.VoucherID == _voucher.VoucherID);
if (dbVoucher.Void)
{
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _voucher.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;// must be a non void bill
}
if (dbVoucher.Printed && !Session.IsAllowed("Edit Printed Bill"))
{
MessageBox.Show("This Bill is already Printed.\nYou do not have the authority to alter it", "Bill already Printed", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;// not allowed to edit printed bill
}
isPrinted = dbVoucher.Printed;
}
#endregion
#region Get Move List
@ -625,7 +572,6 @@ namespace Tanshu.Accounts.PointOfSale
{
Customer = _voucher.Customer,
Table = table,
Waiter = _voucher.Waiter,
Printed = isPrinted,
Void = false,
Narration = "",
@ -642,7 +588,6 @@ namespace Tanshu.Accounts.PointOfSale
{
Customer = _voucher.Customer,
Table = _voucher.Table,
Waiter = _voucher.Waiter,
Printed = isPrinted,
Void = false,
Narration = "",
@ -725,7 +670,6 @@ namespace Tanshu.Accounts.PointOfSale
{
Customer = _voucher.Customer,
Table = _voucher.Table,
Waiter = _voucher.Waiter,
Printed = true,
Void = false,
Narration = "",
@ -783,7 +727,6 @@ namespace Tanshu.Accounts.PointOfSale
var voucher = bi.Get(x => x.VoucherID == _voucher.VoucherID);
voucher.User = Session.User;
voucher.Customer = _voucher.Customer;
voucher.Waiter = _voucher.Waiter;
voucher.Printed = finalBill;
voucher.VoucherType = _voucher.VoucherType;
foreach (var item in _bill.Where(x => x.Key.BillItemType == BillItemType.Product && x.Key.KotID != Guid.Empty))

View File

@ -13,7 +13,6 @@ namespace Tanshu.Accounts.PointOfSale
{
void ClearBill(List<BillItemValue> bill);
void SetCustomerDisplay(string name);
void SetWaiterDisplay(string p);
void CloseWindow();
void ShowAmount(decimal discountAmount, decimal grossAmount, decimal serviceChargeAmount, decimal taxAmount, decimal valueAmount, List<BillItemValue> bill);
void ShowInfo(Voucher voucher);