Ejemplo n.º 1
0
        public static Order FillOrderInfo(Order _order, MyHLShoppingCart shoppingCart)
        {
            Order_V01 order = _order as Order_V01;

            order.DistributorID = shoppingCart.DistributorID;
            order.Shipment      = GetShippingInfoFromCart(shoppingCart);
            order.InputMethod   = InputMethodType.Internet;
            var recvdDate = DateUtils.GetCurrentLocalTime(shoppingCart.Locale.Substring(3, 2));

            order.ReceivedDate = recvdDate;

            // TODO : Order CATEGORY
            order.OrderCategory =
                (ServiceProvider.OrderSvc.OrderCategoryType)Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType), shoppingCart.OrderCategory.ToString());
            //OrderCategoryType.RSO;
            if (order.OrderCategory == ServiceProvider.OrderSvc.OrderCategoryType.ETO)
            {
                if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType))
                {
                    order.OrderCategory =
                        (ServiceProvider.OrderSvc.OrderCategoryType)
                        Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType),
                                   HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType);
                }
            }

            var orderMonth = new OrderMonth(shoppingCart.CountryCode);

            order.OrderMonth = orderMonth.OrderMonthShortString;
            //order.OrderMonth = DateTime.Now.ToString("yyMM");

            order.UseSlidingScale     = HLConfigManager.Configurations.CheckoutConfiguration.UseSlidingScale;
            order.CountryOfProcessing = shoppingCart.CountryCode;

            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(shoppingCart.DistributorID, shoppingCart.CountryCode);

            if (null != distributorOrderingProfile)
            {
                //order.DiscountPercentage = order.UseSlidingScale && distributorOrderingProfile.StaticDiscount < 50
                //                               ? 0
                //                               : distributorOrderingProfile.StaticDiscount;
                order.DiscountPercentage = distributorOrderingProfile.StaticDiscount;  // always pass profile discount
            }
            if (HLConfigManager.Configurations.DOConfiguration.UsesDiscountRules)
            {
                HLRulesManager.Manager.PerformDiscountRules(shoppingCart, order, shoppingCart.Locale, ShoppingCartRuleReason.CartBeingCalculated);
            }
            if (HLConfigManager.Configurations.DOConfiguration.usesOrderManagementRules)
            {
                HLRulesManager.Manager.PerformOrderManagementRules(shoppingCart, order, shoppingCart.Locale, OrderManagementRuleReason.OrderFilled);
            }

            // some countries, like IT, need OrderSubType for correct Fusion pricing.
            // Added for User Story 226150
            if (HLConfigManager.Configurations.DOConfiguration.SaveDSSubType)
            {
                order.OrderSubType = shoppingCart.SelectedDSSubType;
            }
            return(order);
        }
        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")));
        }
        // 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 string GetOrderMonthString()
        {
            DateTime dtOrderMonth = new OrderMonth("JP").CurrentOrderMonth;

            return(dtOrderMonth.ToString("yyyyMM"));
        }
 // this is called from UI control
 public static PurchasingLimits_V01 GetPurchasingLimits(string distributorID, string TIN, string subtype = null)
 {
     if (Settings.GetRequiredAppSetting <bool>("FOPEnabled", false))
     {
         var currentSession = SessionInfo.GetSessionInfo(distributorID, Thread.CurrentThread.CurrentCulture.ToString());
         if (currentSession != null && currentSession.ShoppingCart != null)
         {
             return(FOP.PurchaseRestrictionProvider.GetPurchasingLimits(200000 + OrderMonth.GetCurrentOrderMonth(), distributorID, currentSession.ShoppingCart.OrderSubType));
         }
         else
         {
             return(FOP.PurchaseRestrictionProvider.GetPurchasingLimits(200000 + OrderMonth.GetCurrentOrderMonth(), distributorID, subtype));
         }
     }
     else
     {
         var purchasingLimits = GetPurchasingLimitsFromRulesEngine(distributorID, TIN);
         if (null != purchasingLimits && purchasingLimits.Count > 0)
         {
             return(purchasingLimits[GetOrderMonth()]);
         }
     }
     return(null);
 }