Fix: Quantity for the kot could not be negative, so no scope of deleting products

Fix: It was asking to confirm cancel even when no new product was added.
This commit is contained in:
tanshu 2016-04-11 18:57:07 +05:30
parent 20eac3c216
commit 19353005a5

View File

@ -93,8 +93,8 @@ namespace Tanshu.Accounts.PointOfSale
quantity += item.inventory.Quantity;
if (quantity < 0 && !Session.IsAllowed("Edit Printed Product"))
return;
var total = quantity + _bill.Where(x => x.Key.ProductID == key.ProductID && x.Key.KotID != Guid.Empty && x.Key.BillItemType == key.BillItemType).Sum(x => x.Value.inventory.Quantity);
quantity = Math.Max(quantity, 0);
var old = _bill.Where(x => x.Key.ProductID == key.ProductID && x.Key.KotID != Guid.Empty && x.Key.BillItemType == key.BillItemType).Sum(x => x.Value.inventory.Quantity);
quantity = Math.Max(quantity, -1 * old);
item.inventory.Quantity = quantity;
}
public void SetPrice(BillItemValue item)
@ -171,7 +171,7 @@ namespace Tanshu.Accounts.PointOfSale
public bool CancelBillChanges()
{
if (_bill.Any(x => x.Key.BillItemType != BillItemType.Kot) &&
if (_bill.Any(x => x.Key.BillItemType != BillItemType.Kot && x.Key.KotID == Guid.Empty) &&
MessageBox.Show("Abandon Changes?", "Abandon Changes", MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
return false;