Exemplo n.º 1
0
        public async Task <bool> Confirm()
        {
            Products = await Tenant.Products
                       .WhereIdIn(Order.IncomingList.Select(p => p.ProductId))
                       .ToListAsync();

            foreach (Product product in Products)
            {
                if (HasProductThatNotMovementStock = product.InventoryControl == InventoryControl.None)
                {
                    return(false);
                }

                IIncomingProduct incoming = Order.IncomingList
                                            .Single(p => p.ProductId == product.Id);

                incoming.TransactionId = Guid.NewGuid();

                Tenant.ProductMovements.Add(new ProductMovement
                {
                    StoreId       = Order.StoreId,
                    Date          = Order.Date,
                    TransactionId = incoming.TransactionId.Value,
                    ProductId     = incoming.ProductId,
                    Quantity      = incoming.Quantity
                });
            }

            return(true);
        }
Exemplo n.º 2
0
        private void CheckQuantityAvailableForRevert(IIncomingProduct incoming)
        {
            ProductQuantity productQuantity = ProductQuantities
                                              .SingleOrDefault(p => p.Id == incoming.ProductId);

            InsufficientBalance =
                productQuantity == null ||
                productQuantity.TotalAvailable < incoming.Quantity;
        }