public int GetCurrentOrderMonth() { return(200000 + OrderMonth.GetCurrentOrderMonth()); }
public bool PurchasingLimitsAreExceeded(string distributorId, MyHLShoppingCart cart) { bool exceeded = false; if (cart.OrderCategory == OrderCategoryType.HSO) { return(exceeded); } if (CanPurchase) { // PurchasingLimits_V01 limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(distributorId); PurchasingLimits_V01 limits = GetPurchasingLimits(intOrderMonth(OrderMonth.GetCurrentOrderMonth())); if (limits == null || cart == null) { return(exceeded); } if (null != cart.Totals && cart.OrderCategory == OrderCategoryType.ETO) { return(exceeded); } if (null != limits && limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits && limits.PurchaseLimitType != PurchaseLimitType.None) { switch (limits.PurchaseLimitType) { case PurchaseLimitType.Earnings: { exceeded = limits.NextMaxEarningsLimit > -1 && ((limits.RemainingEarnings - cart.ProductEarningsInCart) < 0); break; } case PurchaseLimitType.Volume: { exceeded = limits.maxVolumeLimit > -1 && ((limits.RemainingVolume - cart.ProductVolumeInCart) < 0); break; } case PurchaseLimitType.DiscountedRetail: { exceeded = limits.maxVolumeLimit > -1 && ((limits.RemainingVolume - cart.ProductDiscountedRetailInCart) < 0); break; } case PurchaseLimitType.TotalPaid: { if (null != cart.Totals) { if (APFDueProvider.containsOnlyAPFSku(cart.ShoppingCartItems)) { return(exceeded); } exceeded = limits.maxVolumeLimit > -1 && ((limits.RemainingVolume - (cart.Totals as OrderTotals_V01).AmountDue) < 0); } break; } } } if (null != limits && limits.LimitsRestrictionType != LimitsRestrictionType.PurchasingLimits) { exceeded = ((limits.RemainingVolume - cart.VolumeInCart) < 0); if (exceeded) { cart.RuleResults = new List <ShoppingCartRuleResult>(); ShoppingCartRuleResult Result = new ShoppingCartRuleResult(); Result.RuleName = "PurchaseRestriction Rules"; Result.Result = RulesResult.Failure; Result.AddMessage(string.Format(HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "FOPVolumePointExceedsOnCheckout").ToString(), 1100, PurchaseRestrictionProvider.GetVolumeLimitsAfterFirstOrderFOP(_processingCountry), PurchaseRestrictionProvider.GetThresholdPeriod(_processingCountry), cart.VolumeInCart - limits.RemainingVolume)); cart.RuleResults.Add(Result); } } else if (exceeded) { cart.RuleResults = new List <ShoppingCartRuleResult>(); ShoppingCartRuleResult Result = new ShoppingCartRuleResult(); Result.RuleName = "PurchaseRestriction Rules"; Result.Result = RulesResult.Failure; Result.AddMessage(string.Format(HttpContext.GetGlobalResourceObject( string.Format("{0}_Rules", HLConfigManager.Platform), "RemainingVolumePointExceeds").ToString(), (cart.VolumeInCart - limits.RemainingVolume))); cart.RuleResults.Add(Result); } } else //member can't purchase { if ((cart.Totals as OrderTotals_V01).AmountDue > 0) //can't purchase and there are items in cart { exceeded = true; cart.RuleResults = new List <ShoppingCartRuleResult>(); ShoppingCartRuleResult Result = new ShoppingCartRuleResult(); Result.RuleName = "PurchaseRestriction Rules"; Result.Result = RulesResult.Failure; Result.AddMessage(string.Format(HttpContext.GetGlobalResourceObject( string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "CantBuy").ToString(), 1100, cart.DistributorID)); cart.RuleResults.Add(Result); } } return(exceeded); }