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); } }
public OrderTagValue GetOrderTagValue(string s) { if (OrderTagValues.Any(x => x.OrderTagGroupName == s)) { return(OrderTagValues.First(x => x.OrderTagGroupName == s)); } return(OrderTagValue.Empty); }
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); } }
//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); }
//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); }
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); }
public decimal GetOrderTagPrice() { return(GetOrderTagSum(OrderTagValues.Where(x => !x.AddTagPriceToOrderPrice))); }
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); }
//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); }
public bool IsTaggedWith(OrderTagGroup orderTagGroup) { return(OrderTagValues.FirstOrDefault(x => x.OrderTagGroupId == orderTagGroup.Id) != null); }
public bool IsTaggedWith(OrderTag model) { return(OrderTagValues.Any(x => x.Name == model.Name)); }
public decimal GetMenuItemOrderTagPrice() { return(GetOrderTagSum(OrderTagValues.Where(x => x.AddTagPriceToOrderPrice), TaxIncluded)); }
private void UntagOrder(OrderTagValue orderTagValue) { OrderTagValues.Remove(orderTagValue); }
private string GetOrderKey() { return(string.Join("", OrderTagValues.OrderBy(x => x.OrderKey).Select(x => x.OrderKey))); }
public bool IsTaggedWith(OrderTag orderTag) { return(OrderTagValues.Any(x => x.TagValue == orderTag.Name)); }
public void UntagOrder(OrderTagValue orderTagValue) { OrderTagValues.Remove(orderTagValue); OrderTags = JsonHelper.Serialize(OrderTagValues); _orderTagValues = null; }
public IEnumerable <OrderTagValue> GetOrderTagValues(Func <OrderTagValue, bool> prediction) { return(OrderTagValues.Where(prediction)); }
public bool OrderTagExists(Func <OrderTagValue, bool> prediction) { return(OrderTagValues.Any(prediction)); }