private int getPTypeSKUCount(ShoppingCartItemList cartItems, ShoppingCartItem_V01 currentItem)
        {
            int     count = 0;
            SKU_V01 skuV01;

            Dictionary <string, SKU_V01> allSKUs = CatalogProvider.GetAllSKU(this.Locale);

            foreach (ShoppingCartItem_V01 item in cartItems)
            {
                if (allSKUs.TryGetValue(item.SKU, out skuV01))
                {
                    if (skuV01.CatalogItem != null &&
                        skuV01.CatalogItem.ProductType == ProductType.Product)
                    {
                        count += item.Quantity;
                    }
                }
            }
            if (currentItem != null) // include current item being added
            {
                if (allSKUs.TryGetValue(currentItem.SKU, out skuV01))
                {
                    if (skuV01.CatalogItem != null &&
                        skuV01.CatalogItem.ProductType == ProductType.Product)
                    {
                        count += currentItem.Quantity;
                    }
                }
            }
            return(count);
        }
        private ShoppingCartRuleResult CheckForInvalidSKU(ShoppingCart_V01 shoppingCart,
                                                          ShoppingCartRuleResult ruleResult)
        {
            var cart = shoppingCart as MyHLShoppingCart;

            if (cart != null)
            {
                bool    isValid      = false;
                SKU_V01 testThisItem = null;
                var     validSKUList = CatalogProvider.GetAllSKU(Locale);
                if (null != validSKUList)
                {
                    isValid = validSKUList.TryGetValue(cart.CurrentItems[0].SKU, out testThisItem);
                    if (isValid)
                    {
                        isValid = (null != testThisItem.CatalogItem);
                    }
                }

                if (!isValid)
                {
                    ruleResult.Result = RulesResult.Failure;
                    var errorMessage =
                        HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform),
                                                            "SkuIsInvalid") ??
                        "SKU {0} is not available.";
                    ruleResult.AddMessage(string.Format(errorMessage.ToString(), cart.CurrentItems[0].SKU));
                }
            }
            return(ruleResult);
        }
Esempio n. 3
0
        private bool CanBuy_eLearningRule(MyHLShoppingCart hlCart)
        {
            bool retVal = true;

            if (PurchaseRestrictionProvider.RequireTraining(hlCart.DistributorID, hlCart.Locale, hlCart.CountryCode))
            {
                //var currentLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(hlCart.DistributorID);
                var currentLimits = GetCurrentPurchasingLimits(hlCart.DistributorID, GetCurrentOrderMonth());

                decimal currentVolumePoints = hlCart.VolumeInCart;
                if (hlCart.ItemsBeingAdded != null && hlCart.ItemsBeingAdded.Any())
                {
                    foreach (var i in hlCart.ItemsBeingAdded)
                    {
                        var currentItem = CatalogProvider.GetCatalogItem(i.SKU, Country);
                        currentVolumePoints += currentItem.VolumePoints * i.Quantity;
                    }
                }

                currentVolumePoints += (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume);

                if (currentVolumePoints > HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV)
                {
                    if (hlCart.ItemsBeingAdded != null)
                    {
                        hlCart.ItemsBeingAdded.Clear();
                    }
                    retVal = false;
                }
            }
            return(retVal);
        }
