private bool SetFreightCodesForIBPOrders(MyHLShoppingCart thisCart) { bool isIbp = false; if (string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.IBPSku)) { return(isIbp); } var ibpSkus = HLConfigManager.Configurations.DOConfiguration.IBPSku.Split(',').ToList(); string oldFreightCode = thisCart.DeliveryInfo.FreightCode; if (thisCart.CartItems.Any() && thisCart.Totals != null) { if (thisCart.CartItems.Any(i => ibpSkus.Contains(i.SKU))) { isIbp = true; var state = (thisCart.DeliveryInfo.Address.Address.StateProvinceTerritory ?? string.Empty).Trim(); var city = (thisCart.DeliveryInfo.Address.Address.City ?? string.Empty).Trim(); // Check if it's a major city if (IsMajorCity(state, city)) { thisCart.DeliveryInfo.FreightCode = "FSL"; } else { thisCart.DeliveryInfo.FreightCode = "IND"; } //check IBP with APF (User Story 164536) var apfSkus = APFDueProvider.GetAPFSkuList(); var thisSkus = thisCart.CartItems.Select(x => x.SKU).ToList(); thisSkus = thisSkus.Except(apfSkus).ToList(); var nonHAP = thisSkus.Except(ibpSkus).ToList(); if (thisCart.CartItems.Any(i => apfSkus.Contains(i.SKU))) { thisCart.DeliveryInfo.FreightCode = "NOF"; } } } if (thisCart.DeliveryInfo.FreightCode != oldFreightCode) { ShoppingCartProvider.UpdateShoppingCart(thisCart); // save to database } return(isIbp); }
public void APFExempt_distributor_notQualified_wfDecimal() { distributor.DistributorVolumes[0].Volume = Decimal.Parse("199.99"); bool result; decimal volume = 0; result = APFDueProvider.IsAPFExemptOn200VP(distributor, volume); Assert.IsFalse(result); PrivateObject apf = new PrivateObject(typeof(APFRules)); result = Convert.ToBoolean(apf.Invoke("IsAPFExempt", distributor, volume)); Assert.IsFalse(result); }
private void ResolveAPF(MyHLShoppingCart cart) { if (APFDueProvider.IsAPFSkuPresent(cart.CartItems)) { int payedApf = APFDueProvider.APFQuantityInCart(cart); var currentDueDate = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, cart.CountryCode).ApfDueDate; var newDueDate = currentDueDate + new TimeSpan(payedApf * 365, 0, 0, 0); DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, cart.CountryCode).ApfDueDate = newDueDate; //TODO : what to do //DistributorProvider.UpdateDistributor(ods); Session.Add("apfdue", newDueDate); APFDueProvider.UpdateAPFDuePaid(cart.DistributorID, newDueDate); } }
private bool CheckIfOnlyAPF() { if (APFDueProvider.containsOnlyAPFSku(ProductsBase.ShoppingCart.CartItems)) { this.divTodaysMagazine.Visible = false; displayTodaysMagazine(false); return(true); } else { this.divTodaysMagazine.Visible = true; displayTodaysMagazine(true); return(false); } }
private ShoppingCartRuleResult CartItemAddedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result, string level) { var distributorId = cart.DistributorID; var isAPFDueandNotPaid = APFDueProvider.IsAPFDueAndNotPaid(distributorId, Locale); if (isAPFDueandNotPaid && HLConfigManager.Configurations.DOConfiguration.IsChina) { string cacheKey = string.Empty; bool reloadAPFs = (null != cart && null != cart.CartItems) && isAPFDueandNotPaid && !APFDueProvider.IsAPFSkuPresent(cart.CartItems); cart.APFEdited = false; DoApfDue(cart.DistributorID, cart, cacheKey, Locale, reloadAPFs, result, true); } try { var hlCart = cart as MyHLShoppingCart; if (null != hlCart) { var isPlacing = !String.IsNullOrWhiteSpace(hlCart.SrPlacingForPcOriginalMemberId); if (isPlacing) { var skuList = APFDueProvider.GetAPFSkuList(); if (skuList != null && skuList.Count > 0) { var items = (from s in skuList from c in cart.CartItems where s == c.SKU select c.SKU).ToList(); if (null != items && items.Count > 0) { hlCart.DeleteItemsFromCart(items, true); } } } } } catch (Exception ex) { LoggerHelper.Error( string.Format("APFRules.CartItemAddedRuleHandler DS:{0} locale:{2} ERR:{1}", cart.DistributorID, ex, Locale)); } return(result); }
public void ListnerMethod() { if (ShoppingCart.ShoppingCartItems != null & ShoppingCart.ShoppingCartItems.Count > 0) { this.OvalSaveCartButton.Visible = true; this.OvalSaveCartButton.Enabled = !(APFDueProvider.containsOnlyAPFSku(ShoppingCart.ShoppingCartItems) && HLConfigManager.Configurations.APFConfiguration.StandaloneAPFOnlyAllowed); this.OvalSaveCartButton.Disabled = !this.OvalSaveCartButton.Enabled; } else { this.OvalSaveCartButton.Visible = false; } btnCancel.Visible = this.ShoppingCart.IsSavedCart; }
public void APFExempt_distributor_Qualified_Wf_Additional_Volume() { bool result; decimal volume = 50; distributor.DistributorVolumes[0].Volume = 150; result = APFDueProvider.IsAPFExemptOn200VP(distributor, volume); Assert.IsTrue(result); PrivateObject apf = new PrivateObject(typeof(APFRules)); result = Convert.ToBoolean(apf.Invoke("IsAPFExempt", distributor, volume)); Assert.IsTrue(result); }
protected void CartItemListView_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { var prodDesc = (LinkButton)e.Item.FindControl("LinkProductDetail"); var hdnSKU = (HiddenField)e.Item.FindControl("hdnSKU"); var nonLinkedSkus = APFDueProvider.GetAPFSkuList(); if (!String.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku)) { nonLinkedSkus.Add(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku); } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku)) { nonLinkedSkus.Add(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku); } if (!String.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku)) { nonLinkedSkus.Add(HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku); } if (prodDesc != null && hdnSKU != null) { if (nonLinkedSkus.Contains(hdnSKU.Value)) { prodDesc.OnClientClick = "return false;"; prodDesc.CommandArgument = "disable"; prodDesc.CssClass = "disable-link"; } if (IsChina) { //Extra checking to ensure the command argument being updated properly for the item without product info. if (string.IsNullOrEmpty(prodDesc.CommandArgument) || prodDesc.CommandArgument.Trim() == string.Empty) { prodDesc.OnClientClick = "return false;"; prodDesc.CommandArgument = "disable"; prodDesc.CssClass = "disable-link"; } } if (ProductsBase.GlobalContext.CultureConfiguration.IsBifurcationEnabled && SessionInfo.DsType == ServiceProvider.DistributorSvc.Scheme.Member && SessionInfo.IsHAPMode == true) { prodDesc.OnClientClick = "return false;"; prodDesc.CommandArgument = "disable"; prodDesc.CssClass = "disable-link"; } } } }
public void APFExempt_distributor_null() { distributor = null; decimal volume = 0; bool result; result = APFDueProvider.IsAPFExemptOn200VP(distributor, 0); Assert.IsFalse(result); PrivateObject apf = new PrivateObject(typeof(APFRules)); object[] args = new object[2] { distributor, volume }; result = Convert.ToBoolean(apf.Invoke("IsAPFExempt", distributor, volume)); Assert.IsFalse(result); }
/// <summary> /// Saves the cart. /// </summary> /// <param name="cartName">Cart name.</param> /// <param name="update">Flag to update the same saved cart</param> private void SaveCart(string cartName, bool update) { if (!update) { if (HLConfigManager.Configurations.DOConfiguration.IsChina) { ShoppingCart.removeItem(APFDueProvider.GetAPFSku()); } var optionType = (ServiceProvider.CatalogSvc.DeliveryOptionType)Enum.Parse(typeof(ServiceProvider.CatalogSvc.DeliveryOptionType), ProductsBase.OptionType.ToString()); this.ShoppingCart.CopyCartWithShippingInfo(true, cartName, ProductsBase.ShippingAddresssID, ProductsBase.DeliveryOptionID, optionType); } this.lblSavedCartMessage1.Text = string.Format( GetLocalResourceObject("lblSavedCartMessage1.Text") as string, cartName); this.updSavedCart.Update(); this.ShowContinuePopup(); }
private ShoppingCartRuleResult CheckHonors2016Warehouse(ShoppingCart_V01 shoppingCart, ShoppingCartRuleResult ruleResult) { var cart = shoppingCart as MyHLShoppingCart; if (cart != null && cart.OrderCategory == OrderCategoryType.RSO && cart.DeliveryInfo != null) { var honors2016Skus = GetHonors2016Skus(); if (cart.DeliveryInfo.Option == DeliveryOptionType.Pickup && cart.DeliveryInfo.WarehouseCode == HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse) { // Remove items from other categories var itemsToRemove = (from item in shoppingCart.CartItems where !honors2016Skus.Contains(item.SKU) select item).ToList(); if (!itemsToRemove.Any()) { return(ruleResult); } //Do not remove APF SKU if exists in the cart var apfSku = APFDueProvider.GetAPFSku(); itemsToRemove.RemoveAll(a => a.SKU.Equals(apfSku)); if (itemsToRemove.Any()) { var notValidSkus = itemsToRemove.Select(s => s.SKU).ToList(); cart.DeleteItemsFromCart(notValidSkus, true); ruleResult.Result = RulesResult.Success; } } else if (cart.DeliveryInfo.Option != DeliveryOptionType.Pickup || cart.DeliveryInfo.WarehouseCode != HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse) { // Remove Honors 2016 items var itemsToRemove = (from item in shoppingCart.CartItems where honors2016Skus.Contains(item.SKU) select item).ToList(); if (itemsToRemove.Any()) { var notValidSkus = itemsToRemove.Select(s => s.SKU).ToList(); cart.DeleteItemsFromCart(notValidSkus, true); ruleResult.Result = RulesResult.Success; } } } return(ruleResult); }
private void retrieveFreightCode(MyHLShoppingCart shoppingCart, MyHerbalife3.Ordering.ServiceProvider.ShoppingCartSvc.ShippingInfo_V01 address) { // to correct prod issue where wrong freight code is set if (shoppingCart != null && shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Address != null && shoppingCart.DeliveryInfo.Address.Address != null && (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping || shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup) && shoppingCart.OrderCategory == MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.OrderCategoryType.RSO && shoppingCart.DeliveryInfo.FreightCode == "NOF") { // Let the ETO and APF preserve the freight SessionInfo sessionInfo = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); var isAPF = APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale); if (!sessionInfo.IsEventTicketMode && !isAPF) { if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping) { List <DeliveryOption> deliveryOptions = GetDeliveryOptions(DeliveryOptionType.Shipping, shoppingCart.DeliveryInfo.Address); if (deliveryOptions != null) { DeliveryOption op = deliveryOptions.Find( d => d.WarehouseCode == shoppingCart.DeliveryInfo.WarehouseCode && d.State.Equals(shoppingCart.DeliveryInfo.Address.Address.StateProvinceTerritory)); if (op != null) { shoppingCart.DeliveryInfo.FreightCode = op.FreightCode; } } } else if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup) { var pickupLocation = GetShippingInfoFromID(shoppingCart.DistributorID, shoppingCart.Locale, DeliveryOptionType.Pickup, shoppingCart.DeliveryInfo.Id, shoppingCart.DeliveryInfo.Address.ID); if (pickupLocation != null) { shoppingCart.DeliveryInfo.FreightCode = pickupLocation.FreightCode; shoppingCart.DeliveryInfo.WarehouseCode = pickupLocation.WarehouseCode; } } } } }
public override void GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, ServiceProvider.OrderSvc.ShippingInfo_V01 address) { if (shoppingCart != null) { if (APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { address.WarehouseCode = HLConfigManager.Configurations.APFConfiguration.APFwarehouse; address.ShippingMethodID = HLConfigManager.Configurations.APFConfiguration.APFFreightCode; } else { shoppingCart.CheckShippingForNonStandAloneAPF(); SessionInfo sessionInfo = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); if (sessionInfo.IsEventTicketMode && shoppingCart.DeliveryInfo != null) { shoppingCart.DeliveryInfo.WarehouseCode = HLConfigManager.Configurations.CheckoutConfiguration.EventTicketWarehouseCode; shoppingCart.DeliveryInfo.FreightCode = HLConfigManager.Configurations.CheckoutConfiguration.EventTicketFreightCode; // Take address from DB var deliveryOptions = base.GetDeliveryOptions(shoppingCart.Locale); var addressETO = deliveryOptions.Find(d => d.Option == ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping && d.OrderCategory == ServiceProvider.ShippingSvc.OrderCategoryType.ETO); if (addressETO != null) { shoppingCart.DeliveryInfo.Address.Address = addressETO.Address; } // Set MB's Name in the Recipient name var loader = new Core.DistributorProvider.DistributorLoader(); var distributor = loader.Load(shoppingCart.DistributorID, shoppingCart.CountryCode); if (distributor != null && distributor.EnglishName != null) { shoppingCart.DeliveryInfo.Address.Recipient = string.Format("{0} {1}{2}", distributor.EnglishName.First, !string.IsNullOrEmpty(distributor.EnglishName.Middle) ? distributor.EnglishName.Middle + " " : string.Empty, distributor.EnglishName.Last); } } } } }
private void CheckingFreightCode(MyHLShoppingCart shoppingCart) { // To prevent prod issue where wrong freight code is set (NOF) if (shoppingCart != null && shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Address != null && shoppingCart.DeliveryInfo.Address.Address != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping && shoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.RSO && shoppingCart.DeliveryInfo.FreightCode == "NOF") { var sessionInfo = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); var isAPF = APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale); // If order is standalone APF or ETO we leave the freight if (!sessionInfo.IsEventTicketMode && !isAPF) { var freightAndWarehouse = GetFreightCodeAndWarehouse(shoppingCart.DeliveryInfo.Address); shoppingCart.DeliveryInfo.FreightCode = freightAndWarehouse[0]; } } }
public void GracePeriodAPFDisplay() { _apfSku = APFDueProvider.GetAPFSku(); List <ShoppingCartItem_V01> item = (from c in _cart.CartItems where c.SKU == _apfSku select c).ToList(); _APFExempted = APFDueProvider.IsAPFExemptOn200VP(DistributorOrderingProfile, _cart.VolumeInCart); if (_APFStatus != 2) { return; } if (_APFExempted) { pnlAPFPaid.Visible = false; } if (item.Count >= 1) { ShowApfAddedMessage(); } else { var apfSku = new List <ShoppingCartItem_V01>(); if (!_APFExempted) { if (_quantityToAdd < 1) { _quantityToAdd = 1; } apfSku.Add(new ShoppingCartItem_V01(0, APFDueProvider.GetAPFSku(), _quantityToAdd, DateTime.Now)); _cart.AddItemsToCart(apfSku); } item = (from c in _cart.CartItems where c.SKU == _apfSku select c).ToList(); if (item.Count >= 1) { ShowApfAddedMessage(); } } }
private bool checkPerOrderLimit(MyHLShoppingCart cart, List <ShoppingCartItem_V01> previousItems, ShoppingCartRuleResult Result, string sku, int qty) { decimal MaxAmount = 999.99m; 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)); calcTheseItems.AddRange(previousItems); var existingItem = calcTheseItems.Find(ci => ci.SKU == sku); if (null != existingItem) { existingItem.Quantity += qty; } else { calcTheseItems.Add(new ShoppingCartItem_V01(0, sku, qty, DateTime.Now)); } var Totals = cart.Calculate(calcTheseItems, false) as OrderTotals_V01; if (Totals != null && Totals.AmountDue > MaxAmount) { var globalResourceObject = HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "AmountLimitExceeds"); if (globalResourceObject != null) { Result.AddMessage( string.Format( globalResourceObject .ToString(), MaxAmount.ToString())); } Result.Result = RulesResult.Failure; return(false); } return(true); }
private void ShowAddApf() { pnlAPFIsDueWithinYear.Visible = true; SetPanelsVisibility(); pnlAPFPaid.Visible = false; // Removing the condition, in order to get the lblAPFMessage text even if the _apfIsDue field is true. // Defect 42710. //if (!_apfIsDue) //{ string dueDateFormat = HLConfigManager.Configurations.APFConfiguration.DueDateDisplayFormat; lblAPFMessage.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "APFDueDateNotification"), _apfDueDate.ToString(dueDateFormat, Thread.CurrentThread.CurrentCulture)); //} if (_apfDueGreaterThanOneYear) { tblEditable.Style.Add(HtmlTextWriterStyle.Display, "none"); } else { tblEditable.Style.Remove(HtmlTextWriterStyle.Display); } lblAPFType.Text = GetLocalResourceObject("APFSKU_" + _apfSku) as string; CatalogItem item = CatalogProvider.GetCatalogItem(_apfSku, CountryCode); if (null != item) { lblAPFAmount.Text = string.Concat(HLConfigManager.Configurations.CheckoutConfiguration.CurrencySymbol, " ", item.ListPrice); } int numApfs = (_apfIsDue) ? (_apfsDue - _apfsInCart) : 1; txtQuantity.Text = numApfs.ToString(); txtQuantity.ReadOnly = numApfs == 1 || !APFDueProvider.CanRemoveAPF(_distributorId, Locale, _level); if (_apfIsDue && _level == "SP") { txtQuantity.ReadOnly = true; } btnAddToCart.Visible = true; }
public override void GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, MyHerbalife3.Ordering.ServiceProvider.OrderSvc.ShippingInfo_V01 address) { DeliveryOption deliveryOptionForAddress = null; if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping) { var currentAddress = shoppingCart.DeliveryInfo.Address; var stateCode = this.GetStateCodeGivenStateName(currentAddress.Address.StateProvinceTerritory.Trim()); var srchCity = currentAddress.Address.City.Trim().ToLower(); if (currentAddress != null) { //1)get cart total & compare with CAP var listDeliveryOptions = base.GetDeliveryOptions( DeliveryOptionType.Shipping, currentAddress as ShippingAddress_V02); var availableOptions = listDeliveryOptions.FindAll(p => p.State.ToLower().Trim() == stateCode.ToLower().Trim()); if (availableOptions.Count > 0) { var optionForMajorCity = availableOptions.FirstOrDefault( i => !string.IsNullOrEmpty(i.Address.City) && i.Address.City.Trim().ToLower() == srchCity.Trim().ToLower()); deliveryOptionForAddress = optionForMajorCity ?? availableOptions.FindAll(p => p.Address.City == null).FirstOrDefault(); if (deliveryOptionForAddress != null) { if (APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { address.WarehouseCode = HLConfigManager.Configurations.APFConfiguration.APFwarehouse; } else { shoppingCart.DeliveryInfo.WarehouseCode = deliveryOptionForAddress.WarehouseCode; } } } } } }
protected void ddl_DSSubType_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(ddl_DSSubType.SelectedItem.Value)) { bool refresh = false; ShoppingCart.SelectedDSSubType = ddl_DSSubType.SelectedItem.Value; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, ddl_DSSubType.SelectedItem .Value); //If the order type is switched to Resale and DS has added APFs to cart, throw them out if (limits.PurchaseType == OrderPurchaseType.Consignment && APFDueProvider.IsAPFSkuPresent(ShoppingCart.CartItems) && !APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)) { ShoppingCart.DeleteItemsFromCart(APFDueProvider.GetAPFSkuList()); refresh = true; } if (ShoppingCart.CartItems.Count > 0) { List <ShoppingCartRuleResult> results = HLRulesManager.Manager.ProcessCart(ShoppingCart, ShoppingCartRuleReason .CartCalculated); if (results.Count > 0 && results.Any(r => r.Result == RulesResult.Failure)) { foreach (ShoppingCartRuleResult result in results) { if (result.Result == RulesResult.Failure) { var args = new CartModifiedForSKULimitationsEventArgs(result.Messages[0]); OnCartItemRemovedDueToSKULimitationRules(this, args); } } } } DisplayRemainingValues(ddl_DSSubType.SelectedItem.Value, refresh); } else { ShoppingCart.SelectedDSSubType = String.Empty; trRemainingVal.Visible = false; } }
private void SetPanelsVisibility() { if (Visible) { //Begin HD Ticket 406707 if (_cart.OrderSubType == "A1" || _cart.OrderSubType == "B1") { pnlAPFIsDueWithinYear.Visible = false; } else if (_cart.OrderSubType == "A2" || _cart.OrderSubType == "B2") { if (!HLConfigManager.Configurations.APFConfiguration.ApfExemptCountriesOfProcessing.Contains(APFDueProvider.GetProcessCountry()) && APFDueProvider.CanPurchaseApf(APFDueProvider.GetProcessCountry(), CountryCode, HLConfigManager.Configurations.APFConfiguration.ApfRestrictedByPurchaseLocation)) { pnlAPFIsDueWithinYear.Visible = true; } } //End HD Ticket 406707 } }
protected void Page_Load(object sender, EventArgs e) { (Page.Master as OrderingMaster).EventBus.RegisterObject(this); _testing = !string.IsNullOrEmpty(Request["testAPF"]); _cart = (Page as ProductsBase).ShoppingCart; //TaskID: 9016 fix Visible = _testing | (APFDueProvider.ShouldShowAPFModule(DistributorID, Thread.CurrentThread.CurrentCulture.Name.Substring(3)) && (null != _cart && _cart.OrderCategory == OrderCategoryType.RSO)); if (DistributorOrderingProfile.IsPC) { Visible = false; } if (_cart.OrderCategory == OrderCategoryType.HSO) { Visible = false; } SetPanelsVisibility(); if (Visible) { if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, this.CountryCode)) { ReadFromData(); RefreshVisibility(null, null); } pnlAPFIsDueWithinYear.Visible = false; pnlAPFPaid.Visible = false; pnlTesting.Visible = _testing; //if (IsPostBack) //{ ReadFromPage(); //} //else //{ DisplayData(); //} } }
/// <summary> /// Gets the shipment information to import into HMS. /// </summary> /// <param name="shoppingCart">The shopping cart.</param> /// <param name="shippment">The order shipment.</param> /// <returns></returns> public override bool GetDistributorShippingInfoForHMS(MyHLShoppingCart shoppingCart, Shipment shippment) { var session = SessionInfo.GetSessionInfo(shoppingCart.DistributorID, shoppingCart.Locale); if (session.IsEventTicketMode) { if (shoppingCart.DeliveryInfo != null) { shoppingCart.DeliveryInfo.FreightCode = HLConfigManager.Configurations.CheckoutConfiguration.EventTicketFreightCode; } return(true); } if (APFDueProvider.hasOnlyAPFSku(shoppingCart.CartItems, shoppingCart.Locale)) { return(true); } if (ShoppingCartProvider.IsStandaloneHFF(shoppingCart.ShoppingCartItems)) { if (shoppingCart.DeliveryInfo != null) { var freightCodeAndWarehouse = GetFreightCodeAndWarehouse(shoppingCart.DeliveryInfo.Address); shoppingCart.DeliveryInfo.FreightCode = shippment.ShippingMethodID = HLConfigManager.Configurations.APFConfiguration.APFFreightCode; shoppingCart.DeliveryInfo.WarehouseCode = shippment.WarehouseCode = freightCodeAndWarehouse[1]; } return(true); } if (shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping && (shoppingCart.DeliveryInfo.FreightCode.Equals(HLConfigManager.Configurations.APFConfiguration.APFFreightCode) || shoppingCart.DeliveryInfo.FreightCode.Equals(HLConfigManager.Configurations.CheckoutConfiguration.EventTicketFreightCode))) { var freightCodeAndWarehouse = GetFreightCodeAndWarehouse(shoppingCart.DeliveryInfo.Address); shoppingCart.DeliveryInfo.FreightCode = shippment.ShippingMethodID = freightCodeAndWarehouse[0]; shoppingCart.DeliveryInfo.WarehouseCode = shippment.WarehouseCode = freightCodeAndWarehouse[1]; } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string level = APFDueProvider.GetDSLevel(); DateTime dt = APFDueProvider.GetAPFDueDate(DistributorID, Locale.Substring(3)); if (dt < DateTime.Now) { btnRemind.Visible = false; lblRemindltr.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "APFFeeDuePastPopup"), dt.ToShortDateString()); } else if (dt > DateTime.Now) { lblRemindltr.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "APFFeeDueFuturePopup"), dt.ToShortDateString()); } else if (dt.Date == DateTime.Now.Date) { lblRemindltr.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "APFFeeDueTodayPopup"), dt.ToShortDateString()); } } }
public override bool ValidateShipping(MyHLShoppingCart shoppingCart) { if (shoppingCart != null) { if (shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping) { if (shoppingCart.DeliveryInfo != null && !string.IsNullOrEmpty(shoppingCart.DeliveryInfo.WarehouseCode) && !string.IsNullOrEmpty(shoppingCart.DeliveryInfo.FreightCode)) { return(true); } } else { if (!APFDueProvider.containsOnlyAPFSku(shoppingCart.CartItems)) { if (shoppingCart.DeliveryInfo != null && !string.IsNullOrEmpty(shoppingCart.DeliveryInfo.WarehouseCode) && !string.IsNullOrEmpty(shoppingCart.DeliveryInfo.FreightCode) && shoppingCart.DeliveryInfo.PickupDate != null && !string.IsNullOrEmpty(shoppingCart.DeliveryInfo.Address.Recipient)) { return(true); } } else { if (shoppingCart.DeliveryInfo != null && !string.IsNullOrEmpty(shoppingCart.DeliveryInfo.WarehouseCode) && !string.IsNullOrEmpty(shoppingCart.DeliveryInfo.FreightCode)) { return(true); } } } } return(false); }
private void ReadFromData() { DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode); _distributorId = DistributorID; _apfDueDate = distributorOrderingProfile.ApfDueDate; _apfSku = APFDueProvider.GetAPFSku(); _cart = (Page as ProductsBase).ShoppingCart; _apfIsDue = APFDueProvider.IsAPFDueAndNotPaid(_distributorId); if (_apfIsDue) { _apfsDue = APFDueProvider.APFQuantityDue(_distributorId, HLConfigManager.Configurations.Locale); } List <ShoppingCartItem_V01> item = (from c in _cart.CartItems where c.SKU == _apfSku select c).ToList(); _apfsInCart = 0; if (item.Count > 0) { _apfsInCart = item[0].Quantity; } }
public static decimal TotalsExcludeAPF(MyHLShoppingCart cart, string countryCode) { 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 totals = cart.Calculate(calcTheseItems); return(totals != null ? (totals as OrderTotals_V01).AmountDue : decimal.Zero); } return(decimal.Zero); }
private ShoppingCartRuleResult CartRetrievedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result) { try { if (null != cart) { if (APFDueProvider.IsAPFSkuPresent(cart.CartItems) && APFDueProvider.IsAPFDueAndNotPaid(cart.DistributorID, Locale)) { var limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(cart.DistributorID); if (null != limits && null != limits.PurchaseSubType) { if (limits.PurchaseType == ServiceProvider.OrderSvc.OrderPurchaseType.Consignment) //No consignment allowed when APFDue { if (limits.PurchaseSubType == "A1") { limits.PurchaseSubType = "A2"; } if (limits.PurchaseSubType == "B1") { limits.PurchaseSubType = "B2"; } } } } } } catch (Exception ex) { LoggerHelper.Error(string.Format("APFRules.it-IT.ProcessAPF DS:{0} locale:{2} ERR:{1}", cart.DistributorID, ex, Locale)); } return(result); }
private ShoppingCartRuleResult CartRetrievedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result, string level) { if (cart != null) { var myhlCart = cart as MyHLShoppingCart; if (APFDueProvider.IsAPFSkuPresent(cart.CartItems) && myhlCart != null) { // Change the APF sku according tins var tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true); var huvt = tins.Find(p => p.IDType.Key == "HUVT"); var hupt = tins.Find(p => p.IDType.Key == "HUPT"); if (huvt != null && hupt != null) { myhlCart.DeleteItemsFromCart(null, true); myhlCart.AddItemsToCart(new List <ShoppingCartItem_V01>(new[] { new ShoppingCartItem_V01(0, AlternAPFSku, 1, DateTime.Now) }), true); return(result); } //Prevent to have a cart with skus Bug 148170 if (cart.CartItems.Count > 1) { //get the skus != apf var nonApfItems = (from c in cart.CartItems where APFDueProvider.IsAPFSku(c.SKU.Trim()) == false select c) .ToList <ShoppingCartItem_V01>(); if (nonApfItems.Count > 0 || HLConfigManager.Configurations.APFConfiguration.StandaloneAPFOnlyAllowed) { var skuToBeRemoved = nonApfItems.Select(x => x.SKU).ToList(); myhlCart.DeleteItemsFromCart(skuToBeRemoved); } } } } return(result); }
private ShoppingCartRuleResult CartItemBeingAddedRuleHandler(ShoppingCart_V01 cart, ShoppingCartRuleResult result, string level) { var hlCart = cart as MyHLShoppingCart; if (null != hlCart) { foreach (ShoppingCartItem_V01 item in cart.CurrentItems) { if (APFDueProvider.IsAPFSku(item.SKU)) { bool canAddAPF = ShouldAddAPFPT(cart as MyHLShoppingCart); if (!canAddAPF) { result.Result = RulesResult.Failure; result.AddMessage( HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "CannotAddAPFSku") as string); var sku = APFDueProvider.GetAPFSku(); SetApfRuleResponse(result, ApfAction.None, sku, "ApfRule", TypeOfApf.StandaloneAPFOnlyAllowed, "CannotRemoveAPFSku"); cart.RuleResults.Add(result); cart.APFEdited = false; return(result); } } } Global.APFRules globalRules = new Global.APFRules(); hlCart.RuleResults = globalRules.ProcessCart(hlCart, ShoppingCartRuleReason.CartItemsBeingAdded); } return(result); }
private ShoppingCartItem_V01 GetApfSku(List <ShoppingCartItem_V01> cartItems, string locale, string level) { ShoppingCartItem_V01 sku = null; var SKUs = APFDueProvider.GetAPFSkuList(); if (SKUs != null && SKUs.Count == 2) { // if sku does not exist in the cart, add it // sku 1 is SP //string apfSKU = level == "SP" ? SKUs[1] : SKUs[0]; string apfSKU = string.Empty; if (level == "SP") { apfSKU = HLConfigManager.Configurations.APFConfiguration.SupervisorSku; } else { apfSKU = HLConfigManager.Configurations.APFConfiguration.DistributorSku; } sku = new ShoppingCartItem_V01(0, apfSKU, 1, DateTime.Now); } return(sku); }