public SubscriptionCharge(ClientAddress deliveryAddress = null, UnitofWork uow = null)
        {
            _subscriptionHelper = uow == null ? new SubscriptionHelper() : new SubscriptionHelper(uow);

            _orderCharge= new OrderChargeModel();
            if (deliveryAddress != null)
            {
                _deliveryAddress = deliveryAddress;
            }
        }
Beispiel #2
0
        public OrderChargeModel Calculate(Order order)
        {
            var orderItems = (from c in _orderItem where c.OrderId == order.OrderId select c).ToList();
            if (orderItems.Any())
            {
                _orderCharge = new OrderChargeModel();
                var firstOrderItem = orderItems.FirstOrDefault();
                if (firstOrderItem != null) _orderCharge.CookerId = firstOrderItem.CookerId;
                var taxPercent = new Common.Util().GetTaxPercent(_orderCharge.CookerId);
                _orderCharge.OrderTypeValue = Enum.GetName(typeof(OrderModelType.Values), order.OrderTypeId);
                _orderCharge.PaymentMethodValue = Enum.GetName(typeof(PaymentMethodType.Values), order.PaymentMethodId);

                #region PickUpOrderCharge

                if (order.OrderTypeId == (int)OrderType.Values.PickUp)
                {
                    _orderCharge = PickUpCharge(order, taxPercent);
                }

                #endregion

                #region DeliveryOrderCharge

                var cookerDelieryZonesId = (from c in _cookerDeliveryZones where c.CookerId == _orderCharge.CookerId select c.DeliveryId).ToList();

                decimal deliveryFees = 0;
                foreach (var deliveryZoneId in cookerDelieryZonesId)
                {
                    //Custom KML Function to see if the item is in the zone
                    //Moq for now
                    var deliveryzone = _deliveryZones.FirstOrDefault(c => c.DeliveryId == deliveryZoneId);

                    //KML integration to see if deliveryaddress is Zone
                    if (_deliveryAddress.AddressTypeId == (int)AddressToDeliveryZone.Values.AddressInZone)
                    {
                        if (deliveryzone != null)
                        {
                            deliveryFees = deliveryzone.DeliveryFees;
                        }
                    }
                }

                _orderCharge = DeliveryCharge(order, deliveryFees, taxPercent);

                #endregion

                _orderCharge.SalesTaxes = new Money().RoundTo2Decimal(CalculateSalesTax(_orderCharge.TotalCharges, taxPercent));
                _orderCharge.PlanTitle = null;
                return _orderCharge;
            }
            return null;
        }
        public OrderChargeModel Calculate(int clientSubscriptionId, OrderSubscription orderSubscription)
        {
            _orderCharge = new OrderChargeModel
            {
                CookerId = _subscriptionHelper.GetCookerServingPriceModel(clientSubscriptionId).CookerId
            };
            var taxPercent = _subscriptionHelper.GetTaxPercent(_subscriptionHelper.GetCookerServingPriceModel(clientSubscriptionId).CookerId);
            _orderCharge.OrderTypeValue = Enum.GetName(typeof(OrderModelType.Values), orderSubscription.OrderTypeId);
            _orderCharge.PaymentMethodValue = Enum.GetName(typeof(PaymentMethodType.Values), orderSubscription.PaymentMethodId);

            #region PickUpOrderCharge

            //if (orderSubscription.OrderTypeId == (int)OrderType.Values.PickUp)
            //{
            //   _orderCharge = PickUpCharge(orderSubscription, taxPercent);
            //}

            #endregion

            #region DeliveryOrderCharge

            //var cookerDelieryZonesId = (from c in _cookerDeliveryZones where c.CookerId == cookerId select c.DeliveryId).ToList();

            //decimal deliveryFees = 0;
            //foreach (var deliveryZoneId in cookerDelieryZonesId)
            //{
            //    //Custom KML Function to see if the item is in the zone
            //    //Moq for now
            //    var deliveryzone = _deliveryZones.FirstOrDefault(c => c.DeliveryId == deliveryZoneId);

            //    //KML integration to see if deliveryaddress is Zone
            //    if (_deliveryAddress.AddressTypeId == (int) AddressToDeliveryZone.Values.AddressInZone)
            //    {
            //        if (deliveryzone != null)
            //        {
            //            deliveryFees = deliveryzone.DeliveryFees;
            //        }
            //    }
            //}

            //_orderCharge = DeliveryCharge(order, deliveryFees, taxPercent);

            #endregion

            #region Neutral
            _orderCharge = Netural(orderSubscription, taxPercent);
            #endregion

            return _orderCharge;
        }