private void CheckQuantityAvailableFor(IOutgoingProduct outgoing) { ProductQuantity productQuantity = ProductQuantities .SingleOrDefault(p => p.Id == outgoing.ProductId); InsufficientBalance = productQuantity == null || productQuantity.TotalAvailable < outgoing.Quantity; }
private void RegisterStockMovementFor(IOutgoingProduct outgoing) { outgoing.TransactionId = Guid.NewGuid(); Tenant.ProductMovements.Add(new ProductMovement { StoreId = Order.StoreId, Date = Order.Date, TransactionId = outgoing.TransactionId.Value, ProductId = outgoing.ProductId, Quantity = outgoing.Quantity * (-1) }); }
public async Task <bool> Confirm() { await RetrieveProductsAndQuantities(); foreach (Product product in Products) { if (product.InventoryControl == InventoryControl.Unit) { IOutgoingProduct outgoing = Order.OutgoingList .Single(p => p.ProductId == product.Id); CheckQuantityAvailableFor(outgoing); if (InsufficientBalance) { return(false); } RegisterStockMovementFor(outgoing); } } return(true); }