Пример #1
0
 public void Add(Consignment item)
 {
     Deliveries.Add(item);
     if (item is IValuable)
     {
         Valuables.Add((item as IValuable));
     }
 }
Пример #2
0
        public void AddDelivery(Delivery delivery)
        {
            if (Deliveries == null)
            {
                Deliveries = new List <Delivery>();
            }

            Deliveries.Add(delivery);
            Refresh();
        }
Пример #3
0
        public void AddDelivery(House house, List <Ingredient> pizza)
        {
            house.OnPizzaOrdered(pizza);
            Deliveries.Add(house);
            TotalNumDeliveries++;

            foreach (Ingredient ingredient in pizza)
            {
                //Debug.WriteLine(" Ingredient Pos On Grid = {0} ", ingredient.GetPositionOnGrid());
                DeliveryIngredientPositions.Add(ingredient.GetPositionOnGrid());
            }
        }
Пример #4
0
        public void SetDeliveries(IEnumerable <Tuple <DeliveryMode, DateTimeOffset, string> > orderDeliveries)
        {
            if (Deliveries == null || Deliveries.Any())
            {
                Deliveries = new List <OrderDelivery>();
            }

            foreach (var orderDelivery in orderDeliveries)
            {
                Deliveries.Add(new OrderDelivery(orderDelivery.Item1, orderDelivery.Item2, orderDelivery.Item3));
            }

            DeliveryFeesWholeSalePrice = 0;
            DeliveryFeesVatPrice       = 0;
            DeliveryFeesOnSalePrice    = 0;

            foreach (var delivery in Deliveries)
            {
                var deliveryMode = delivery.DeliveryMode;

                if (deliveryMode.AcceptPurchaseOrdersWithAmountGreaterThan.HasValue &&
                    deliveryMode.AcceptPurchaseOrdersWithAmountGreaterThan.Value >
                    (TotalProductWholeSalePrice + TotalReturnableWholeSalePrice))
                {
                    throw SheaftException.Validation(
                              $"Le montant de la commande pour {deliveryMode.Producer.Name} est inférieur au palier de {deliveryMode.AcceptPurchaseOrdersWithAmountGreaterThan.Value}€ fixé par le producteur.");
                }

                if (deliveryMode.ApplyDeliveryFeesWhen is DeliveryFeesApplication.Always)
                {
                    DeliveryFeesWholeSalePrice += deliveryMode.DeliveryFeesWholeSalePrice ?? 0;
                    DeliveryFeesVatPrice       += deliveryMode.DeliveryFeesVatPrice ?? 0;
                    DeliveryFeesOnSalePrice    += deliveryMode.DeliveryFeesOnSalePrice ?? 0;
                }

                if (deliveryMode.ApplyDeliveryFeesWhen is DeliveryFeesApplication.TotalLowerThanPurchaseOrderAmount &&
                    deliveryMode.DeliveryFeesMinPurchaseOrdersAmount.HasValue &&
                    deliveryMode.DeliveryFeesMinPurchaseOrdersAmount.Value >
                    (TotalProductWholeSalePrice + TotalReturnableWholeSalePrice))
                {
                    DeliveryFeesWholeSalePrice += deliveryMode.DeliveryFeesWholeSalePrice ?? 0;
                    DeliveryFeesVatPrice       += deliveryMode.DeliveryFeesVatPrice ?? 0;
                    DeliveryFeesOnSalePrice    += deliveryMode.DeliveryFeesOnSalePrice ?? 0;
                }
            }

            DeliveriesCount = Deliveries?.Count ?? 0;
            RefreshOrder();
        }
Пример #5
0
        private void SetDeliveries(IEnumerable <Delivery> deliveries)
        {
            if (Deliveries == null || Deliveries.Any())
            {
                Deliveries = new List <Delivery>();
            }

            var positionCounter = 0;

            foreach (var delivery in deliveries.OrderBy(d => d.Position))
            {
                if (delivery.DeliveryBatchId.HasValue && delivery.DeliveryBatchId != Id)
                {
                    delivery.DeliveryBatch.RemoveDelivery(delivery);
                }

                delivery.SetPosition(positionCounter);
                Deliveries.Add(delivery);
                positionCounter++;
            }

            Refresh();
        }