protected IPurchasingLimitManager PurchasingLimitManager(string distributorId) { IPurchasingLimitManagerFactory purchasingLimitManagerFactory = new PurchasingLimitManagerFactory(); var purchasingLimitManager = purchasingLimitManagerFactory.GetPurchasingLimitManager(distributorId); return(purchasingLimitManager); }
// FOP public static int GetOrderMonth(OrderMonth orderMonth, string distributorID, string countryCode) { DateTime current; if (HLConfigManager.Configurations.DOConfiguration.PurchasingLimitRestrictionType == PurchasingLimitRestrictionType.Annually || HLConfigManager.Configurations.DOConfiguration.PurchasingLimitRestrictionType == PurchasingLimitRestrictionType.Quarterly) { IPurchasingLimitManager manager = new PurchasingLimitManagerFactory().GetPurchasingLimitManager(distributorID); if (manager != null && (manager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan | IsMarketingPlanDistributor)) { current = orderMonth.CurrentOrderMonth; return(Int32.Parse(current.ToString("yyyyMM"))); } current = DateUtils.GetCurrentLocalTime(countryCode); } else { current = orderMonth.CurrentOrderMonth; } return(Int32.Parse(current.ToString("yyyyMM"))); }
public static int GetOrderMonth() { DateTime current; string countryCode = System.Threading.Thread.CurrentThread.CurrentCulture.Name.Substring(3); if (HLConfigManager.Configurations.DOConfiguration.PurchasingLimitRestrictionType == PurchasingLimitRestrictionType.Annually || HLConfigManager.Configurations.DOConfiguration.PurchasingLimitRestrictionType == PurchasingLimitRestrictionType.Quarterly) { string distributorID = ((MembershipUser <DistributorProfileModel>)Membership.GetUser()).Value.Id; IPurchasingLimitManager manager = new PurchasingLimitManagerFactory().GetPurchasingLimitManager(distributorID); if (manager != null && (manager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan | IsMarketingPlanDistributor)) { OrderMonth orderMonth = new OrderMonth(countryCode); current = orderMonth.CurrentOrderMonth; return(Int32.Parse(current.ToString("yyyyMM"))); } current = DateUtils.GetCurrentLocalTime(countryCode); } else { OrderMonth orderMonth = new OrderMonth(countryCode); current = orderMonth.CurrentOrderMonth; } return(Int32.Parse(current.ToString("yyyyMM"))); }
protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { decimal NewVolumePoints = 0m; decimal cartVolume = 0m; if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { CatalogItem_V01 currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country); if (currentItem == null) { return(Result); } List <string> codes = new List <string>(CountryType.SG.HmsCountryCodes); codes.Add(CountryType.SG.Key); var tins = DistributorOrderingProfileProvider.GetTinList(cart.DistributorID, true); IPurchasingLimitManager manager = new PurchasingLimitManagerFactory().GetPurchasingLimitManager(cart.DistributorID); if (!codes.Contains(DistributorProfileModel.ProcessingCountryCode)) // foreign DS { //Foreign DS without local National ID they cannot purchase "P" type products. if (tins != null && tins.Find(t => t.IDType.Key == "SNID") == null) { if (currentItem.ProductType == ServiceProvider.CatalogSvc.ProductType.Product) { Result.Result = RulesResult.Failure; Result.AddMessage(HttpContext.GetGlobalResourceObject(string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase").ToString()); cart.RuleResults.Add(Result); return(Result); } } //Foreign DS with local National ID they can purchase P L and A type items. } if (PurchasingLimitProvider.IsRestrictedByMarketingPlan(cart.DistributorID)) { return(base.PerformRules(cart, reason, Result)); } // DS with Dummy TIN No "S0000000S", can purchase any category of products up to 1100 vp per order if (tins != null && tins.Find(t => t.ID == "S0000000S") != null) { MyHLShoppingCart myCart = cart as MyHLShoppingCart; if (!string.IsNullOrEmpty(myCart.VolumeInCart.ToString())) { cartVolume = myCart.VolumeInCart; } 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); } else { return(Result); } } } return(Result); }
public IPurchasingLimitManager PurchasingLimitManager(string id) { IPurchasingLimitManagerFactory purchasingLimitManagerFactory = new PurchasingLimitManagerFactory(); return(purchasingLimitManagerFactory.GetPurchasingLimitManager(id)); }
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); }