Fix: Updated PrintBill where discount is showed on screen before printing bill.
Fix: Updated Product Page so that HappyHour is updated properly
This commit is contained in:
parent
5124347d1b
commit
5f0f80ed1e
|
@ -381,19 +381,10 @@ namespace Tanshu.Accounts.PointOfSale
|
||||||
ClearBill();
|
ClearBill();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool SaveAndPrintBill()
|
public bool CanSaveBill(bool isPrinted, bool isVoid)
|
||||||
{
|
{
|
||||||
#region Check if Allowed
|
|
||||||
if (!Session.IsAllowed("Print Bill") || _bill.Count(x => x.Key.BillItemType != BillItemType.Kot) == 0)
|
if (!Session.IsAllowed("Print Bill") || _bill.Count(x => x.Key.BillItemType != BillItemType.Kot) == 0)
|
||||||
return false;
|
return false;
|
||||||
bool isPrinted = false, isVoid = false;
|
|
||||||
if (_voucher.VoucherID != Guid.Empty)
|
|
||||||
using (var bi = new VoucherBI())
|
|
||||||
{
|
|
||||||
var dbVoucher = bi.Get(x => x.VoucherID == _voucher.VoucherID);
|
|
||||||
isPrinted = dbVoucher.Printed;
|
|
||||||
isVoid = dbVoucher.Void;
|
|
||||||
}
|
|
||||||
if (isVoid)
|
if (isVoid)
|
||||||
{
|
{
|
||||||
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _voucher.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(string.Format("This Bill is already void.\nReason: {0}", _voucher.VoidReason), "Bill already Voided", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
@ -401,11 +392,10 @@ namespace Tanshu.Accounts.PointOfSale
|
||||||
}
|
}
|
||||||
if (isPrinted && !Session.IsAllowed("Edit Printed Bill"))
|
if (isPrinted && !Session.IsAllowed("Edit Printed Bill"))
|
||||||
return false;
|
return false;
|
||||||
#endregion
|
return true;
|
||||||
|
}
|
||||||
var amount = _bill.NetAmount;
|
public bool SaveAndPrintBill(bool isPrinted, decimal amount)
|
||||||
|
{
|
||||||
SetDiscount();
|
|
||||||
if (isPrinted)
|
if (isPrinted)
|
||||||
{
|
{
|
||||||
SaveReprintOrDiscountBill(amount);
|
SaveReprintOrDiscountBill(amount);
|
||||||
|
|
|
@ -95,6 +95,8 @@ namespace Tanshu.Accounts.PointOfSale
|
||||||
else
|
else
|
||||||
product.Price = decimal.Parse(txtPrice.Text.Trim());
|
product.Price = decimal.Parse(txtPrice.Text.Trim());
|
||||||
|
|
||||||
|
product.HasHappyHour = chkHasHappyHour.Checked;
|
||||||
|
|
||||||
// Tax
|
// Tax
|
||||||
if (cmbVat.SelectedItem == null)
|
if (cmbVat.SelectedItem == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,8 +22,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
this.Text = Session.User.Name;
|
this.Text = Session.User.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowInfo(Voucher voucher, BillDict bill)
|
private void ShowInfo()
|
||||||
{
|
{
|
||||||
|
Voucher voucher = _controller._voucher;
|
||||||
|
BillDict bill = _controller._bill;
|
||||||
if (voucher.VoucherID == Guid.Empty)
|
if (voucher.VoucherID == Guid.Empty)
|
||||||
{
|
{
|
||||||
txtBillID.Text = "";
|
txtBillID.Text = "";
|
||||||
|
@ -106,14 +108,14 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
if (!e.Alt)
|
if (!e.Alt)
|
||||||
{
|
{
|
||||||
_controller.ShowCustomers();
|
_controller.ShowCustomers();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Keys.F8:
|
case Keys.F8:
|
||||||
{
|
{
|
||||||
_controller.LoadBill(null);
|
_controller.LoadBill(null);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
FormState = SaleFormState.Billing;
|
FormState = SaleFormState.Billing;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -130,19 +132,19 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
case Keys.Delete:
|
case Keys.Delete:
|
||||||
{
|
{
|
||||||
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Keys.Add:
|
case Keys.Add:
|
||||||
{
|
{
|
||||||
_controller.SetQuantity(CurrentKey, CurrentProduct, 1, false);
|
_controller.SetQuantity(CurrentKey, CurrentProduct, 1, false);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Keys.Subtract:
|
case Keys.Subtract:
|
||||||
{
|
{
|
||||||
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Keys.Up:
|
case Keys.Up:
|
||||||
|
@ -160,7 +162,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
case Keys.Escape:
|
case Keys.Escape:
|
||||||
{
|
{
|
||||||
var canceled = _controller.CancelBillChanges();
|
var canceled = _controller.CancelBillChanges();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
if (canceled)
|
if (canceled)
|
||||||
FormState = SaleFormState.Waiting;
|
FormState = SaleFormState.Waiting;
|
||||||
break;
|
break;
|
||||||
|
@ -177,20 +179,20 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
lblServiceCharge.Visible = showSC;
|
lblServiceCharge.Visible = showSC;
|
||||||
}
|
}
|
||||||
var state = _controller.FormLoad();
|
var state = _controller.FormLoad();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
FormState = state;
|
FormState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCustomer_Click(object sender, EventArgs e)
|
private void btnCustomer_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_controller.ShowCustomers();
|
_controller.ShowCustomers();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnVoid_Click(object sender, EventArgs e)
|
private void btnVoid_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var voided = _controller.VoidBill();
|
var voided = _controller.VoidBill();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
if (voided)
|
if (voided)
|
||||||
FormState = SaleFormState.Waiting;
|
FormState = SaleFormState.Waiting;
|
||||||
}
|
}
|
||||||
|
@ -201,13 +203,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
_controller.SetPrice(CurrentProduct);
|
_controller.SetPrice(CurrentProduct);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnClear_Click(object sender, EventArgs e)
|
private void btnClear_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var canceled = _controller.CancelBillChanges();
|
var canceled = _controller.CancelBillChanges();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
if (canceled)
|
if (canceled)
|
||||||
FormState = SaleFormState.Waiting;
|
FormState = SaleFormState.Waiting;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +248,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
private void btnSettle_Click(object sender, EventArgs e)
|
private void btnSettle_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var settled = _controller.SettleBill();
|
var settled = _controller.SettleBill();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
if (settled)
|
if (settled)
|
||||||
FormState = SaleFormState.Waiting;
|
FormState = SaleFormState.Waiting;
|
||||||
}
|
}
|
||||||
|
@ -258,19 +260,19 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
return; // No Product or Old Product
|
return; // No Product or Old Product
|
||||||
|
|
||||||
_controller.ShowModifiers(item);
|
_controller.ShowModifiers(item);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDelete_Click(object sender, EventArgs e)
|
private void btnDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnMoveTable_Click(object sender, EventArgs e)
|
private void btnMoveTable_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_controller.MoveTable();
|
_controller.MoveTable();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnMore_Click(object sender, EventArgs e)
|
private void btnMore_Click(object sender, EventArgs e)
|
||||||
|
@ -303,7 +305,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
private void btnMoveKot_Click(object sender, EventArgs e)
|
private void btnMoveKot_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_controller.MoveKot(CurrentKot);
|
_controller.MoveKot(CurrentKot);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Helper Functions
|
#region Helper Functions
|
||||||
|
@ -363,7 +365,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
showModifier = bi.HasCompulsoryModifier(CurrentProduct.inventory.Product.ProductGroup.ProductGroupID);
|
showModifier = bi.HasCompulsoryModifier(CurrentProduct.inventory.Product.ProductGroup.ProductGroupID);
|
||||||
if (showModifier)
|
if (showModifier)
|
||||||
_controller.ShowModifiers(CurrentProduct);
|
_controller.ShowModifiers(CurrentProduct);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void productPage_Click(object sender, EventArgs e)
|
private void productPage_Click(object sender, EventArgs e)
|
||||||
|
@ -386,7 +388,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
var item = button.Tag as FoodTable;
|
var item = button.Tag as FoodTable;
|
||||||
var tableName = item.Name;
|
var tableName = item.Name;
|
||||||
_controller.LoadBill(tableName);
|
_controller.LoadBill(tableName);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
FormState = SaleFormState.Billing;
|
FormState = SaleFormState.Billing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,14 +405,28 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
}
|
}
|
||||||
private void btnPrintBill_Click(object sender, EventArgs e)
|
private void btnPrintBill_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var printed = _controller.SaveAndPrintBill();
|
bool isPrinted = false, isVoid = false;
|
||||||
|
if (_controller._voucher.VoucherID != Guid.Empty)
|
||||||
|
using (var bi = new VoucherBI())
|
||||||
|
{
|
||||||
|
var dbVoucher = bi.Get(x => x.VoucherID == _controller._voucher.VoucherID);
|
||||||
|
isPrinted = dbVoucher.Printed;
|
||||||
|
isVoid = dbVoucher.Void;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_controller.CanSaveBill(isPrinted, isVoid))
|
||||||
|
return;
|
||||||
|
var amount = _controller._bill.NetAmount;
|
||||||
|
_controller.SetDiscount();
|
||||||
|
ShowInfo();
|
||||||
|
var printed = _controller.SaveAndPrintBill(isPrinted, amount);
|
||||||
if (!printed)
|
if (!printed)
|
||||||
return;
|
return;
|
||||||
if (_controller._editVoucherID.HasValue)
|
if (_controller._editVoucherID.HasValue)
|
||||||
this.Close();
|
this.Close();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
FormState = SaleFormState.Waiting;
|
FormState = SaleFormState.Waiting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,7 +440,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
this.Close();
|
this.Close();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
FormState = SaleFormState.Waiting;
|
FormState = SaleFormState.Waiting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,13 +448,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
private void btnQuantity_Click(object sender, EventArgs e)
|
private void btnQuantity_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_controller.SetQuantity(CurrentKey, CurrentProduct, 0, true);
|
_controller.SetQuantity(CurrentKey, CurrentProduct, 0, true);
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDiscount_Click(object sender, EventArgs e)
|
private void btnDiscount_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_controller.SetDiscount();
|
_controller.SetDiscount();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -446,7 +462,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
|
||||||
private void btnSplitBill_Click(object sender, EventArgs e)
|
private void btnSplitBill_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_controller.SplitBill();
|
_controller.SplitBill();
|
||||||
ShowInfo(_controller._voucher, _controller._bill);
|
ShowInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -142,21 +142,18 @@ inner join v.Kots k
|
||||||
inner join k.Inventories i
|
inner join k.Inventories i
|
||||||
inner join i.Vat va
|
inner join i.Vat va
|
||||||
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
|
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
|
||||||
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v
|
and exists (
|
||||||
and vs.Settled != :noCharge and vs.Settled != :unsettled and vs.Settled != :amount and vs.Settled != :roundoff and vs.Settled != :staff and vs.Settled != :void and vs.Settled != :tip)
|
select Voucher from VoucherSettlement vs where vs.Voucher = v and vs.Settled in (:cash, :creditCard, :billToCompany)
|
||||||
|
)
|
||||||
group by i.VatRate, va.Name
|
group by i.VatRate, va.Name
|
||||||
";
|
";
|
||||||
var list = _session
|
var list = _session
|
||||||
.CreateQuery(query)
|
.CreateQuery(query)
|
||||||
.SetParameter("startDate", startDate)
|
.SetParameter("startDate", startDate)
|
||||||
.SetParameter("finishDate", finishDate)
|
.SetParameter("finishDate", finishDate)
|
||||||
.SetParameter("noCharge", SettleOption.NoCharge)
|
.SetParameter("cash", SettleOption.Cash)
|
||||||
.SetParameter("unsettled", SettleOption.Unsettled)
|
.SetParameter("creditCard", SettleOption.CreditCard)
|
||||||
.SetParameter("amount", SettleOption.Amount)
|
.SetParameter("billToCompany", SettleOption.BillToCompany)
|
||||||
.SetParameter("roundoff", SettleOption.RoundOff)
|
|
||||||
.SetParameter("staff", SettleOption.Staff)
|
|
||||||
.SetParameter("void", SettleOption.Void)
|
|
||||||
.SetParameter("tip", SettleOption.Tip)
|
|
||||||
.List<object[]>();
|
.List<object[]>();
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
outList.Add(new TaxAnalysis() { Name = string.Format("{0} - {1:#.##%;(#.##%);0%}", (string)item[0], (decimal)item[1]), TaxRate = (decimal)item[1], TaxAmount = (decimal)item[2], NetSale = (decimal)item[3] });
|
outList.Add(new TaxAnalysis() { Name = string.Format("{0} - {1:#.##%;(#.##%);0%}", (string)item[0], (decimal)item[1]), TaxRate = (decimal)item[1], TaxAmount = (decimal)item[2], NetSale = (decimal)item[3] });
|
||||||
|
|
Loading…
Reference in New Issue