Esempio n. 4
0
        private void SetCategoryMenu()
        {
            List <string> apparelCategories = HLConfigManager.Configurations.DOConfiguration.ApparelCategoryName.Split(',').ToList();

            CatetoryMenu.DataSource = from r in ProductInfoCatalog.RootCategories
                                      where
                                      ShouldTake(r, _sessionInfo.IsEventTicketMode,
                                                 _sessionInfo.ShowAllInventory, _sessionInfo.IsHAPMode, "exclude", apparelCategories) &&
                                      CatalogProvider.IsDisplayable(r, Locale)
                                      select r;

            CatetoryMenu.DataBind();

            if (apparelCategories != null)
            {
                string apparelCat = apparelCategories.FirstOrDefault();
                if (!string.IsNullOrEmpty(apparelCat))
                {
                    ApparelMenu.DataSource = from r in ProductInfoCatalog.RootCategories
                                             where
                                             ShouldTake(r, _sessionInfo.IsEventTicketMode,
                                                        _sessionInfo.ShowAllInventory, _sessionInfo.IsHAPMode, "display", apparelCategories) &&
                                             CatalogProvider.IsDisplayable(r, Locale)
                                             select r;
                    ApparelMenu.DataBind();
                }
                else
                {
                    ApparelMenu.DataSource = null;
                    ApparelMenu.Visible    = false;
                    liMenuApparelAndAccessories.Visible = false;
                }
            }
        }
        private bool CanBuy_eLearningRule(MyHLShoppingCart hlCart)
        {
            bool   retVal       = true;
            var    session      = SessionInfo.GetSessionInfo(hlCart.DistributorID, hlCart.Locale);
            string trainingCode = HLConfigManager.Configurations.ShoppingCartConfiguration.TrainingCode;

            if (session.DsTrainings == null)
            {
                session.DsTrainings = DistributorOrderingProfileProvider.GetTrainingList(hlCart.DistributorID, hlCart.CountryCode);
            }

            if (session.DsTrainings != null && session.DsTrainings.Count > 0 && session.DsTrainings.Exists(t => t.TrainingCode == trainingCode && !t.TrainingFlag))
            {
                var     currentLimits       = PurchasingLimitProvider.GetCurrentPurchasingLimits(hlCart.DistributorID);
                decimal currentVolumePoints = hlCart.VolumeInCart;

                var currentItem = CatalogProvider.GetCatalogItem(hlCart.CurrentItems[0].SKU, Country);
                currentVolumePoints += currentItem.VolumePoints * hlCart.CurrentItems[0].Quantity;
                if (currentLimits.PurchaseLimitType == PurchaseLimitType.Volume)
                {
                    currentVolumePoints += (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume);
                }

                if (currentVolumePoints > HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV)
                {
                    retVal = false;
                }
            }


            return(retVal);
        }
Esempio n. 6
0
        public void PerformBackorderRules_Inventory_pt_BR()
        {
            var testSettings = new OrderingTestSettings("pt-BR", "webtest1");
            var target       = new Ordering.Rules.Inventory.pt_BR.InventoryRules();

            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                testSettings.Distributor, testSettings.Locale, "RSP", "BM", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetShoppingCartItem(1, 1, "0141")
            }, OrderCategoryType.RSO);
            CatalogItem item = CatalogProvider.GetCatalogItem("0141", "BR");
            int         PreviousItemsCount = cart.CartItems.Count();

            target.PerformBackorderRules(cart, item);
            int NowItemsCount = cart.CartItems.Count();

            if (!cart.RuleResults.Any())
            {
                Assert.AreEqual(PreviousItemsCount, NowItemsCount);
            }
            else if (cart.RuleResults.Any() && cart.RuleResults[0].Messages.Count > 0)
            {
                Assert.AreEqual(RulesResult.Failure, cart.RuleResults[0].Result);
            }
        }
        public static decimal TotalsExcludeAPF(MyHLShoppingCart cart, string countryCode)
        {
            if (APFDueProvider.IsAPFSkuPresent(cart.CartItems))
            {
                var calcTheseItems = new List <ShoppingCartItem_V01>();
                calcTheseItems.AddRange(from i in cart.CartItems
                                        where !APFDueProvider.IsAPFSku(i.SKU)
                                        select
                                        new ShoppingCartItem_V01(i.ID, i.SKU, i.Quantity, i.Updated,
                                                                 i.MinQuantity));

                // remove A and L type
                var allItems =
                    CatalogProvider.GetCatalogItems(
                        (from s in calcTheseItems where s.SKU != null select s.SKU).ToList(), countryCode);
                if (null != allItems && allItems.Count > 0)
                {
                    var skuExcluded = (from c in allItems.Values
                                       where (c as CatalogItem_V01).ProductType != ServiceProvider.CatalogSvc.ProductType.Product
                                       select c.SKU);
                    calcTheseItems.RemoveAll(s => skuExcluded.Contains(s.SKU));
                }

                var totals = cart.Calculate(calcTheseItems);
                return(totals != null ? (totals as OrderTotals_V01).AmountDue : decimal.Zero);
            }
            return(cart.Totals != null ? (cart.Totals as OrderTotals_V01).AmountDue : decimal.Zero);
        }
