diff --git a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs index 45f3184..530cf66 100644 --- a/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs +++ b/Tanshu.Accounts.PointOfSale/Controllers/BillController.cs @@ -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;