private void CleanupCart(MyHLShoppingCart cart) { if (PurchasingLimitProvider.RequirePurchasingLimits(cart.DistributorID, cart.CountryCode)) { PurchasingLimitProvider.ReconcileAfterPurchase(cart, cart.DistributorID, Country); } if (null != HttpContext.Current) { var currentSession = SessionInfo.GetSessionInfo(cart.DistributorID, Locale); if (currentSession != null) { if (!String.IsNullOrEmpty(currentSession.OrderNumber)) { currentSession.OrderNumber = String.Empty; currentSession.OrderMonthShortString = string.Empty; currentSession.OrderMonthString = string.Empty; currentSession.ShippingMethodNameMX = String.Empty; currentSession.ShippingMethodNameUSCA = String.Empty; currentSession.ShoppingCart.CustomerOrderDetail = null; // currentSession.CustomerPaymentSettlementApproved = false; Commented out for merge. Need to investigate currentSession.CustomerOrderNumber = String.Empty; currentSession.CustomerAddressID = 0; } } //Clear the order month session... HttpContext.Current.Session["OrderMonthDataSessionKey"] = null; SessionInfo.SetSessionInfo(cart.DistributorID, Locale, currentSession); } ShoppingCartProvider.UpdateInventory(cart, Country, Locale, true); }
public PurchasingLimits ReloadPurchasingLimits(int orderMonth) { PurchasingLimits_V01 purchasingLimitsV01 = null; try { if (PurchasingLimitProvider.RequirePurchasingLimits(_distributorId, _currentLoggedInCountry)) { CreatePurchasingLimits(GetDistributorPurchasingLimitsCollection()); } if (PurchasingLimits == null) { return(purchasingLimitsV01); } if (orderMonth > 0) { SetPurchasingLimits(orderMonth); } SaveToCache(); } catch (Exception ex) { LoggerHelper.Error(ex.ToString()); } if (PurchasingLimits != null) { PurchasingLimits.TryGetValue(orderMonth, out purchasingLimitsV01); } return(purchasingLimitsV01); }
public void LoadPurchasingLimits() { if (PurchasingLimitProvider.RequirePurchasingLimits(_distributorId, _currentLoggedInCountry)) { if (PurchasingLimits == null) { CreatePurchasingLimits(GetDistributorPurchasingLimitsCollection()); } } }
private void CleanupOrder(MyHLShoppingCart cart, string distributorId) { if (!IsPostBack) { if (PurchasingLimitProvider.RequirePurchasingLimits(distributorId, _country)) { PurchasingLimitProvider.ReconcileAfterPurchase(cart, distributorId, _country); } if (cart != null) { // take out quantities from inventory ShoppingCartProvider.UpdateInventory(cart, cart.CountryCode, cart.Locale, true); } cart.CloseCart(); } }
public void RefreshVisibility(object sender, EventArgs e) { if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { if (null != _cart) { PurchasingLimits_V01 limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID); if (null != limits) { if (limits.PurchaseType == OrderPurchaseType.Consignment) { pnlAPFIsDueWithinYear.Visible = false; pnlAPFPaid.Visible = false; } SetPanelsVisibility(); } } } }
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(); //} } }
public DistributorOrderingProfile GetDistributorOrderingProfile(string id, string countryCode) { var distributorOrderingProfileCacheKey = string.Format("DO_DS_{0}", id); var expires = 15; int.TryParse(Settings.GetRequiredAppSetting("DistributorCacheExpireMinutes"), out expires); var orderingProfile = _cache.Retrieve(_ => CreateDistributorOrderingProfile(id, countryCode), distributorOrderingProfileCacheKey, TimeSpan.FromMinutes(expires)); if (orderingProfile.CurrentLoggedInCountry != countryCode) { if (orderingProfile.CurrentLoggedInCountry == "KR" | countryCode == "KR") { var distributor = _distributorLoader.Load(id, countryCode); if (distributor != null) { _distributorLoader.Expire(distributor, id, string.Empty); } _cache.Expire(typeof(DistributorOrderingProfile), distributorOrderingProfileCacheKey); orderingProfile = _cache.Retrieve(_ => CreateDistributorOrderingProfile(id, countryCode), distributorOrderingProfileCacheKey, TimeSpan.FromMinutes(expires)); } else { if (!Settings.GetRequiredAppSetting <bool>("FOPEnabled", false)) { //For other countries, we just update the existing cached distributor if (PurchasingLimitProvider.RequirePurchasingLimits(id, countryCode)) { IPurchasingLimitManagerFactory purchasingLimitManagerFactory = new PurchasingLimitManagerFactory(); purchasingLimitManagerFactory.GetPurchasingLimitManager(id).LoadPurchasingLimits(); } } } orderingProfile.CurrentLoggedInCountry = countryCode; } return(orderingProfile); }
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); }
protected override void OnUnload(EventArgs e) { base.OnUnload(e); if (!IsPostBack) { try { if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { PurchasingLimitProvider.ReconcileAfterPurchase(ShoppingCart, DistributorID, CountryCode); } var currentSession = SessionInfo.GetSessionInfo(DistributorID, Locale); if (currentSession != null) { if (!String.IsNullOrEmpty(currentSession.OrderNumber)) { ShoppingCart.OrderNumber = currentSession.OrderNumber; currentSession.OrderNumber = String.Empty; currentSession.OrderMonthShortString = string.Empty; currentSession.OrderMonthString = string.Empty; currentSession.ShippingMethodNameMX = String.Empty; currentSession.ShippingMethodNameUSCA = String.Empty; if (currentSession.ShoppingCart != null) { currentSession.ShoppingCart.CustomerOrderDetail = null; } currentSession.CustomerOrderNumber = String.Empty; currentSession.CustomerAddressID = 0; currentSession.ConfirmedAddress = false; currentSession.BRPF = String.Empty; currentSession.OrderStatus = SubmitOrderStatus.Unknown; currentSession.HmsPricing = false; currentSession.LocalPaymentId = string.Empty; currentSession.TrackingUrl = string.Empty; currentSession.SelectedPaymentChoice = string.Empty; if (null != currentSession.ShippingAddresses) { var customerAddress = currentSession.ShippingAddresses.Find(p => p.ID == currentSession.CustomerAddressID); if (customerAddress != null) { currentSession.ShippingAddresses.Remove(customerAddress); } } currentSession.IsHAPMode = false; } currentSession.IsAPFOrderFromPopUp = false; } //Clear the order month session... Session["OrderMonthDataSessionKey"] = null; ResolveAPF(); InsertIntoMLMOverrideTable(currentSession); SessionInfo.SetSessionInfo(DistributorID, Locale, currentSession); RemoveDupCheckCookie(); closeCart(); } catch (Exception ex) { LoggerHelper.Error( string.Format("Error in Confirm.aspx.cs : OnUnload error message: {0}; \r\n Stack Info: {1}", ex.GetBaseException().Message, ex.GetBaseException().StackTrace)); closeCart(); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { var _errors = new List <string>(); if (ShoppingCart != null) { if (ShoppingCart.Totals == null) { ShoppingCart.Calculate(); } // Set the order var order = OrderCreationHelper.CreateOrderObject(ShoppingCart) as Order_V01; order.DistributorID = DistributorID; order.CountryOfProcessing = CountryCode; order.ReceivedDate = DateUtils.GetCurrentLocalTime(CountryCode); order.OrderMonth = GetOrderMonthShortString(); order.OrderCategory = (OrderCategoryType) Enum.Parse(typeof(OrderCategoryType), HLConfigManager.Configurations.DOConfiguration.HFFModalOrderType); order.Shipment = OrderProvider.CreateShippingInfo(CountryCode, ShoppingCart); var provider = (Page as ProductsBase).GetShippingProvider(); (order.Shipment as ShippingInfo_V01).Address = ObjectMappingHelper.Instance.GetToOrder(provider.GetHFFDefaultAddress(ShoppingCart.DeliveryInfo.Address)); order.Handling = OrderProvider.CreateHandlingInfo(CountryCode, string.Empty, ShoppingCart, order.Shipment as ShippingInfo_V01); List <Payment> payments = null; if (PaymentOptions != null) { if (PaymentOptions.ValidateAndGetPayments(ObjectMappingHelper.Instance.GetToOrder(ShoppingCart.DeliveryInfo.Address.Address), out payments)) { if (payments != null && payments.Count > 0) { order.Payments = new PaymentCollection(); order.Payments.AddRange((from p in payments select p).ToArray()); } HLRulesManager.Manager.PerformTaxationRules(order, (Page as ProductsBase).Locale); if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { if (order.PurchasingLimits == null) { var limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID); if (null != limits) { limits.PurchaseSubType = ShoppingCart.SelectedDSSubType; order.PurchasingLimits = limits; order.PurchaseCategory = limits.PurchaseType; } } } order = OrderProvider.PopulateLineItems(CountryCode, order, ShoppingCart) as Order_V01; order.DiscountPercentage = (ShoppingCart.Totals as OrderTotals_V01).DiscountPercentage; var theOrder = OrderProvider.CreateOrder(order, ShoppingCart, CountryCode); List <FailedCardInfo> failedCards = null; string error = string.Empty; string orderID = OrderProvider.ImportOrder(theOrder, out error, out failedCards, ShoppingCart.ShoppingCartID); if (string.IsNullOrEmpty(error)) { // TODO: how to get auth token ShoppingCartProvider.UpdateShoppingCart(ShoppingCart, OrderProvider.SerializeOrder(theOrder, order, ShoppingCart, new Guid()), orderID, order.ReceivedDate); if (string.IsNullOrEmpty(order.OrderID)) { order.OrderID = orderID; order.Pricing = ShoppingCart.Totals; } if (!String.IsNullOrEmpty(ShoppingCart.EmailAddress)) { EmailHelper.SendEmail(ShoppingCart, order); } OrderSubmitted(order, orderID); // Handling UI lbOrderNumValue.Text = orderID; divPayment.Attributes.Add("class", string.Format("{0} hide", divSubmitCommand.Attributes["class"])); divPaymentSummary.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); //hide the PaymentSummary if the Payment choice for HFF Order is Wire if (SessionInfo.SelectedPaymentChoice == "WireTransfer") { divPaymentSummary.Attributes["class"] = "hide"; } else { divPaymentSummary.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); } divOrderComplete.Attributes["class"] = divOrderComplete.Attributes["class"].Replace("hide", string .Empty); divEmailNotification.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); divSubmitCommand.Attributes.Add("class", string.Format("{0} hide", divSubmitCommand.Attributes["class"])); divEndCommand.Attributes["class"] = divEndCommand.Attributes["class"].Replace("hide", string.Empty); if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { PurchasingLimitProvider.ReconcileAfterPurchase(ShoppingCart, DistributorID, CountryCode); } var currentSession = SessionInfo.GetSessionInfo(DistributorID, Locale); if (currentSession != null) { if (!String.IsNullOrEmpty(currentSession.OrderNumber)) { currentSession.OrderNumber = String.Empty; currentSession.OrderMonthShortString = string.Empty; currentSession.OrderMonthString = string.Empty; currentSession.ShippingMethodNameMX = String.Empty; currentSession.ShippingMethodNameUSCA = String.Empty; currentSession.ShoppingCart.CustomerOrderDetail = null; // currentSession.CustomerPaymentSettlementApproved = false; Commented out for Merge. Need to investigate currentSession.CustomerOrderNumber = String.Empty; currentSession.CustomerAddressID = 0; if (null != currentSession.ShippingAddresses) { var customerAddress = currentSession.ShippingAddresses.Find( p => p.ID == currentSession.CustomerAddressID); if (customerAddress != null) { currentSession.ShippingAddresses.Remove(customerAddress); } } } } //Clear the order month session... Session["OrderMonthDataSessionKey"] = null; SessionInfo.SetSessionInfo(DistributorID, Locale, currentSession); if (ShoppingCart != null) { // take out quantities from inventory ShoppingCartProvider.UpdateInventory(ShoppingCart, CountryCode, Locale, true); } ShoppingCart.CloseCart(); RecoverActiveCart(); onHFFOrderPlaced(this, new EventArgs()); } else { LoggerHelper.Error(error); if (error.Contains("AUTHORIZE PAYMENT")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "PaymenyFail")); } else if (error.Contains("TIMEOUT")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "Resubmit")); } else if (error.Contains("ORDER CANNOT BE FULFILLED FOR THE DISTRIBUTOR")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "CantOrder")); } else { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "TransactionFail")); } } } } } }