Esempio n. 8
0
        public static DistributorShoppingCartItem GetCatalogItems(int id, int qty, string sku, string countrylocal)
        {
            CatalogItem_V01 catalog = CatalogProvider.GetCatalogItem(sku, countrylocal.Substring(3));

            if (catalog == null)
            {
                return(new DistributorShoppingCartItem
                {
                    ID = id,
                    MinQuantity = 1,
                    PartialBackordered = false,
                    Quantity = qty,
                    SKU = sku,
                    Updated = DateTime.Now,
                });
            }
            else
            {
                return(new DistributorShoppingCartItem
                {
                    ID = id,
                    MinQuantity = 1,
                    PartialBackordered = false,
                    Quantity = qty,
                    SKU = sku,
                    Updated = DateTime.Now,
                    CatalogItem = catalog,
                    Description = catalog.Description
                });
            }
        }
        public InvoiceLineModel GetInvoiceLineFromSku(string sku, string locale, string countryCode, int quantity, bool isCustomer)
        {
            SKU_V01 skuItem;

            CatalogProvider.GetAllSKU(locale).TryGetValue(sku, out skuItem);
            if (null == skuItem || skuItem.CatalogItem.IsEventTicket == true)
            {
                return(null);
            }
            var retailPrice = isCustomer && (locale == "en-GB" || locale == "ko-KR")
                ? GetCustomerRetailPrice(skuItem.SKU, locale)
                : skuItem.CatalogItem.ListPrice;

            var invoiceLineModel = new InvoiceLineModel
            {
                Sku = skuItem.SKU,
                DisplayCurrencySymbol = HLConfigManager.Configurations.CheckoutConfiguration.CurrencySymbol,
                RetailPrice           = retailPrice,
                ProductCategory       = skuItem.CatalogItem.TaxCategory,
                ProductName           = string.Format("{0}{1}", skuItem.Product.DisplayName, skuItem.Description),
                ProductType           = skuItem.Product.TypeOfProduct.ToString(),
                StockingSku           = skuItem.CatalogItem.StockingSKU,
                EarnBase                = skuItem.CatalogItem.EarnBase,
                VolumePoint             = skuItem.CatalogItem.VolumePoints,
                Quantity                = quantity,
                TotalEarnBase           = quantity * skuItem.CatalogItem.EarnBase,
                TotalVolumePoint        = quantity * skuItem.CatalogItem.VolumePoints,
                TotalRetailPrice        = quantity * retailPrice,
                DisplayRetailPrice      = retailPrice.FormatPrice(),
                DisplayTotalRetailPrice = (quantity * retailPrice).FormatPrice(),
                DisplayTotalVp          = (quantity * skuItem.CatalogItem.VolumePoints).FormatPrice()
            };

            return(invoiceLineModel);
        }
        public ActionResult Departure(GuestWebParams param)
        {
            DepartureContext context;
            DateTime         date = ((param != null) && param.TestDate.HasValue) ? param.TestDate.Value.Date : DateTime.Now.Date;

            if (WebSecurity.IsAuthenticated)
            {
                context = new DepartureContext();
                List <GuestClaim> list = GuestProvider.GetActiveClaims(UrlLanguage.CurrentLanguage, WebSecurity.CurrentUserId, date);
                if ((list != null) && (list.Count > 0))
                {
                    context.Hotels = new List <DepartureHotel>();
                    foreach (GuestClaim claim in list)
                    {
                        int?hotel = null;
                        context.Hotels.AddRange(GuestProvider.GetDepartureInfo(UrlLanguage.CurrentLanguage, date, date.AddDays(1.0), hotel, new int?(claim.claim)));
                    }
                }
                return(base.View(context));
            }
            if (HttpPreferences.Current.LocationHotel != null)
            {
                context = new DepartureContext {
                    Hotel = CatalogProvider.GetHotelDescription(UrlLanguage.CurrentLanguage, HttpPreferences.Current.LocationHotel)
                };
                if (context.Hotel != null)
                {
                    context.Hotels = GuestProvider.GetDepartureInfo(UrlLanguage.CurrentLanguage, date, date.AddDays(1.0), new int?(context.Hotel.id), null);
                }
                return(base.View(context));
            }
            string str = base.Url.RouteUrl(base.Request.QueryStringAsRouteValues());

            return(base.RedirectToAction("login", "account", new { returnUrl = str }));
        }
        public ExcursionPriceList Price(int id, [FromUri] PriceParam param)
        {
            if (param == null)
            {
                throw new System.ArgumentNullException("param");
            }
            WebPartner partner = UserToolsProvider.GetPartner(param);

            if (!param.Date.HasValue)
            {
                throw new ArgumentNullExceptionWithCode(202, "date");
            }
            if (!param.StartPoint.HasValue && param.StartPointAlias != null)
            {
                param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
            }
            ExcursionPriceList result;

            if (param.Date.Value.Date < System.DateTime.Today)
            {
                result = new ExcursionPriceList(new System.Collections.Generic.List <ExcursionPrice>());
            }
            else
            {
                System.Collections.Generic.List <ExcursionPrice> prices = ExcursionProvider.GetPrice(param.Language, partner.id, id, param.Date.Value, param.StartPoint);
                result = new ExcursionPriceList((
                                                    from m in prices
                                                    where !m.issaleclosed && !m.isstopsale && m.price != null && !(m.totalseats >= 0 && !m.freeseats.HasValue)
                                                    select m).ToList <ExcursionPrice>());
            }

            return(result);
        }
