Пример #1
0
        /// <summary>
        /// Atualiza os dados de depósito por nova compra efetuada
        /// </summary>
        public void UpdateStock(ProductInWarehouse productInWarehouse, Purchase purchase)
        {
            var quantity = productInWarehouse.Total + purchase.Quantity;
            var total    = (productInWarehouse.AveragePrice * productInWarehouse.Total) + (purchase.Quantity * purchase.Price);
            var average  = Decimal.Round(total / quantity, 4);

            productInWarehouse.Total        = quantity;
            productInWarehouse.AveragePrice = average;
        }
        /// <summary>
        /// Obtém todos as informações de produtos dos depositos
        /// </summary>
        public static ProductInWarehouse GetProductsInWarehouse(this Repository <ProductInWarehouse> repository,
                                                                Product product, Warehouse warehouse)
        {
            ProductInWarehouse productInWarehouse = repository.Get(new GetProductInWarehouse(product.CodeCatalog, warehouse.Code));

            productInWarehouse.Product   = product;
            productInWarehouse.Warehouse = warehouse;
            return(productInWarehouse);
        }
Пример #3
0
        /// <summary>
        /// Registra a entrada do produto no depósito pela primeira compra
        /// </summary>
        public ProductInWarehouse RegisterNewProductStock(Purchase purchase)
        {
            var productInWarehouse = new ProductInWarehouse
            {
                Warehouse    = this,
                Product      = purchase.Product,
                Total        = purchase.Quantity,
                AveragePrice = purchase.Price
            };

            return(productInWarehouse);
        }