Exemple #1
0
        public void UpdatePortion(MenuItemPortion portion, string priceTag, IEnumerable <TaxTemplate> taxTemplates)
        {
            PortionName = portion.Name;

            UpdateTaxTemplates(taxTemplates);

            if (!string.IsNullOrEmpty(priceTag))
            {
                string tag   = priceTag;
                var    price = portion.Prices.SingleOrDefault(x => x.PriceTag == tag);
                if (price != null && price.Price > 0)
                {
                    UpdatePrice(price.Price, price.PriceTag);
                }
                else
                {
                    priceTag = "";
                }
            }

            if (string.IsNullOrEmpty(priceTag))
            {
                UpdatePrice(portion.Price, "");
            }

            if (OrderTagValues.Any(x => x.MenuItemId > 0 && x.PortionName != portion.Name))
            {
                foreach (var orderTagValue in OrderTagValues.Where(x => x.MenuItemId > 0))
                {
                    orderTagValue.PortionName = portion.Name;
                }
                OrderTags       = JsonHelper.Serialize(OrderTagValues);
                _orderTagValues = null;
            }
        }
        private void TagOrder(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, int tagIndex, string tagNote)
        {
            var otag = new OrderTagValue
            {
                TagValue                = orderTag.Name,
                OrderTagGroupId         = orderTagGroup.Id,
                TagName                 = orderTagGroup.Name,
                TagNote                 = !string.IsNullOrEmpty(tagNote) ? tagNote : null,
                MenuItemId              = orderTag.MenuItemId,
                AddTagPriceToOrderPrice = orderTagGroup.AddTagPriceToOrderPrice,
                PortionName             = orderTag.MenuItemId > 0 ? PortionName : null,
                UserId   = userId,
                Quantity = 1,
                OrderKey = orderTagGroup.SortOrder.ToString("000") + orderTag.SortOrder.ToString("000"),
                TaxFree  = orderTagGroup.TaxFree
            };

            otag.UpdatePrice(orderTag.Price);

            if (tagIndex > -1)
            {
                OrderTagValues.Insert(tagIndex, otag);
            }
            else
            {
                OrderTagValues.Add(otag);
            }
            OrderTags       = JsonHelper.Serialize(OrderTagValues);
            _orderTagValues = null;
        }
        public bool ToggleOrderTag(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, string tagNote)
        {
            var result = true;
            var otag   = OrderTagValues.FirstOrDefault(x => x.TagValue == orderTag.Name);

            if (otag == null)
            {
                if (orderTagGroup.MaxSelectedItems > 1 && OrderTagValues.Count(x => x.OrderTagGroupId == orderTagGroup.Id) >= orderTagGroup.MaxSelectedItems)
                {
                    return(false);
                }
                var tagIndex = -1;
                if (orderTagGroup.MaxSelectedItems == 1)
                {
                    var sTag = OrderTagValues.SingleOrDefault(x => x.OrderTagGroupId == orderTag.OrderTagGroupId);
                    if (sTag != null)
                    {
                        tagIndex = OrderTagValues.IndexOf(sTag);
                    }
                    OrderTagValues.Where(x => x.OrderTagGroupId == orderTagGroup.Id).ToList().ForEach(x => OrderTagValues.Remove(x));
                }
                TagOrder(orderTagGroup, orderTag, userId, tagIndex, tagNote);
            }
            else
            {
                otag.Quantity++;
                if (orderTagGroup.MaxSelectedItems == 1 || (orderTag.MaxQuantity > 0 && otag.Quantity > orderTag.MaxQuantity))
                {
                    UntagOrder(otag);
                    result = false;
                }
            }
            OrderTags = JsonHelper.Serialize(OrderTagValues);
            return(result);
        }
 public void TagIfNotTagged(OrderTagGroup orderTagGroup, OrderTag orderTag, int userId, string tagNote)
 {
     if (OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.TagValue == orderTag.Name) == null)
     {
         ToggleOrderTag(orderTagGroup, orderTag, userId, tagNote);
     }
 }