Esempio n. 12
0
        public void PerformDiscountRules(ShoppingCart_V02 cart, Order_V01 order, string locale)
        {
            MyHLShoppingCart shoppingCart = cart as MyHLShoppingCart;
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            decimal CartVolume = 0.0M;

            foreach (ShoppingCartItem_V01 CartItem in shoppingCart.CartItems)
            {
                var item = CatalogProvider.GetCatalogItem(CartItem.SKU, shoppingCart.CountryCode);
                if (item != null)
                {
                    CartVolume += (item.VolumePoints) * CartItem.Quantity;
                }
            }

            List <string> codes = new List <string>(CountryType.VE.HmsCountryCodes);

            if (order != null && shoppingCart != null && CartVolume >= 500 &&
                member.Value.TypeCode != "SP" && codes.Contains(member.Value.ProcessingCountryCode))
            {
                order.UseSlidingScale    = false;
                order.DiscountPercentage = 42;
            }
        }
        private bool CheckInventory(string skuToCheck, int quantity)
        {
            int inventoryQty = 0;

            if (!string.IsNullOrEmpty(skuToCheck))
            {
                CatalogItem_V01 catItem = CatalogProvider.GetCatalogItem(skuToCheck, this.ProductsBase.CountryCode);
                if (catItem != null)
                {
                    WarehouseInventory warehouseInventory;
                    if (catItem.InventoryList != null && catItem.InventoryList.TryGetValue(ProductsBase.CurrentWarehouse, out warehouseInventory))
                    {
                        var warehouseInventory01 = warehouseInventory as WarehouseInventory_V01;
                        if (warehouseInventory01 != null && !warehouseInventory01.IsBlocked)
                        {
                            inventoryQty = ShoppingCartProvider.CheckInventory(catItem, quantity,
                                                                               this.ProductsBase.CurrentWarehouse);
                        }
                    }
                }
            }

            lblError.Text = inventoryQty > 0 ? string.Empty :
                            string.Format(MyHL_ErrorMessage.OutOfInventory, skuToCheck);

            return(inventoryQty > 0);
        }
Esempio n. 14
0
        public async Task <BackOrderDetailsViewModel> GetInventoryDetails()
        {
            var locale = CultureInfo.CurrentUICulture.Name;

            var details = await CatalogProvider.GetBackOrderDetailsFullWh(locale);

            return(details);
        }
