コード例 #1
0
        private void CheckQuantityAvailableFor(IOutgoingProduct outgoing)
        {
            ProductQuantity productQuantity = ProductQuantities
                                              .SingleOrDefault(p => p.Id == outgoing.ProductId);

            InsufficientBalance =
                productQuantity == null ||
                productQuantity.TotalAvailable < outgoing.Quantity;
        }
コード例 #2
0
        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)
            });
        }
コード例 #3
0
        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);
        }