private void DisplayRemainingValues(string DSSubType, bool Refresh) { trRemainingVal.Visible = true; var limits = new PurchasingLimits_V01(); if (string.IsNullOrEmpty(DSSubType)) { trRemainingVal.Visible = false; return; } else { limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSSubType); } if (!this.FOPEnabled) { displayPurchasingLimits(DSSubType, limits, Refresh); } else { if (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) { displayPurchasingLimits(DSSubType, limits, Refresh); } else { displayFOP(limits, Refresh); } } }
protected void ddl_OrderType_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(ddl_OrderType.SelectedItem.Value)) { OnOrderSubTypeChanged(sender, e); //bool refresh = false; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, ddl_OrderType.SelectedItem.Value); ShoppingCart.SelectedDSSubType = ddl_OrderType.SelectedItem.Value; lblOrderTypeVal.Text = ddl_OrderType.SelectedItem.ToString(); //If the order type is switched to Resale and DS has added APFs to cart, throw them out if (ddl_OrderType.SelectedItem.Value == OrderTypesBG.CO.ToString() && 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); } } } } if (HasMemberVPLimitations()) { PurchaseLimitType limitType = PurchaseLimitType.Volume; limits.PurchaseLimitType = limitType; DisplayRemaining(ShoppingCart.SelectedDSSubType); } else { PurchaseLimitType limitType = PurchaseLimitType.None; limits.PurchaseLimitType = limitType; } } else { ShoppingCart.SelectedDSSubType = String.Empty; trRemainingVal.Visible = false; lblOrderTypeVal.Text = String.Empty; } }
private void DisplayRemainingValues(string DSSubType, bool Refresh) { PurchasingLimits_V01 limits = new PurchasingLimits_V01(); ShoppingCart.EmailValues.RemainingVolume = string.Empty; if (string.IsNullOrEmpty(DSSubType)) { limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID); } else { limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSSubType); } if (FOPEnabled) { trRemainingVal.Visible = limits.RemainingVolume > -1; } else { trRemainingVal.Visible = PurchasingLimitManager(ShoppingCart.DistributorID).PurchasingLimitsRestriction != PurchasingLimitRestrictionType.MarketingPlan; } if (DSSubType == "RE") { //trRemainingVal.Visible = false; OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, true, false, Refresh)); } lblRemainingValDisplay.Text = this.GetLocalResourceObject("RemainingVolume").ToString(); if (ShoppingCart != null && limits != null) { decimal totalDue = TotalsExcludeAPF(ShoppingCart, this.CountryCode); decimal remaining = decimal.Zero; if (FOPEnabled) { decimal cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart; remaining = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? limits.RemainingVolume - totalDue : limits.RemainingVolume - cartVolume; } else { remaining = limits.RemainingVolume - totalDue; } if (remaining < 0) { remaining = 0; } this.lblRemainingVal.Text = limits.PurchaseLimitType == PurchaseLimitType.Volume ? remaining.ToString("N2") : this.getAmountString(remaining); this.lblRemainingVal.Visible = limits.PurchaseLimitType != PurchaseLimitType.None; } if (trRemainingVal.Visible) { ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text; } OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, false, true, Refresh)); }
protected void ddl_DSSubType_SelectedIndexChanged(object sender, EventArgs e) { if (!String.IsNullOrEmpty(ddl_DSSubType.SelectedItem.Value)) { bool refresh = false; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, ddl_DSSubType.SelectedItem.Value); ShoppingCart.SelectedDSSubType = 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) { CartModifiedForSKULimitationsEventArgs args = new CartModifiedForSKULimitationsEventArgs(result.Messages[0]); OnCartItemRemovedDueToSKULimitationRules(this, args); } } } ShoppingCart.Calculate(); OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, true, false, true)); } DisplayRemainingValues(ddl_DSSubType.SelectedItem.Value, refresh); lblMessageZeroPercent.Visible = ShoppingCart.SelectedDSSubType == "RE"; } else { ShoppingCart.SelectedDSSubType = String.Empty; trRemainingVal.Visible = false; } }
private void DisplayRemaining() { string DSType = DistributorOrderingProfile.OrderSubType == null ? string.Empty : DistributorOrderingProfile.OrderSubType; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSType); ShoppingCart.SelectedDSSubType = string.IsNullOrEmpty(DSType) ? "NA" : DSType; ShoppingCart.EmailValues.RemainingVolume = string.Empty; decimal cartVolume = ShoppingCart.VolumeInCart; if (null != limits) { decimal remaining = decimal.Zero; if (FOPEnabled) { cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart; } remaining = (limits.RemainingVolume - cartVolume); if (remaining < 0) { remaining = 0; } lblRemainingVal.Text = remaining.ToString("N2"); } trRemainingVal.Visible = ((null != limits && limits.PurchaseLimitType == PurchaseLimitType.Volume) || (null != limits && PurchasingLimitManager(DistributorID).PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan)); if (trRemainingVal.Visible) { ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text; } }
protected void Page_Load(object sender, EventArgs e) { List <TaxIdentification> tinList = DistributorOrderingProfile.TinList; if (!IsPostBack) { if (ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO) { trOrderType.Visible = false; trRemainingVal.Visible = false; ShoppingCart.SelectedDSSubType = "NA"; PurchasingLimitProvider.GetPurchasingLimits(DistributorID, "ETO"); return; } if (tinList == null || tinList.Where(t => t.IDType.Key == "GRVT").Count() == 0) { trOrderType.Visible = false; trRemainingVal.Visible = true; ShoppingCart.SelectedDSSubType = "PC"; DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } else { if (tinList.Where(t => t.IDType.Key == "GRVT" || t.IDType.Key == "GRTN" || t.IDType.Key == "GRSS" || t.IDType.Key == "GRBL").Count() == 4) { trRemainingVal.Visible = false; trOrderType.Visible = true; } else { trRemainingVal.Visible = true; trOrderType.Visible = true; } if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType)) { ddl_DSSubType.ClearSelection(); ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType); if (null != item) { item.Selected = true; lblOrderTypeVal.Text = item.Text; } else { if (ddl_DSSubType.Items.Count > 0) { item = ddl_DSSubType.Items[0]; item.Selected = true; lblOrderTypeVal.Text = item.Text; ShoppingCart.SelectedDSSubType = item.Value; } } DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } else { //User Story 102057: INC2676705: Default 'Προσωπικό όριο αγορών' (Personal limit) ListItem item = ddl_DSSubType.Items.FindByValue("PC"); item.Selected = true; lblOrderTypeVal.Text = item.Text; ShoppingCart.SelectedDSSubType = item.Value; ShoppingCart.Calculate(); OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(item.Value, true, false, true)); } if (DisplayStatic) { ddl_DSSubType.Visible = false; lblOrderTypeVal.Visible = true; } else { ddl_DSSubType.Visible = true; lblOrderTypeVal.Visible = false; } } lblMessageZeroPercent.Visible = false; if (ddl_DSSubType.Visible == true) { if (ddl_DSSubType.SelectedValue != null && ddl_DSSubType.SelectedValue == "RE") { lblMessageZeroPercent.Visible = true; } } } }
/// <summary> /// The IShoppingCart Rule Interface implementation /// </summary> /// <param name="cart">The current Shopping Cart</param> /// <param name="reason">The Rule invoke Reason</param> /// <param name="Result">The Rule Results collection</param> /// <returns>The cumulative rule results - including the results of this iteration</returns> protected virtual ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { var purchasingLimitManager = PurchasingLimitManager(cart.DistributorID); decimal DistributorRemainingVolumePoints = 0; decimal DistributorRemainingDiscountedRetail = 0; //decimal CartVolumePoints = 0; decimal NewVolumePoints = 0; decimal DistributorRemainingEarnings = 0; //decimal CartEarnings = 0; decimal NewEarnings = 0; decimal Discount = 0; var myhlCart = cart as MyHLShoppingCart; if (null == myhlCart) { LoggerHelper.Error( string.Format("{0} myhlCart is null {1}", Locale, cart.DistributorID)); Result.Result = RulesResult.Failure; return(Result); } PurchasingLimits_V01 PurchasingLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(cart.DistributorID); purchasingLimitManager.SetPurchasingLimits(PurchasingLimits); if (null == PurchasingLimits) { LoggerHelper.Error( string.Format("{0} PurchasingLimits could not be retrieved for distributor {1}", Locale, cart.DistributorID)); Result.Result = RulesResult.Failure; return(Result); } DistributorRemainingVolumePoints = DistributorRemainingDiscountedRetail = PurchasingLimits.RemainingVolume; DistributorRemainingEarnings = PurchasingLimits.RemainingEarnings; var distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, Country); Discount = Convert.ToDecimal(distributorOrderingProfile.StaticDiscount); if (myhlCart.Totals != null && (myhlCart.Totals as OrderTotals_V01).DiscountPercentage != 0.0M) { Discount = (myhlCart.Totals as OrderTotals_V01).DiscountPercentage; } myhlCart.SetDiscountForLimits(Discount); var currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country); if (currentItem != null) { if (currentItem.ProductType == ServiceProvider.CatalogSvc.ProductType.EventTicket) { PurchasingLimitProvider.GetPurchasingLimits(cart.DistributorID, "ETO"); } else { NewVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity; } } if (NewVolumePoints > 0 || PurchasingLimits.PurchaseLimitType == PurchaseLimitType.Earnings || purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) { if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.Volume) { if (PurchasingLimits.maxVolumeLimit == -1) { return(Result); } decimal cartVolume = (cart as MyHLShoppingCart).VolumeInCart; if (DistributorRemainingVolumePoints - (cartVolume + NewVolumePoints) < 0) { Result.Result = RulesResult.Failure; if (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) //MPE Thresholds { if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThresholdByIncreasingQuantity").ToString(), cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThreshold").ToString(), cart.CurrentItems[0].SKU)); } } else { if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsByIncreasingQuantity").ToString(), cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceeds").ToString(), cart.CurrentItems[0].SKU)); } } cart.RuleResults.Add(Result); } } else if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.DiscountedRetail) { var myHlCart = cart as MyHLShoppingCart; var calcTheseItems = new List <ShoppingCartItem_V01>(cart.CartItems); var existingItem = cart.CartItems.Find(ci => ci.SKU == cart.CurrentItems[0].SKU); if (null != existingItem) { existingItem.Quantity += cart.CurrentItems[0].Quantity; } else { calcTheseItems.Add(new ShoppingCartItem_V01(0, cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity, DateTime.Now)); } var totals = myhlCart.Calculate(calcTheseItems) as OrderTotals_V01; if (null != existingItem) { existingItem.Quantity -= cart.CurrentItems[0].Quantity; } if (null == totals) { var message = string.Format( "Purchasing Limits DiscountedRetail calculation failed due to Order Totals returning a null for Distributor {0}", cart.DistributorID); LoggerHelper.Error(message); throw new ApplicationException(message); } decimal newDiscountedRetail = 0.0M; decimal dsicount = totals.DiscountPercentage; var skus = (from s in calcTheseItems where s.SKU != null select s.SKU).ToList(); var allItems = CatalogProvider.GetCatalogItems(skus, Country); if (null != allItems && allItems.Count > 0) { newDiscountedRetail = (from t in totals.ItemTotalsList from c in allItems.Values where (c as CatalogItem_V01).ProductType == ServiceProvider.CatalogSvc.ProductType.Product && c.SKU == (t as ItemTotal_V01).SKU select(t as ItemTotal_V01).DiscountedPrice).Sum(); } myhlCart.SetDiscountForLimits(totals.DiscountPercentage); if (DistributorRemainingDiscountedRetail - newDiscountedRetail < 0) { Result.Result = RulesResult.Failure; if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "DiscountedRetailExceedsByIncreasingQuantity").ToString(), cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "DiscountedRetailExceeds").ToString(), cart.CurrentItems[0].SKU)); } cart.RuleResults.Add(Result); } } else if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.Earnings && cart.OrderSubType == "B1") { NewEarnings += (currentItem.EarnBase) * cart.CurrentItems[0].Quantity * Discount / 100; if (DistributorRemainingEarnings - ((cart as MyHLShoppingCart).ProductEarningsInCart + NewEarnings) < 0) { Result.Result = RulesResult.Failure; if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "EarningExceedsByIncreasingQuantity").ToString(), cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "EarningExceeds") .ToString(), cart.CurrentItems[0].SKU)); } cart.RuleResults.Add(Result); } } else if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.ProductCategory) { if (currentItem.ProductType == ServiceProvider.CatalogSvc.ProductType.Product) { Result.Result = RulesResult.Failure; Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "PurchaseLimitTypeProductCategory").ToString(), cart.CurrentItems[0].SKU)); cart.RuleResults.Add(Result); } else { if (DistributorRemainingVolumePoints - ((cart as MyHLShoppingCart).VolumeInCart + NewVolumePoints) < 0) { Result.Result = RulesResult.Failure; if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThresholdByIncreasingQuantity").ToString(), cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThreshold").ToString(), cart.CurrentItems[0].SKU)); } } } } else if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.TotalPaid) { Result.Result = RulesResult.Success; var myHlCart = cart as MyHLShoppingCart; 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)); var existingItem = calcTheseItems.Find(ci => ci.SKU == cart.CurrentItems[0].SKU); if (null != existingItem) { existingItem.Quantity += cart.CurrentItems[0].Quantity; } else { calcTheseItems.Add(new ShoppingCartItem_V01(0, cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity, DateTime.Now)); } // remove A and L type var allItems = CatalogProvider.GetCatalogItems( (from s in calcTheseItems where s.SKU != null select s.SKU).ToList(), Country); 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 = myhlCart.Calculate(calcTheseItems); if (null == totals) { var message = string.Format( "Purchasing Limits DiscountedRetail calculation failed due to Order Totals returning a null for Distributor {0}", cart.DistributorID); LoggerHelper.Error(message); throw new ApplicationException(message); } if (DistributorRemainingVolumePoints - (totals as OrderTotals_V01).AmountDue < 0) { Result.Result = RulesResult.Failure; if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "DiscountedRetailExceedsByIncreasingQuantity").ToString(), cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "DiscountedRetailExceeds").ToString(), cart.CurrentItems[0].SKU)); } cart.RuleResults.Add(Result); } } else { Result.Result = RulesResult.Success; } } } return(Result); }
public ShoppingCartRuleResult checkVolumeLimits(MyHLShoppingCart cart, ShoppingCartRuleResult Result, string Locale, string Country) { decimal DistributorRemainingVolumePoints = 0; decimal NewVolumePoints = 0; IPurchasingLimitManagerFactory purchasingLimitManagerFactory = new PurchasingLimitManagerFactory(); var purchasingLimitManager = purchasingLimitManagerFactory.GetPurchasingLimitManager(cart.DistributorID); var purchasingLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(cart.DistributorID); if (null == purchasingLimits) { LoggerHelper.Error( string.Format("{0} PurchasingLimits could not be retrieved for distributor in checkVolumeLimits {1}", Locale, cart.DistributorID)); Result.Result = RulesResult.Failure; return(Result); } purchasingLimitManager.SetPurchasingLimits(purchasingLimits); DistributorRemainingVolumePoints = purchasingLimits.RemainingVolume; var currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country); if (currentItem != null) { if (currentItem.ProductType == ServiceProvider.CatalogSvc.ProductType.EventTicket) { PurchasingLimitProvider.GetPurchasingLimits(cart.DistributorID, "ETO"); } else { NewVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity; } } if (NewVolumePoints > 0) { if (purchasingLimits.maxVolumeLimit == -1) { return(Result); } decimal cartVolume = cart.VolumeInCart; if (DistributorRemainingVolumePoints - (cartVolume + NewVolumePoints) < 0) { Result.Result = RulesResult.Failure; var orderMonth = new OrderMonth(Country); var msg = HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform) ?? string.Empty, "VolumePointExceedsOnOrderMonth") as string; msg = string.Format(msg, orderMonth.CurrentOrderMonth.ToString("MM-yyyy"), DistributorRemainingVolumePoints); Result.AddMessage(msg); var globalResourceObject = HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "DisgardCommonMessage"); if (globalResourceObject != null) { Result.AddMessage(globalResourceObject.ToString()); } cart.RuleResults.Add(Result); } } return(Result); }
public virtual bool PurchasingLimitsAreExceeded(string distributorId) { bool exceeded = false; if (!PurchasingLimitProvider.RequirePurchasingLimits(distributorId, Country)) { return(exceeded); } var cart = ShoppingCartProvider.GetShoppingCart(distributorId, Locale, true); PurchasingLimits_V01 limits = null; if (HLConfigManager.Configurations.DOConfiguration.SaveDSSubType) { limits = PurchasingLimitProvider.GetPurchasingLimits(distributorId, cart.SelectedDSSubType); } else { limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(distributorId); } if (null != cart && null != cart.Totals && cart.OrderCategory != ServiceProvider.CatalogSvc.OrderCategoryType.ETO) { bool restrictedByMarketingPlan = PurchasingLimitProvider.IsRestrictedByMarketingPlan(distributorId); if ((null != limits && (limits.PurchaseLimitType != PurchaseLimitType.None) || restrictedByMarketingPlan)) { if (limits.PurchaseType != OrderPurchaseType.Consignment || (limits.PurchaseType == OrderPurchaseType.Consignment && cart.OrderSubType == "B1")) { if (restrictedByMarketingPlan) { limits.PurchaseLimitType = (limits.maxVolumeLimit == -1) ? PurchaseLimitType.None : PurchaseLimitType.Volume; } else { limits.PurchaseLimitType = (limits.maxVolumeLimit == -1) ? PurchaseLimitType.None : limits.PurchaseLimitType; } switch (limits.PurchaseLimitType) { case PurchaseLimitType.Earnings: { exceeded = ((limits.RemainingEarnings - cart.ProductEarningsInCart) < 0); break; } case PurchaseLimitType.Volume: { exceeded = ((limits.RemainingVolume - cart.VolumeInCart) < 0); break; } case PurchaseLimitType.DiscountedRetail: { exceeded = ((limits.RemainingVolume - cart.ProductDiscountedRetailInCart) < 0); break; } case PurchaseLimitType.TotalPaid: { if (null != cart.Totals) { exceeded = ((limits.RemainingVolume - (cart.Totals as OrderTotals_V01).AmountDue) < 0); } break; } } } } //else if (ods.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) //{ // exceeded = ((limits.RemainingVolume - cart.VolumeInCart) < 0); //} } return(exceeded); }
/// <summary> /// The IShoppingCart Rule Interface implementation /// </summary> /// <param name="cart">The current Shopping Cart</param> /// <param name="reason">The Rule invoke Reason</param> /// <param name="Result">The Rule Results collection</param> /// <returns>The cumulative rule results - including the results of this iteration</returns> protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { decimal DistributorRemainingVolumePoints = 0; decimal NewVolumePoints = 0; if (cart.CurrentItems == null || cart.CurrentItems.Count == 0) { Result.Result = RulesResult.Failure; return(Result); } var orderMonth = new OrderMonth(Country); PurchasingLimitManager(cart.DistributorID).SetPurchasingLimits(PurchasingLimitProvider.GetOrderMonth()); var PurchasingLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(cart.DistributorID); if (null == PurchasingLimits) { LoggerHelper.Error( string.Format("{0} PurchasingLimits could not be retrieved for distributor {1}", Locale, cart.DistributorID)); Result.Result = RulesResult.Failure; return(Result); } DistributorRemainingVolumePoints = PurchasingLimits.RemainingVolume; var currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country); if (currentItem != null) { if (currentItem.ProductType == ServiceProvider.CatalogSvc.ProductType.EventTicket) { PurchasingLimitProvider.GetPurchasingLimits(cart.DistributorID, "ETO"); } else { NewVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity; } } // validate order threshold first if (PurchasingLimits.maxVolumeLimit == -1) { return(Result); } if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.ProductCategory && currentItem.ProductType == ServiceProvider.CatalogSvc.ProductType.Product) { Result.Result = RulesResult.Failure; Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "PurchaseLimitTypeProductCategory") as string ?? string.Empty, cart.CurrentItems[0].SKU)); cart.RuleResults.Add(Result); return(Result); } // validate against order threshold first decimal cartVolume = (cart as MyHLShoppingCart).VolumeInCart; if (PurchasingLimitProvider.IsOrderThresholdMaxVolume(PurchasingLimits) || PurchasingLimits.PurchaseLimitType != PurchaseLimitType.None) { if (DistributorRemainingVolumePoints - (cartVolume + NewVolumePoints) < 0) { Result.Result = RulesResult.Failure; string message = string.Empty; if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.Messages.Add( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThresholdByIncreasingQuantity") as string ?? string.Empty, cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.Messages.Add( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThreshold") as string ?? string.Empty, cart.CurrentItems[0].SKU)); } if (Result.Messages.Any()) { cart.RuleResults.Add(Result); } else { Result.Result = RulesResult.Success; } return(Result); // if fails, just return } } if (PurchasingLimits.PurchaseLimitType == PurchaseLimitType.ProductCategory) { if (DistributorRemainingVolumePoints - ((cart as MyHLShoppingCart).VolumeInCart + NewVolumePoints) < 0) { Result.Result = RulesResult.Failure; if (cart.CartItems.Exists(item => item.SKU == cart.CurrentItems[0].SKU)) { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThresholdByIncreasingQuantity") as string ?? string.Empty, cart.CurrentItems[0].SKU, cart.CurrentItems[0].Quantity)); } else { Result.AddMessage( string.Format( HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "VolumePointExceedsThreshold") as string ?? string.Empty, cart.CurrentItems[0].SKU)); } } } else { Result.Result = RulesResult.Success; } } return(Result); }
protected void Page_Load(object sender, EventArgs e) { string DSType = DistributorOrderingProfile.OrderSubType == null ? string.Empty : DistributorOrderingProfile.OrderSubType; if (string.IsNullOrEmpty(DSType) || DSType.ToUpper() == "N") { DSType = "NA"; } if (!IsPostBack) { ShoppingCart.SelectedDSSubType = string.IsNullOrEmpty(ShoppingCart.SelectedDSSubType) ? DSType.Equals("F") ? "PC" : "NA" : ShoppingCart.SelectedDSSubType; // initial value if (ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.ETO) { trOrderType.Visible = false; trRemainingVal.Visible = false; //ShoppingCart.SelectedDSSubType = String.Empty; ShoppingCart.SelectedDSSubType = DSType.Equals("F") ? "PC" : "NA"; PurchasingLimitProvider.GetPurchasingLimits(DistributorID, "ETO"); return; } bool noConsignmentOrdersAllowed = false; if (DSType.Equals("F")) { if (APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)) { noConsignmentOrdersAllowed = true; } } if (noConsignmentOrdersAllowed) { lbltext.Text = GetLocalResourceObject("CannotPlaceConsignmentWhileAPFDue") as string; lbltext.Visible = true; } ddl_DSSubType.Enabled = false; //ddlDelivery.Enabled = false; trRemainingVal.Visible = false; switch (DSType) { case "F": { ddl_DSSubType.Items.Clear(); if (!HideEmptyListItem) { ddl_DSSubType.Items.Add(string.Empty); } if (!noConsignmentOrdersAllowed) { ddl_DSSubType.Items.Add(new ListItem("Revente", "RE")); //TODOD: Resx these } ddl_DSSubType.Items.Add(new ListItem("Consommation Personnelle", "PC")); ddl_DSSubType.Enabled = true; if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType)) { ddl_DSSubType.ClearSelection(); ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType); if (null != item) { item.Selected = true; lblOrderTypeVal.Text = item.Text; } DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } break; } default: { ShoppingCart.SelectedDSSubType = DSType; lblOrderType.Visible = false; lblOrderTypeVal.Text = @"Consommation Personnelle"; ddl_DSSubType.Visible = false; ddl_DSSubType.Items.Clear(); ddl_DSSubType.Items.Add(new ListItem(DSType, DSType)); ddl_DSSubType.SelectedIndex = 0; break; } } if (ddl_DSSubType.Items.Count > 0 && null != ddl_DSSubType.SelectedItem && ddl_DSSubType.Visible) { ShoppingCart.SelectedDSSubType = ddl_DSSubType.SelectedItem.Value; } else { ShoppingCart.SelectedDSSubType = "NA"; } if (DisplayStatic) { if (DSType.Equals("F")) { ddl_DSSubType.Visible = false; lblOrderTypeVal.Visible = true; } else { DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } } else { if (DSType.Equals("F")) { ddl_DSSubType.Visible = true; lblOrderTypeVal.Visible = false; } else { DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } } } }
private void DisplayRemainingValues(string DSSubType, bool Refresh) { var limits = new PurchasingLimits_V01(); trRemainingVal.Visible = true; ShoppingCart.EmailValues.RemainingVolume = string.Empty; if (string.IsNullOrEmpty(DSSubType)) { limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID); } else { limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSSubType); } if (FOPEnabled) { if (limits != null && limits.LimitsRestrictionType == LimitsRestrictionType.FOP) { DisplayRemainingValuesFOP(DistributorID, Refresh, limits); return; } } if (DSSubType == "RE") { trRemainingVal.Visible = false; OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, true, false, Refresh)); } else if (DSSubType == "PC") { lblRemainingValDisplay.Text = GetLocalResourceObject("RemainingVolume").ToString(); if (ShoppingCart != null) { decimal discountedRetail = (null != ShoppingCart.Totals) ? ShoppingCart.ProductDiscountedRetailInCart : 0.0M; decimal remaining = limits.RemainingVolume - discountedRetail; if (remaining < 0) { remaining = 0; } lblRemainingVal.Text = limits.PurchaseLimitType == PurchaseLimitType.Volume ? remaining.ToString("N2") : getAmountString(remaining); } OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs(ddl_DSSubType.SelectedItem.Value, false, true, Refresh)); } else { trRemainingVal.Visible = false; OnOrderSubTypeChanged(this, new OrderSubTypeEventArgs("NA", true, false, Refresh)); } if (trRemainingVal.Visible) { ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bool apfIsDue = false; bool hasVPLimitations = true; //Company (Resale) not allowed when APF is due if (APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)) { apfIsDue = true; //lbltext.Text = GetLocalResourceObject("CannotPlaceResaletWhileAPFDue") as string; //lbltext.Visible = true; } else if (ShoppingCart.OrderCategory == OrderCategoryType.ETO) { trOrderType.Visible = false; trRemainingVal.Visible = false; ShoppingCart.SelectedDSSubType = OrderTypesBG.PC.ToString(); PurchasingLimitProvider.GetPurchasingLimits(DistributorID, "ETO"); return; } else { hasVPLimitations = HasMemberVPLimitations(); } //For PC Orders always Has Member VP Limitations ddl_OrderType.Items.Clear(); ddl_OrderType.Enabled = false; ddl_OrderType.Items.Add(new ListItem(GetLocalResourceObject("TypeOrder_1") as string, OrderTypesBG.PC.ToString())); //Personal Consumption if (!hasVPLimitations && !apfIsDue) { ddl_OrderType.Items.Add(new ListItem(GetLocalResourceObject("TypeOrder_2") as string, OrderTypesBG.CO.ToString())); //Company(Resale) ddl_OrderType.Enabled = true; //lbltext.Text = string.Empty; //lbltext.Visible = false; } if (ShoppingCart != null) { switch (ShoppingCart.SelectedDSSubType) { case "PC": case "CO": { ddl_OrderType.SelectedIndex = ddl_OrderType.Items.IndexOf(ddl_OrderType.Items.FindByValue(ShoppingCart.SelectedDSSubType)); break; } default: { ShoppingCart.SelectedDSSubType = ddl_OrderType.SelectedItem.Value; break; } } lblOrderTypeVal.Text = ddl_OrderType.SelectedItem.ToString(); } // Displaying remaining volume points //if (ShoppingCart.OrderCategory == OrderCategoryType.ETO || !hasVPLimitations) if (ShoppingCart.OrderCategory == OrderCategoryType.ETO) { trRemainingVal.Visible = false; } else { DisplayRemaining(ddl_OrderType.SelectedItem.Value); } if (DisplayStatic) { ddl_OrderType.Visible = false; lblOrderTypeVal.Visible = true; } } }
private void DisplayRemaining(string orderSubType) { //string DSType = ProductsBase.LevelSubType; ShoppingCart.EmailValues.RemainingVolume = string.Empty; //ShoppingCart.SelectedDSSubType = orderSubType; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, orderSubType); decimal cartVolume = 0M; if (null != limits) { if (FOPEnabled) { if (limits.PurchaseLimitType == PurchaseLimitType.TotalPaid) { cartVolume = TotalsExcludeAPF(ShoppingCart, this.CountryCode); lblRemainingValDisplay.Text = GetLocalResourceObject("RemainingAmount").ToString(); } else { cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart; } } else { var purchasingLimitManager = PurchasingLimitManager(this.DistributorID); cartVolume = (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) ? ShoppingCart.VolumeInCart : ShoppingCart.ProductVolumeInCart; } decimal remaining = (limits.RemainingVolume - cartVolume); if (remaining < 0) { remaining = 0; } if (limits.PurchaseLimitType == PurchaseLimitType.Volume) { lblRemainingVal.Text = ProductsBase.GetVolumePointsFormat(remaining); } //else //{ // lblRemainingVal.Text = ProductsBase.getAmountString(remaining); //} } if (PurchasingLimitProvider.DisplayLimits(DistributorID, CountryCode)) { if (HasMemberVPLimitations()) { trRemainingVal.Visible = null != limits ? true : false; //trRemainingVal.Visible = null != limits && // (limits.PurchaseLimitType == PurchaseLimitType.Earnings || // limits.PurchaseLimitType == PurchaseLimitType.Volume || // limits.PurchaseLimitType == PurchaseLimitType.TotalPaid); PurchaseLimitType limitType = PurchaseLimitType.Volume; limits.PurchaseLimitType = limitType; } else { if (limits.LimitsRestrictionType == LimitsRestrictionType.FOP) { trRemainingVal.Visible = null != limits ? true : false; //Show remaining VP when FOP regardless of Limitations } else { trRemainingVal.Visible = false; } } } else { trRemainingVal.Visible = false; } if (trRemainingVal.Visible) { ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text; } }
private void DisplayRemaining() { string DSType = ProductsBase.LevelSubType; ShoppingCart.EmailValues.RemainingVolume = string.Empty; PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSType); ShoppingCart.SelectedDSSubType = !countries.Trim().Contains(Locale.Substring(3)) ? DSType : ""; //var purchasingLimitManager = PurchasingLimitManager(this.DistributorID); //decimal cartVolume = (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) ? ShoppingCart.VolumeInCart : ShoppingCart.ProductVolumeInCart; decimal cartVolume = 0M; if (null != limits) { if (FOPEnabled) { if (limits.PurchaseLimitType == PurchaseLimitType.TotalPaid) { cartVolume = TotalsExcludeAPF(ShoppingCart, this.CountryCode); lblRemainingValDisplay.Text = GetLocalResourceObject("RemainingAmount").ToString(); } else { cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart; } } else { var purchasingLimitManager = PurchasingLimitManager(this.DistributorID); cartVolume = (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) ? ShoppingCart.VolumeInCart : ShoppingCart.ProductVolumeInCart; } decimal remaining = (limits.RemainingVolume - cartVolume); if (remaining < 0) { remaining = 0; } if (limits.PurchaseLimitType == PurchaseLimitType.Volume) { lblRemainingVal.Text = ProductsBase.GetVolumePointsFormat(remaining); } else { lblRemainingVal.Text = ProductsBase.getAmountString(remaining); } } if (PurchasingLimitProvider.DisplayLimits(DistributorID, CountryCode)) { trRemainingVal.Visible = null != limits && (limits.PurchaseLimitType == PurchaseLimitType.Earnings || limits.PurchaseLimitType == PurchaseLimitType.Volume || limits.PurchaseLimitType == PurchaseLimitType.TotalPaid); } else { trRemainingVal.Visible = false; } if (trRemainingVal.Visible) { ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text; } }
protected void Page_Load(object sender, EventArgs e) { DistributorOrderingProfile dsProfile = DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode); string DSType = dsProfile.OrderSubType; //lblProductType.Visible = false; if (!IsPostBack) { if (ShoppingCart.OrderCategory == OrderCategoryType.ETO) { trOrderType.Visible = false; trRemainingVal.Visible = false; ShoppingCart.SelectedDSSubType = "D2"; PurchasingLimitProvider.GetPurchasingLimits(DistributorID, "ETO"); return; } else { if (ShoppingCart.SelectedDSSubType == "ETO") { ShoppingCart.SelectedDSSubType = String.Empty; } } //lblPickupLocation.Visible = ddlPickup.Visible = false; bool noConsignmentOrdersAllowed = false; if (DSType.Equals("A") || DSType.Equals("B")) { if (APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale)) { noConsignmentOrdersAllowed = true; } } //Begin HD Ticket 406707 if (ShoppingCart.OrderSubType == "A2" || ShoppingCart.OrderSubType == "B2") { bool isAPFDue = APFDueProvider.IsAPFDueAndNotPaid(DistributorID, Locale) || APFDueProvider.IsAPFDueWithinOneYear(DistributorID, CountryCode) || APFDueProvider.IsAPFDueGreaterThanOneYear(DistributorID, CountryCode); if (!isAPFDue) { //delete APF SKU from cart ShoppingCart.DeleteItemsFromCart(APFDueProvider.GetAPFSkuList()); } } //End HD Ticket 406707 if (noConsignmentOrdersAllowed) { lbltext.Text = GetLocalResourceObject("CannotPlaceConsignmentWhileAPFDue") as string; lbltext.Visible = true; } ddl_DSSubType.Enabled = false; //ddlDelivery.Enabled = false; trRemainingVal.Visible = false; switch (DSType) { case "A": ddl_DSSubType.Items.Clear(); if (!HideEmptyListItem) { ddl_DSSubType.Items.Add(string.Empty); } if (!noConsignmentOrdersAllowed) { ddl_DSSubType.Items.Add(new ListItem("Vendita a Cliente ", "A1")); //TODOD: Resx these } ddl_DSSubType.Items.Add(new ListItem("Uso Personale", "A2")); ddl_DSSubType.Enabled = true; if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType)) { ddl_DSSubType.ClearSelection(); ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType); if (null != item) { item.Selected = true; lblOrderTypeVal.Text = item.Text; } //lblOrderTypeVal.Text = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType).Text; DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } break; case "B": ddl_DSSubType.Items.Clear(); if (!HideEmptyListItem) { ddl_DSSubType.Items.Add(string.Empty); } if (!noConsignmentOrdersAllowed) { ddl_DSSubType.Items.Add(new ListItem("Vendita a Cliente", "B1")); DisplayRemainingValues(ShoppingCart.SelectedDSSubType); } ddl_DSSubType.Items.Add(new ListItem("Uso Personale", "B2")); ddl_DSSubType.Enabled = true; if (!String.IsNullOrEmpty(ShoppingCart.SelectedDSSubType)) { ddl_DSSubType.ClearSelection(); ListItem item = ddl_DSSubType.Items.FindByValue(ShoppingCart.SelectedDSSubType); if (null != item) { item.Selected = true; lblOrderTypeVal.Text = item.Text; } DisplayRemainingValues(ShoppingCart.SelectedDSSubType); trRemainingVal.Visible = true; } break; case "C": case "D": case "D2": case "E": if (DSType == "D") { DSType = "D2"; } lblOrderType.Visible = false; lblOrderTypeVal.Text = "Uso Personale"; ddl_DSSubType.Visible = false; ddl_DSSubType.Items.Clear(); ddl_DSSubType.Items.Add(new ListItem(DSType, DSType)); ddl_DSSubType.SelectedIndex = 0; //ddl_DSSubType.Enabled = false; //ddl_DSSubType.Items.Add(DSType); //ddlDelivery.Enabled = true; break; } if (ddl_DSSubType.SelectedItem != null) { ShoppingCart.SelectedDSSubType = ddl_DSSubType.SelectedItem.Value; } if (DisplayStatic) { if (DSType.Equals("A") || DSType.Equals("B")) { ddl_DSSubType.Visible = false; lblOrderTypeVal.Visible = true; } else if (DSType.Equals("D") || DSType.Equals("D2") || DSType.Equals("E")) { DisplayRemainingValues(DSType); } } else { if (DSType.Equals("A") || DSType.Equals("B")) { ddl_DSSubType.Visible = true; lblOrderTypeVal.Visible = false; } else if (DSType.Equals("D") || DSType.Equals("D2") || DSType.Equals("E")) { DisplayRemainingValues(DSType); } } if (this.FOPEnabled) { var limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSType); if (limits != null && limits.LimitsRestrictionType == LimitsRestrictionType.FOP) { DisplayRemainingValues(DSType); } } } }