Esempio n. 15
0
        private void UpdateItemList()
        {
            var provider = new CatalogProvider();

            var items = provider.GetItems(SelectedTypeId, SelectedBrandId, Query);

            Items = new ObservableCollection <CatalogItemModel>(items);
        }
        private void displayLocaleSpecificRadioButtons()
        {
            string primarySku   = HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku;
            string secondarySku = HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku;

            MyHLShoppingCart cart = (ProductsBase).ShoppingCart;

            //checks if primary sku is present in the catalog.
            CatalogItem_V01 catItem = CatalogProvider.GetCatalogItem(primarySku,
                                                                     (this.Page as ProductsBase).CountryCode);

            if (catItem != null && !IsBlocked(catItem))
            {
                this.divTodaysMagazine.Visible = true;
                displayTodaysMagazine(true);
                //SetlocaleDescription(Locale.Substring(3));
                //this.rbSecondaryLanguage.Visible = false;
            }
            else //Primary sku not present, do not display both primary and secondary.
            {
                this.rbPrimaryLanguage.Visible   = false;
                this.rbSecondaryLanguage.Visible = false;
                this.divTodaysMagazine.Visible   = false;
                this.divTodaysMagazine.Style.Add(System.Web.UI.HtmlTextWriterStyle.Display, "none");
                displayTodaysMagazine(false);
                return;
            }

            //if secondary sku is not present, then do not show the radio buttons.
            if (secondarySku.Equals(string.Empty))
            {
                this.rbPrimaryLanguage.Visible   = false;
                this.rbSecondaryLanguage.Visible = false;
                return;
            }

            //if primary sku is present, check for secondary sku in the catalog.
            CatalogItem_V01 catSecItem = CatalogProvider.GetCatalogItem(secondarySku, (this.Page as ProductsBase).CountryCode);

            if (catSecItem != null && !IsBlocked(catSecItem))
            {
                //SetlocaleDescription(Locale.Substring(3));
                this.rbSecondaryLanguage.Visible = true;
            }
            else
            {
                this.rbPrimaryLanguage.Visible       =
                    this.rbSecondaryLanguage.Visible = false;
            }

            //Set the default selection to primary...
            if ((this.rbPrimaryLanguage != null) && (this.rbSecondaryLanguage != null))
            {
                this.rbPrimaryLanguage.Checked   = true;
                this.rbSecondaryLanguage.Checked = false;
            }
        }
Esempio n. 17
0
        private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                                    ShoppingCartRuleReason reason,
                                                    ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                var SKUIds = new List <string[]>();
                SKUIds.Add(new[] { HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku, "3" });
                SKUIds.Add(new[] { "4150", "10" });

                if (cart.CurrentItems[0].SKU == HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku)
                {
                    var catItems = CatalogProvider.GetCatalogItems((from c in cart.CartItems
                                                                    select c.SKU.Trim()).ToList <string>(),
                                                                   Country);
                    if (catItems != null)
                    {
                        if (!catItems.Any(c => c.Value.ProductType == ProductType.Product))
                        {
                            Result.Result = RulesResult.Failure;
                            Result.AddMessage(
                                string.Format(
                                    HttpContext.GetGlobalResourceObject(
                                        string.Format("{0}_Rules", HLConfigManager.Platform), "AddProductFirst")
                                    .ToString(), cart.CurrentItems[0].SKU));
                            cart.RuleResults.Add(Result);
                            return(Result);
                        }
                    }
                }

                foreach (string[] sku in SKUIds)
                {
                    int quantity = 0;
                    if (cart.CurrentItems[0].SKU == sku[0])
                    {
                        quantity += cart.CurrentItems[0].Quantity;
                        if (cart.CartItems.Exists(item => item.SKU == sku[0]))
                        {
                            quantity += cart.CartItems.Where(item => item.SKU == sku[0]).First().Quantity;
                        }
                        if (quantity > Convert.ToInt32(sku[1]))
                        {
                            Result.Result = RulesResult.Failure;
                            Result.AddMessage(
                                string.Format(
                                    HttpContext.GetGlobalResourceObject(
                                        string.Format("{0}_Rules", HLConfigManager.Platform), "SKUQuantityExceeds")
                                    .ToString(), sku[1], sku[0]));
                            cart.RuleResults.Add(Result);
                        }
                    }
                }
            }
            return(Result);
        }
        private List <InvoiceCategoryModel> GetCategoriesFromSource(int rootCategoryId, string locale, bool isCustomer)
        {
            var productInfo = CatalogProvider.GetProductInfoCatalog(locale);
            var categories  = productInfo.RootCategories.Where(c => c.ID == rootCategoryId);
            var category    = categories.Any() ? categories.First() : null;
            var prodList    = new List <CategoryProductModel>();

            prodList = GetAllProducts(category, category, prodList);
            return(ConvertToInvoiceCategoryModel(prodList, rootCategoryId, locale, isCustomer));
        }