Exemple #5
0
 public OrderTagValue GetOrderTagValue(string s)
 {
     if (OrderTagValues.Any(x => x.OrderTagGroupName == s))
     {
         return(OrderTagValues.First(x => x.OrderTagGroupName == s));
     }
     return(OrderTagValue.Empty);
 }
Exemple #6
0
        public void UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag)
        {
            var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.Name == orderTag.Name);

            if (value != null)
            {
                UntagOrder(value);
            }
        }
Exemple #7
0
        //Görünen fiyat
        public decimal GetVisiblePrice()
        {
            var result = Price + OrderTagValues.Where(x => x.AddTagPriceToOrderPrice).Sum(x => x.Price * x.Quantity);

            if (ProductTimerValue != null)
            {
                result = ProductTimerValue.GetPrice(result + GetOrderTagPrice());
            }
            return(result);
        }
Exemple #8
0
        //Vergi etkilememiş fiyat
        public decimal GetPrice()
        {
            var result = Price + OrderTagValues.Sum(x => x.Price * x.Quantity);

            if (ProductTimerValue != null)
            {
                result = ProductTimerValue.GetPrice(result);
            }
            return(result);
        }
Exemple #9
0
        public bool UntagIfTagged(OrderTagGroup orderTagGroup, OrderTag orderTag)
        {
            var value = OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id && x.TagValue == orderTag.Name);

            if (value != null)
            {
                UntagOrder(value);
                return(true);
            }
            return(false);
        }
Exemple #10
0
 public decimal GetOrderTagPrice()
 {
     return(GetOrderTagSum(OrderTagValues.Where(x => !x.AddTagPriceToOrderPrice)));
 }
Exemple #11
0
        public decimal GetTotalTaxAmount(decimal plainSum, decimal preTaxServices)
        {
            var result = CalculatePrice && (DecreaseInventory || IncreaseInventory) ? (TaxAmount + OrderTagValues.Sum(x => x.TaxAmount)) * Quantity : 0;

            if (preTaxServices != 0)
            {
                result += (result * preTaxServices) / plainSum;
            }
            return(result);
        }
Exemple #12
0
        //var plainSum = GetPlainSum();
        //var postServices = CalculateServices(Calculations.Where(x => !x.IncludeTax), plainSum);
        //var tax = CalculateTax(plainSum, postServices);

        public decimal GetTaxAmount()
        {
            var result = CalculatePrice && (DecreaseInventory || IncreaseInventory) ? (TaxAmount + OrderTagValues.Sum(x => x.TaxAmount)) * Quantity : 0;

            //if (IncreaseInventory) result = 0 - result;
            return(result);
        }
Exemple #13
0
 public bool IsTaggedWith(OrderTagGroup orderTagGroup)
 {
     return(OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null);
 }
Exemple #14
0
 public bool IsTaggedWith(OrderTag model)
 {
     return(OrderTagValues.Any(x => x.Name == model.Name));
 }
Exemple #15
0
 public decimal GetMenuItemOrderTagPrice()
 {
     return(GetOrderTagSum(OrderTagValues.Where(x => x.AddTagPriceToOrderPrice), TaxIncluded));
 }
Exemple #16
0
 private void UntagOrder(OrderTagValue orderTagValue)
 {
     OrderTagValues.Remove(orderTagValue);
 }
Exemple #17
0
 private string GetOrderKey()
 {
     return(string.Join("", OrderTagValues.OrderBy(x => x.OrderKey).Select(x => x.OrderKey)));
 }
Exemple #18
0
 public bool IsTaggedWith(OrderTag orderTag)
 {
     return(OrderTagValues.Any(x => x.TagValue == orderTag.Name));
 }
Exemple #19
0
 public void UntagOrder(OrderTagValue orderTagValue)
 {
     OrderTagValues.Remove(orderTagValue);
     OrderTags       = JsonHelper.Serialize(OrderTagValues);
     _orderTagValues = null;
 }
Exemple #20
0
 public IEnumerable <OrderTagValue> GetOrderTagValues(Func <OrderTagValue, bool> prediction)
 {
     return(OrderTagValues.Where(prediction));
 }
Exemple #21
0
 public bool OrderTagExists(Func <OrderTagValue, bool> prediction)
 {
     return(OrderTagValues.Any(prediction));
 }