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:
tanshu 2016-05-12 14:41:02 +05:30
parent 5124347d1b
commit 5f0f80ed1e
4 changed files with 54 additions and 49 deletions

View File

@ -381,19 +381,10 @@ namespace Tanshu.Accounts.PointOfSale
ClearBill();
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)
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)
{
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"))
return false;
#endregion
var amount = _bill.NetAmount;
SetDiscount();
return true;
}
public bool SaveAndPrintBill(bool isPrinted, decimal amount)
{
if (isPrinted)
{
SaveReprintOrDiscountBill(amount);

View File

@ -95,6 +95,8 @@ namespace Tanshu.Accounts.PointOfSale
else
product.Price = decimal.Parse(txtPrice.Text.Trim());
product.HasHappyHour = chkHasHappyHour.Checked;
// Tax
if (cmbVat.SelectedItem == null)
{

View File

@ -22,8 +22,10 @@ namespace Tanshu.Accounts.PointOfSale.Sales
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)
{
txtBillID.Text = "";
@ -106,14 +108,14 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (!e.Alt)
{
_controller.ShowCustomers();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
break;
}
case Keys.F8:
{
_controller.LoadBill(null);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
FormState = SaleFormState.Billing;
break;
}
@ -130,19 +132,19 @@ namespace Tanshu.Accounts.PointOfSale.Sales
case Keys.Delete:
{
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
break;
}
case Keys.Add:
{
_controller.SetQuantity(CurrentKey, CurrentProduct, 1, false);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
break;
}
case Keys.Subtract:
{
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
break;
}
case Keys.Up:
@ -160,7 +162,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
case Keys.Escape:
{
var canceled = _controller.CancelBillChanges();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
if (canceled)
FormState = SaleFormState.Waiting;
break;
@ -177,20 +179,20 @@ namespace Tanshu.Accounts.PointOfSale.Sales
lblServiceCharge.Visible = showSC;
}
var state = _controller.FormLoad();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
FormState = state;
}
private void btnCustomer_Click(object sender, EventArgs e)
{
_controller.ShowCustomers();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
private void btnVoid_Click(object sender, EventArgs e)
{
var voided = _controller.VoidBill();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
if (voided)
FormState = SaleFormState.Waiting;
}
@ -201,13 +203,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
if (item == null)
return;
_controller.SetPrice(CurrentProduct);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
private void btnClear_Click(object sender, EventArgs e)
{
var canceled = _controller.CancelBillChanges();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
if (canceled)
FormState = SaleFormState.Waiting;
}
@ -246,7 +248,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnSettle_Click(object sender, EventArgs e)
{
var settled = _controller.SettleBill();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
if (settled)
FormState = SaleFormState.Waiting;
}
@ -258,19 +260,19 @@ namespace Tanshu.Accounts.PointOfSale.Sales
return; // No Product or Old Product
_controller.ShowModifiers(item);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
private void btnDelete_Click(object sender, EventArgs e)
{
_controller.SetQuantity(CurrentKey, CurrentProduct, -1, false);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
private void btnMoveTable_Click(object sender, EventArgs e)
{
_controller.MoveTable();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
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)
{
_controller.MoveKot(CurrentKot);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
#region Helper Functions
@ -363,7 +365,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
showModifier = bi.HasCompulsoryModifier(CurrentProduct.inventory.Product.ProductGroup.ProductGroupID);
if (showModifier)
_controller.ShowModifiers(CurrentProduct);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
private void productPage_Click(object sender, EventArgs e)
@ -386,7 +388,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
var item = button.Tag as FoodTable;
var tableName = item.Name;
_controller.LoadBill(tableName);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
FormState = SaleFormState.Billing;
}
@ -403,14 +405,28 @@ namespace Tanshu.Accounts.PointOfSale.Sales
}
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)
return;
if (_controller._editVoucherID.HasValue)
this.Close();
else
{
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
FormState = SaleFormState.Waiting;
}
}
@ -424,7 +440,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
this.Close();
else
{
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
FormState = SaleFormState.Waiting;
}
}
@ -432,13 +448,13 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnQuantity_Click(object sender, EventArgs e)
{
_controller.SetQuantity(CurrentKey, CurrentProduct, 0, true);
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
private void btnDiscount_Click(object sender, EventArgs e)
{
_controller.SetDiscount();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
#endregion
@ -446,7 +462,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales
private void btnSplitBill_Click(object sender, EventArgs e)
{
_controller.SplitBill();
ShowInfo(_controller._voucher, _controller._bill);
ShowInfo();
}
}
}

View File

@ -142,21 +142,18 @@ inner join v.Kots k
inner join k.Inventories i
inner join i.Vat va
where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false
and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v
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)
and exists (
select Voucher from VoucherSettlement vs where vs.Voucher = v and vs.Settled in (:cash, :creditCard, :billToCompany)
)
group by i.VatRate, va.Name
";
var list = _session
.CreateQuery(query)
.SetParameter("startDate", startDate)
.SetParameter("finishDate", finishDate)
.SetParameter("noCharge", SettleOption.NoCharge)
.SetParameter("unsettled", SettleOption.Unsettled)
.SetParameter("amount", SettleOption.Amount)
.SetParameter("roundoff", SettleOption.RoundOff)
.SetParameter("staff", SettleOption.Staff)
.SetParameter("void", SettleOption.Void)
.SetParameter("tip", SettleOption.Tip)
.SetParameter("cash", SettleOption.Cash)
.SetParameter("creditCard", SettleOption.CreditCard)
.SetParameter("billToCompany", SettleOption.BillToCompany)
.List<object[]>();
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] });