Esempio n. 19
0
            private static decimal GetRetailPrice(string sku, int quantity, decimal unitPrice)
            {
                var SkuPrice = CatalogProvider.GetCatalogItem(sku, "CN");

                if (SkuPrice != null)
                {
                    return(SkuPrice.ListPrice * quantity);
                }

                return(unitPrice);
            }
 public CategoryGroupWithCategoriesList CategoriesByGroup([FromUri] CategoryParam param)
 {
     if (param == null)
     {
         throw new ArgumentNullException("param");
     }
     if (!(param.StartPoint.HasValue || (param.StartPointAlias == null)))
     {
         param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
     }
     return(new CategoryGroupWithCategoriesList(ExcursionProvider.GetCategoriesByGroup(param.Language, param.StartPoint)));
 }
 public GeoCatalogObjectList GeoPoints([FromUri] GeoCatalogParam param)
 {
     if (param == null)
     {
         throw new ArgumentNullException("param");
     }
     if (string.IsNullOrEmpty(param.SearchText))
     {
         throw new ArgumentNullExceptionWithCode(0x65, "s");
     }
     return(new GeoCatalogObjectList(CatalogProvider.GetGeoPoints(param.Language, param.SearchText)));
 }
 public GeoCatalogObject GeoPointByAlias([FromUri] GeoPointByAliasParam param)
 {
     if (param == null)
     {
         throw new ArgumentNullException("param");
     }
     if (string.IsNullOrEmpty(param.GeoPointAlias))
     {
         throw new ArgumentNullExceptionWithCode(0x6a, "gpa");
     }
     return(CatalogProvider.GetGeoPointByAlias(param.Language, param.GeoPointAlias));
 }
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            setupClientSideEventForQuantityAndSku();

            CheckoutButton1.Text     = CheckoutButton1Disabled.Text = CheckoutButton2Disabled.Text =
                CheckoutButton2.Text = GetLocalResourceObject("CheckoutButtonResource1.Text") as string;

            //HLRulesManager.Manager.ProcessCatalogItemsForInventory(this.Locale, ShoppingCart);
            // this is to trigger qty/avail check.
            CatalogProvider.GetProductInfoCatalog(Locale, CurrentWarehouse);
            if (!IsPostBack)
            {
                string title = GetLocalResourceObject("PageResource1.Title") as string;
                TopTab.Text = title;
                (this.Master as OrderingMaster).SetPageHeader(title);
                if (ShoppingCart != null && ShoppingCart.CartItems != null && ShoppingCart.CartItems.Count > 0)
                {
                    findCrossSell(ShoppingCart.CartItems);
                }
                else
                {
                    NoCrossSellFound(this, null);
                }
                DisplayAPFMessage();
                //User Story 391426:- start
                GetTWSKUQuantitytorestrict();
            }
            else
            {
                CheckoutButton1.Enabled = true;
                CheckoutButton2.Enabled = true;
            }

            if (ShoppingCart != null && ShoppingCart.OrderCategory == OrderCategoryType.ETO)
            {
                this.Page.Title = GetLocalResourceObject("EventTickets.Title") as string;
                (this.Master as OrderingMaster).SetPageHeader(GetLocalResourceObject("EventTickets.Title") as string);
            }

            // Set static product list.
            if (this.AllSKUS.Any())
            {
                Products = this.AllSKUS.Where(sku => sku.Value.ProductAvailability == ProductAvailabilityType.Available).Select(
                    sku => string.Concat(sku.Key, " ", sku.Value.Product.DisplayName, " ", sku.Value.Description));
            }
            if (!IsPostBack)
            {
                if (IsChina)
                {
                    divChinaPCMessageBox.Visible = SessionInfo.IsReplacedPcOrder;
                }
            }
        }
Esempio n. 24
0
        private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                                    ShoppingCartRuleReason reason,
                                                    ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                List <string> codes = new List <string>(CountryType.KZ.HmsCountryCodes);
                codes.Add(CountryType.KZ.Key);
                bool isCOPKZ = codes.Contains(DistributorProfileModel.ProcessingCountryCode);
                if (!isCOPKZ)
                {
                    return(Result);
                }

                if (!HasActiveAppTinCode(cart.DistributorID))
                {
                    try
                    {
                        var cartVolume  = 0m;
                        var currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country);
                        var myCart      = cart as MyHLShoppingCart;
                        if (myCart != null && !string.IsNullOrEmpty(myCart.VolumeInCart.ToString()))
                        {
                            cartVolume = myCart.VolumeInCart;
                        }
                        var newVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity;

                        if (cartVolume + newVolumePoints > MaxVolPoints)
                        {
                            Result.AddMessage(
                                string.Format(
                                    HttpContext.GetGlobalResourceObject(
                                        string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceeds")
                                    .ToString(), cart.CurrentItems[0].SKU));
                            Result.Result = RulesResult.Failure;
                            cart.RuleResults.Add(Result);
                            return(Result);
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error(
                            string.Format(
                                "Error while performing Add to Cart Rule for Belarus distributor: {0}, Cart Id:{1}, \r\n{2}",
                                cart.DistributorID, cart.ShoppingCartID, ex.ToString()));
                    }
                }
            }


            return(Result);
        }
Esempio n. 25
0
        private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                CatalogItem_V01 currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country);

                try
                {
                    List <string> codes = new List <string>(CountryType.TH.HmsCountryCodes);
                    codes.Add(CountryType.TH.Key);
                    bool isCOPThai        = codes.Contains(DistributorProfileModel.ProcessingCountryCode);
                    TaxIdentification tid = null;

                    var tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true);
                    tid = tins.Find(t => t.IDType.Key == "THID");
                    //Simulate the dummy tin with an foreign DS
                    //TaxIdentification ti = new TaxIdentification() { CountryCode = "TH", ID = "dummy", IDType = new TaxIdentificationType(dummyTin) };
                    //ods.Value.TinList.Add(ti);

                    if (CanPurchase(cart.DistributorID, Country))
                    {
                        //Additional Check to allow DS COP = Thai Tin = No TIN, Can place only L and A items
                        if (IsWithOutTinCode)
                        {
                            if (currentItem.ProductType == ProductType.Product)
                            {
                                Result.Result = RulesResult.Failure;
                                Result.AddMessage(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase").ToString());
                                cart.RuleResults.Add(Result);
                            }
                        }
                    }
                    else
                    {
                        if (IsWithOutTinCode)
                        {
                            if (currentItem.ProductType == ProductType.Product)
                            {
                                Result.Result = RulesResult.Failure;
                                Result.AddMessage(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase").ToString());
                                cart.RuleResults.Add(Result);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.Error(string.Format("Error while performing Add to Cart Rule for Singapore distributor: {0}, Cart Id:{1}, \r\n{2}", cart.DistributorID, cart.ShoppingCartID, ex.ToString()));
                }
            }
            return(Result);
        }
Esempio n. 26
0
        private bool IsElegibleForPromo(ShoppingCart_V02 cart, MyHLShoppingCart hlCart, out decimal volume)
        {
            var isElegible = false;

            volume = 0;

            LoggerHelper.Info(
                string.Format("CheckPromoInCart.ShoppingCart V02 items {0}",
                              string.Concat(cart.CartItems.Select(i => string.Format("{0},", i.SKU)))));
            LoggerHelper.Info(
                string.Format("CheckPromoInCart.MyHLShoppingCart items {0}",
                              string.Concat(hlCart.CartItems.Select(i => string.Format("{0},", i.SKU)))));
            LoggerHelper.Info(
                string.Format("AllowedSKUToAddPromoSKU {0}",
                              string.Concat(AllowedSKUToAddPromoSKU.Select(i => string.Format("{0},", i)))));

            var cartItemsV02 = (from a in AllowedSKUToAddPromoSKU
                                join b in cart.CartItems on a equals b.SKU
                                select
                                new
            {
                Sku = b.SKU,
                Qty = b.Quantity,
                Volume = CatalogProvider.GetCatalogItem(b.SKU, "IT").VolumePoints
            }).ToList();

            if (cartItemsV02.Any())
            {
                isElegible = true;
                volume     = cartItemsV02.Sum(oi => oi.Qty * oi.Volume);
            }
            else
            {
                var shoppingcartItemsV02 = (from a in AllowedSKUToAddPromoSKU
                                            join b in hlCart.ShoppingCartItems on a equals b.SKU
                                            select
                                            new { Sku = b.SKU, Qty = b.Quantity, Volume = b.CatalogItem.VolumePoints })
                                           .ToList();

                if (shoppingcartItemsV02.Any())
                {
                    isElegible = true;
                    volume     = shoppingcartItemsV02.Sum(oi => oi.Qty * oi.Volume);
                }
                else
                {
                    LoggerHelper.Info("No Items in Cart or MyHLCart. Rule fails");
                }
            }

            return(isElegible);
        }
        protected override async Task <ActivationState> HandleInternalAsync(ToastNotificationActivatedEventArgs args)
        {
            if (Int32.TryParse(args.Argument, out int id))
            {
                var provider = new CatalogProvider();
                var item     = await provider.GetItemByIdAsync(id);

                if (item != null)
                {
                    return(new ActivationState(typeof(ItemDetailViewModel), new ItemDetailState(item)));
                }
            }
            return(new ActivationState(typeof(CatalogViewModel), new CatalogState()));
        }
        private IEnumerable <InvoiceLineModel> InvoiceModelListforAutocomplete(string locale, string countryCode, bool isCustomer)
        {
            var productinfocatalog = CatalogProvider.GetProductInfoCatalog(locale);
            var result             = new List <InvoiceLineModel>();

            foreach (var category in productinfocatalog.RootCategories.Where(cat => null != cat))
            {
                result.AddRange(GetInvoiceLinesFromCategory(category, locale, countryCode, isCustomer));
            }
            var distinctList =
                result.Where(s => s != null && s.Sku != null).GroupBy(p => p.Sku).Select(g => g.First()).ToList();

            return(distinctList);
        }
        public FilterDetailsResult FilterDetails([FromUri] FiltersParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            WebPartner partner = UserToolsProvider.GetPartner(param);

            if (!(param.StartPoint.HasValue || (param.StartPointAlias == null)))
            {
                param.sp = new int?(CatalogProvider.GetGeoPointIdByAlias(param.StartPointAlias));
            }
            return(GetCachedFilterDetails(param, partner));
        }
        private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                                    ShoppingCartRuleReason reason,
                                                    ShoppingCartRuleResult Result)
        {
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
            {
                bool bEventTicket = isEventTicket(cart.DistributorID, Locale);
                var  thisCart     = cart as MyHLShoppingCart;
                if (null != thisCart)
                {
                    //Kiosk items must have inventory
                    string             sku                = thisCart.CurrentItems[0].SKU;
                    var                catItem            = CatalogProvider.GetCatalogItem(sku, Country);
                    WarehouseInventory warehouseInventory = null;

                    var isSplitted = false;

                    if (thisCart.DeliveryInfo != null && thisCart.DeliveryInfo.Option == ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping &&
                        HLConfigManager.Configurations.DOConfiguration.WhCodesForSplit.Contains(thisCart.DeliveryInfo.WarehouseCode))
                    {
                        //split order scenario
                        ShoppingCartProvider.CheckInventory(catItem, thisCart.CurrentItems[0].Quantity, thisCart.DeliveryInfo.WarehouseCode, thisCart.DeliveryInfo.FreightCode, ref isSplitted);
                    }


                    if (!isSplitted && null != thisCart.DeliveryInfo && !string.IsNullOrEmpty(thisCart.DeliveryInfo.WarehouseCode) && !bEventTicket && !isNonInventoryItem(sku))
                    {
                        catItem.InventoryList.TryGetValue(thisCart.DeliveryInfo.WarehouseCode, out warehouseInventory);
                        if ((warehouseInventory != null && (warehouseInventory as WarehouseInventory_V01).QuantityAvailable <= 0) || warehouseInventory == null)
                        {
                            Result.AddMessage(string.Format(HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "BackOrderItem").ToString(), sku));
                            Result.Result = RulesResult.Failure;
                            cart.RuleResults.Add(Result);
                        }
                        else
                        {
                            int availQuantity = InventoryHelper.CheckInventory(thisCart, thisCart.CurrentItems[0].Quantity, catItem, thisCart.DeliveryInfo.WarehouseCode);
                            if (availQuantity - thisCart.CurrentItems[0].Quantity < 0)
                            {
                                Result.AddMessage(string.Format(HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "OutOfInventory").ToString(), sku));
                                Result.Result = RulesResult.Failure;
                                cart.RuleResults.Add(Result);
                            }
                        }
                    }
                }
            }

            return(Result);
        }