public void PurchasingLimitsTest_PH_Distributor()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-PH");
            var    target = new Ordering.Rules.PurchasingLimits.en_PH.PurchasingLimitRules();
            string DsId   = "37170799";
            string Local  = "en-PH";

            var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            MembershipUser  user      = Membership.GetUser(DsId);
            GenericIdentity identity  = new GenericIdentity(user.UserName);
            RolePrincipal   principal = new RolePrincipal(identity);

            System.Threading.Thread.CurrentPrincipal = principal;
            HttpContext.Current.User = principal;
            HttpRuntime.Cache.Insert("DISTR_" + DsId, distributor);
            var myHlShoppingCart = ShoppingCartProvider.GetShoppingCart(DsId, Local, false);

            myHlShoppingCart.CurrentItems = new ShoppingCartItemList();
            MyHLShoppingCartGenerator.PrepareAddToCart(myHlShoppingCart, ShoppingCartItemHelper.GetCartItem(1, 80, "0065"));
            var result = target.ProcessCart(myHlShoppingCart, ShoppingCartRuleReason.CartItemsBeingAdded);

            if (result.Count > 0 && result[0].Messages.Count == 0)
            {
                Assert.AreEqual(RulesResult.Unknown, result[0].Result);
            }
            else
            {
                Assert.Fail("Test Failed");
            }
        }
        public void ProcessCartTesten_US_CheckForHFFSKU_Fail()
        {
            const string DsId         = "1111111111";
            const string Local        = "en-US";
            var          testSettings = new OrderingTestSettings(Local, DsId);
            var          target       = new Ordering.Rules.CartIntegrity.en_US.CartIntegrityRules();

            var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "F356", Local)
            }, OrderCategoryType.ETO);

            var result = target.ProcessCart(
                cart, ShoppingCartRuleReason.CartWarehouseCodeChanged);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "Invalid sku found. DS: 1111111111, CART: 0, SKU F356 : removed from cart.");
            }
            else
            {
                Assert.Fail("Distributor can not add HFF Sku F356.");
            }
        }
Esempio n. 3
0
        protected void SetAPFDueDate(object sender, EventArgs e)
        {
            DateTime dueDate = DateTime.MinValue;

            try
            {
                if (DateTime.TryParse(txtDueDate.Text, out dueDate))
                {
                    DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode);
                    if (null != distributorOrderingProfile)
                    {
                        distributorOrderingProfile.ApfDueDate = dueDate;
                        // TODO : this is not necessary?
                        //DistributorProvider.UpdateDistributor(distributor);
                        lblStatus.Text = "Set to: " + dueDate.ToString("M/d/yyyy", CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        lblStatus.Text = "Distributor error";
                    }
                }
                else
                {
                    lblStatus.Text = "Date error";
                }
            }
            catch
            {
                lblStatus.Text = "Server Error";
            }

            DisplayData();
        }
        /// <summary>
        /// this is called when cart created or when cache expires
        /// </summary>
        /// <param name="purchaseRestrictionManager"></param>
        /// <param name="locale"></param>
        /// <param name="orderMonth"></param>
        /// <param name="distributorId"></param>
        /// <param name="orderSubType"></param>
        public virtual void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            //if (manager.PurchasingLimits == null)
            //    return;
            if (manager.ApplicableLimits == null)
            {
                return;
            }
            string processingCountryCode = DistributorProfileModel.ProcessingCountryCode;

            if ((manager.CanPurchase = CanPurchase(tins, processingCountryCode, Country)) == true)
            {
                manager.CanPurchasePType = CanPurchasePType(tins, processingCountryCode, Country);
            }
            else
            {
                manager.CanPurchasePType = false;
            }
            if (manager.CanPurchasePType == true && Settings.GetRequiredAppSetting <bool>("CheckGBNewMember", false))
            {
                if (processingCountryCode == "GB" && Country != "GB")
                {
                    DateTime currentLocalDatetime = HL.Common.Utilities.DateUtils.ConvertToLocalDateTime(DateTime.Now, Country);
                    if (currentLocalDatetime.Subtract(DistributorOrderingProfileProvider.GetProfile(distributorId, Country).ApplicationDate).TotalDays < 7)
                    {
                        manager.CanPurchase = false;
                    }
                }
            }

            if (processingCountryCode == "IN")
            {
                manager.ExtendRestrictionErrorMessage = new[] { "FB01", "FB02", "FB03", "FB04", "FB05", "FBL1", "FBL2", "FBL3", "FBL4", "FBL5", "FBOR" }.Intersect(from t in tins select t.IDType.Key).ToList().Count == 0;
            }
        }
        private string getEndDate(string distributorId, string countryCode)
        {
            var distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorId, countryCode);
            var endDate = distributorOrderingProfile.ApplicationDate.AddDays(7);

            return(endDate.ToShortDateString());
        }
        public void ProcessCartTestGlobal_DuplicateSKUs_Fail()
        {
            string DsId         = "1111111111";
            string Local        = "en-IN";
            var    testSettings = new OrderingTestSettings(Local, DsId);
            var    target       = new Ordering.Rules.CartIntegrity.Global.CartIntegrityRules();

            var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "1248", Local),
                ShoppingCartItemHelper.GetCatalogItems(1, 1, "1248", Local)
            }, OrderCategoryType.ETO);

            var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartCalculated);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "Duplicate sku found. DS: 1111111111, CART: 0, SKU 1248 removed from cart.");
            }
            else
            {
                Assert.Fail("SKU 1248 is dupliacte.it should be removed from the cart");
            }
        }
        public void PurchasingLimitsTest_PH_ForeignDistributor_Fail()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-PH");
            var    target      = new Ordering.Rules.PurchasingLimits.en_PH.PurchasingLimitRules();
            string DsId        = "WEBTEST1";
            string Local       = "en-PH";
            var    distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            MembershipUser  user      = Membership.GetUser(DsId);
            GenericIdentity identity  = new GenericIdentity(user.UserName);
            RolePrincipal   principal = new RolePrincipal(identity);

            System.Threading.Thread.CurrentPrincipal = principal;
            HttpContext.Current.User = principal;
            HttpRuntime.Cache.Insert("DISTR_" + DsId, distributor);
            var myHlShoppingCart = ShoppingCartProvider.GetShoppingCart(DsId, Local, false);

            myHlShoppingCart.CurrentItems = new ShoppingCartItemList();
            MyHLShoppingCartGenerator.PrepareAddToCart(myHlShoppingCart, ShoppingCartItemHelper.GetCartItem(1, 80, "0065"));
            var result = target.ProcessCart(myHlShoppingCart, ShoppingCartRuleReason.CartItemsBeingAdded);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "Item SKU:0065 has not been added to the cart since by adding that into the cart, you exceeded your volume points  limit.");
            }
            else
            {
                Assert.Fail("Test Failed");
            }
        }
Esempio n. 8
0
        private List <MyHLShoppingCartView> GetOrdersByOrderNumber(string memberId, string locale, string orderNumber,
                                                                   DateTime startDate, DateTime endDate)
        {
            var shoppingCartViews = new List <MyHLShoppingCartView>();

            if (!string.IsNullOrEmpty(orderNumber))
            {
                var customerProfileId =
                    DistributorOrderingProfileProvider.GetProfile(memberId, locale.Substring(3, 2)).CNCustomorProfileID;
                var shoppingCartView = new MyHLShoppingCartView();

                var proposedStartDate = DateTime.Now.AddMonths(-12);
                //DateTime startDate = new DateTime(proposedStartDate.Year, proposedStartDate.Month, proposedStartDate.Day); //ensure the time is the start of the day, which is 00:00:00
                //DateTime endDate = DateTime.Now;

                shoppingCartViews = shoppingCartView.GetOrdersWithDetail(memberId, customerProfileId, locale, startDate,
                                                                         endDate, OrderStatusFilterType.All, "", "", false, false, orderNumber);

                if (shoppingCartViews.Count > 0)
                {
                    return(shoppingCartViews.FindAll(oi => oi.OrderNumber == orderNumber));
                }
            }

            return(shoppingCartViews);
        }
        public void ProcessCartTestNonWebClient_Invalidquantity_Fail()
        {
            const string DsId         = "1111111111";
            const string Local        = "en-AU";
            var          testSettings = new OrderingTestSettings(Local, DsId);
            var          target       = new Ordering.Rules.CartIntegrity.NonWebClient.CartIntegrityRules();

            var distributor = DistributorOrderingProfileProvider.GetProfile(DsId, Local.Substring(3));

            HttpRuntime.Cache.Insert("DISTR_" + testSettings.Distributor, distributor);
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart(
                DsId, Local, "", "", false, null, new List <DistributorShoppingCartItem>
            {
                ShoppingCartItemHelper.GetCatalogItems(1, 200, "0124", Local)
            }, OrderCategoryType.ETO);

            cart.ShoppingCartID = 1;

            var result = target.ProcessCart(cart, ShoppingCartRuleReason.CartItemsBeingAdded);

            if (result.Count > 0 && result[0].Messages.Count > 0)
            {
                Assert.AreEqual(result[0].Messages[0],
                                "The quantity of SKU 0124 is not valid.");
            }
            else
            {
                Assert.Fail("May be the quantity 200 for the sku 0124 is valid for Australia.");
            }
        }
Esempio n. 10
0
        private void ReadFromData()
        {
            DistributorOrderingProfile distributorOrderingProfile =
                DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode);

            _distributorId = DistributorID;
            _apfDueDate    = distributorOrderingProfile.ApfDueDate;
            if (_testing)
            {
                APFDueProvider.UpdateAPFDuePaid(_distributorId, _apfDueDate);
            }
            _apfSku                   = APFDueProvider.GetAPFSku();
            _cart                     = (Page as ProductsBase).ShoppingCart;
            _apfIsDue                 = APFDueProvider.IsAPFDueAndNotPaid(_distributorId, HLConfigManager.Configurations.Locale);
            _apfDueWithinOneYear      = APFDueProvider.IsAPFDueWithinOneYear(_distributorId, CountryCode);
            _apfDueGreaterThanOneYear = APFDueProvider.IsAPFDueGreaterThanOneYear(_distributorId, CountryCode);
            if (_apfIsDue)
            {
                _apfsDue = APFDueProvider.APFQuantityDue(_distributorId, HLConfigManager.Configurations.Locale);
            }
            List <ShoppingCartItem_V01> item = (from c in _cart.CartItems where c.SKU == _apfSku select c).ToList();

            _apfsInCart = 0;
            if (item.Count > 0)
            {
                _apfsInCart = item[0].Quantity;
            }
        }
        private ShoppingCartRuleResult CartRetrievedRuleHandler(ShoppingCart_V01 cart,
                                                                ShoppingCartRuleResult result)
        {
            var sessioninfo = SessionInfo.GetSessionInfo(cart.DistributorID, cart.Locale);
            var distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, "CN");

            if (sessioninfo != null && distributorOrderingProfile != null)
            {
                if (sessioninfo.IsEventTicketMode)
                {
                    if (sessioninfo.IsReplacedPcOrder)
                    {
                        var shoppingCart = cart as MyHLShoppingCart;
                        var items        = new List <string>();
                        if (cart.CartItems != null)
                        {
                            items.AddRange(cart.CartItems.Select(item => item.SKU));
                        }
                        if (items.Any())
                        {
                            if (shoppingCart != null)
                            {
                                shoppingCart.DeleteItemsFromCart(items, true);
                            }
                        }
                    }
                }
            }
            return(result);
        }
        public void PerformTaxationRules(Order_V01 order, string locale)
        {
            if (null != order)
            {
                var limits = order.PurchasingLimits as PurchasingLimits_V01;
                if (null == limits)
                {
                    limits =
                        PurchasingLimitProvider.GetCurrentPurchasingLimits(order.DistributorID);
                    order.PurchasingLimits = limits;
                }
                if (null == limits)
                {
                    //Log an error here - can't tax this, it is invalid for IT if we don't have Limits created
                }
                else
                {
                    //Add suplemental items for Incaricato VAT and INPS calcs
                    limits.Items = new SupplementalItems();
                    limits.Items.Add("ConsignmentWitholdingRate", new List <decimal>(new[] { 0.1794M }));
                    //Both A1 and B1
                    limits.Items.Add("FlatFreightRate", new List <decimal>(new[] { 0.045M }));
                    if (!string.IsNullOrEmpty(limits.PurchaseSubType) && limits.PurchaseSubType.Equals("A1"))
                    //VAT Registered
                    {
                        DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(order.DistributorID, Country);
                        //Calcualte the INPS contribution for A1
                        if (distributorOrderingProfile.YTDEarnings > limits.MaxEarningsLimit &&
                            distributorOrderingProfile.YTDEarnings <=
                            HLConfigManager.Configurations.DOConfiguration.MaxTaxableEarnings)
                        {
                            var taxIds = DistributorOrderingProfileProvider.GetTinList(order.DistributorID, true);
                            if (taxIds.Count > 0 &&
                                taxIds.Where(
                                    p =>
                                    p.IDType.Key.Equals("IEVA") & p.IDType.Key.Equals("ITIN") &
                                    p.IDType.Key.Equals("ITSS")).Count() > 0)
                            {
                                limits.Items.Add("INPSContributionRate", new List <decimal>(new[] { 0.0442M }));
                            }
                            else
                            {
                                limits.Items.Add("INPSContributionRate", new List <decimal>(new[] { 0.0695M }));
                            }
                        }
                        else
                        {
                            limits.Items.Add("INPSContributionRate", new List <decimal>(new[] { 0M }));
                        }
                        limits.Items.Add("VATReimbursementRate", new List <decimal>(new[] { 0.20M }));
                    }
                }

                CheckforMultipleDuplicateLinkedSkus(order);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (member != null)
            {
                var user = member.Value;
                _distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(user.Id, "CN");
            }
        }
        void ValidateMaxQtyDependsOnSpouseName(Dictionary <int, SKU_V01> eventProductList, ShoppingCart_V01 cart, ref ShoppingCartRuleResult result, out Dictionary <int, SKU_V01> eligibleEventProductList)
        {
            int maxAllowed = 0;

            string[] words       = null;
            int      Quantity    = 0;
            string   eligibleSKu = string.Empty;


            var allreadypurchasedEventTicktList = _iEventTicketProviderLoader.LoadSkuPurchasedCount(eventProductList, cart.DistributorID, Locale.Substring(3));
            var user = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, this.Country);
            var rsp  = MyHerbalife3.Ordering.Providers.China.OrderProvider.GetEventEligibility(cart.DistributorID);

            if (rsp != null && rsp.IsEligible)
            {
                words = rsp.Remark.Split('|');

                Quantity    = Convert.ToInt32(words[words.Length - 1]);
                eligibleSKu = words[words.Length - 2];
            }
            var MaxEventTicketPerUser = Convert.ToInt32(HL.Common.Configuration.Settings.GetRequiredAppSetting("MaxEventTicketPerUser"));

            if (Quantity > 0 && Enumerable.Range(1, MaxEventTicketPerUser).Contains(Quantity))
            {
                maxAllowed = Quantity;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(user.SpouseLocalName))
                {
                    maxAllowed = 1;
                }
                else
                {
                    maxAllowed = 2;
                }
            }
            var CheckEventTicket = eventProductList.Any(p => p.Value.SKU == eligibleSKu);

            if (CheckEventTicket)
            {
                eligibleEventProductList = _iEventTicketProviderLoader.ValidateEventList(eventProductList, allreadypurchasedEventTicktList, maxAllowed, ref result);
            }
            else
            {
                maxAllowed = 0;
                eligibleEventProductList = new Dictionary <int, SKU_V01>();
                result.Result            = RulesResult.Failure;
                var msg = GetRulesResourceString("YouAreNotEligibleForEvent");
                result.AddMessage(msg);
            }
        }
        public override void SetPurchaseRestriction(List <TaxIdentification> tins, int orderMonth, string distributorId, IPurchaseRestrictionManager manager)
        {
            var limits = GetLimits(LimitsRestrictionType.PurchasingLimits, orderMonth, manager);

            if (limits == null)
            {
                return;
            }

            DistributorOrderingProfile orderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorId, "FR");

            limits.PurchaseLimitType = orderingProfile.OrderSubType == "F" ? PurchaseLimitType.Volume : PurchaseLimitType.None;
            base.SetPurchaseRestriction(tins, orderMonth, distributorId, manager);
            SetLimits(orderMonth, manager, limits);
        }
        private void ResolveAPF(MyHLShoppingCart cart)
        {
            if (APFDueProvider.IsAPFSkuPresent(cart.CartItems))
            {
                int payedApf       = APFDueProvider.APFQuantityInCart(cart);
                var currentDueDate = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, cart.CountryCode).ApfDueDate;
                var newDueDate     = currentDueDate + new TimeSpan(payedApf * 365, 0, 0, 0);
                DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, cart.CountryCode).ApfDueDate = newDueDate;

                //TODO : what to do
                //DistributorProvider.UpdateDistributor(ods);
                Session.Add("apfdue", newDueDate);
                APFDueProvider.UpdateAPFDuePaid(cart.DistributorID, newDueDate);
            }
        }
Esempio n. 17
0
        private List <MyHLShoppingCartView> GetOrderList(string memberId, string locale, DateTime?from, DateTime?to,
                                                         bool check3Months = false)
        {
            var shoppingCartView  = new MyHLShoppingCartView();
            var customerProfileId =
                DistributorOrderingProfileProvider.GetProfile(memberId, locale.Substring(3, 2)).CNCustomorProfileID;
            var filterExpressions = string.Empty;
            var sortExpressions   = string.Empty;
            var countryCode       = locale.Substring(3, 2);
            var localNow          = DateUtils.GetCurrentLocalTime(countryCode);

            if (check3Months)
            {
                from = localNow.AddMonths(-3);
                to   = localNow;
            }
            else
            {
                if (!from.HasValue)
                {
                    if (to.HasValue)
                    {
                        from = to.Value.AddMonths(-3);
                    }
                    else
                    {
                        from = localNow.AddMonths(-3);
                    }
                }

                if (!to.HasValue)
                {
                    if (from.HasValue)
                    {
                        to = from.Value.AddMonths(3);
                    }
                    else
                    {
                        to = localNow;
                    }
                }
            }

            var result = shoppingCartView.GetOrdersWithDetail(memberId, customerProfileId, locale, from.Value, to.Value,
                                                              OrderStatusFilterType.All, "", "");

            return(result);
        }
        public List <string> PerformValidateDistributorRules(string DistributorID)
        {
            List <string> errors = null;
            //OnlineDistributor ods =  DistributorProvider.GetDistributor(DistributorID);
            DistributorOrderingProfile ods = DistributorOrderingProfileProvider.GetProfile(DistributorID, Country);

            if (ods != null)
            {
                if (ods.CantBuy)
                {
                    return(errors = new List <string> {
                        string.Format(HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "CantBuy").ToString())
                    });
                }
            }
            return(errors);
        }
        protected void OnYes(object sender, EventArgs e)
        {
            var member             = (MembershipUser <DistributorProfileModel>)Membership.GetUser();
            var currentSessionInfo = SessionInfo.GetSessionInfo(member.Value.Id, CultureInfo.CurrentCulture.Name);

            currentSessionInfo.TrainingBreached = true;
            if (null != pnlMessageBox)
            {
                pnlMessageBox.Visible = false;
            }

            DistributorOrderingProfile dsProfile = DistributorOrderingProfileProvider.GetProfile(member.Value.Id,
                                                                                                 member.Value
                                                                                                 .ProcessingCountryCode);

            dsProfile.CantBuyOverride = true;
        }
 public PayByPhoneResponseViewModel IsEligible(string memberId, string countryCode)
 {
     try
     {
         var orderingProfile = DistributorOrderingProfileProvider.GetProfile(memberId, countryCode);
         int learningPoint   = OrderProvider.GetAccumulatedPCLearningPoint(memberId, "pcpoint");
         if (orderingProfile != null)
         {
             return(new PayByPhoneResponseViewModel {
                 Enabled = orderingProfile.IsPayByPhoneEnabled, LearningPoint = learningPoint
             });
         }
     }
     catch (Exception ex)
     {
         LoggerHelper.Exception("General", ex);
     }
     return(null);
 }
Esempio n. 21
0
        public override bool DistributorIsExemptFromPurchasingLimits(string distributorId)
        {
            bool isExempt = base.DistributorIsExemptFromPurchasingLimits(distributorId);

            if (!isExempt)
            {
                return(false);
            }

            //French SS imposed PC limits
            var profile = DistributorOrderingProfileProvider.GetProfile(distributorId, Country);

            if (profile != null)
            {
                return(profile.OrderSubType != "F");
            }

            return(isExempt);
        }
Esempio n. 22
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ddlMemberID.SelectedValue))
            {
                //Need to display user friendly mesage, will take up in the next iteration
                return;
            }
            ILoader <DistributorProfileModel, GetDistributorProfileById> distributorProfileLoader = new DistributorProfileLoader();
            var distributorProfileModel = distributorProfileLoader.Load(new GetDistributorProfileById {
                Id = ddlMemberID.SelectedValue
            });
            var pcDistInfo     = DistributorOrderingProfileProvider.GetProfile(ddlMemberID.SelectedValue, CountryCode);
            var currentSession = Providers.SessionInfo.GetSessionInfo(DistributorID, Locale);

            currentSession.ReplacedPcDistributorProfileModel    = distributorProfileModel;
            currentSession.ReplacedPcDistributorOrderingProfile = pcDistInfo;
            currentSession.IsReplacedPcOrder = true;
            base.ShoppingCart.SrPlacingForPcOriginalMemberId = currentSession.ReplacedPcDistributorOrderingProfile.Id;
            Providers.SessionInfo.SetSessionInfo(DistributorID, Locale, currentSession);
            var allSKU       = CatalogProvider.GetAllSKU(Locale);
            var SKUsToRemove = new List <string>();

            foreach (var cartitem in ShoppingCart.CartItems)
            {
                SKU_V01 PrmoSku;

                allSKU.TryGetValue(cartitem.SKU, out PrmoSku);
                if (PrmoSku != null)
                {
                    if (!PrmoSku.IsPurchasable)
                    {
                        SKUsToRemove.Add(PrmoSku.SKU.Trim());
                    }
                }
            }
            Array.ForEach(SKUsToRemove.ToArray(),
                          a => ShoppingCart.CartItems.Remove(ShoppingCart.CartItems.Find(x => x.SKU == a)));
            Array.ForEach(SKUsToRemove.ToArray(),
                          a => ShoppingCart.ShoppingCartItems.Remove(ShoppingCart.ShoppingCartItems.Find(x => x.SKU == a)));

            Response.Redirect("PriceList.aspx?ETO=False");
        }
 public void PerformOrderManagementRules(ShoppingCart_V02 cart, Order_V01 order, string locale, OrderManagementRuleReason reason)
 {
     if (reason == OrderManagementRuleReason.OrderFilled)
     {
         if (order.PurchasingLimits != null)
         {
             var limits = (order.PurchasingLimits as PurchasingLimits_V01);
             if (limits != null && string.IsNullOrEmpty(limits.PurchaseSubType))
             {
                 var myHLCart = cart as MyHLShoppingCart;
                 if (myHLCart != null && string.IsNullOrEmpty(myHLCart.SelectedDSSubType))
                 {
                     limits.PurchaseSubType = myHLCart.SelectedDSSubType;
                 }
                 else
                 {
                     var dsProfile = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, order.CountryOfProcessing);
                     limits.PurchaseSubType = dsProfile.OrderSubType;
                 }
             }
         }
     }
 }
Esempio n. 24
0
 private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart,
                                             ShoppingCartRuleReason reason,
                                             ShoppingCartRuleResult Result)
 {
     if (reason == ShoppingCartRuleReason.CartItemsBeingAdded)
     {
         try
         {
             if (!CanPurchase(cart.DistributorID, Country))
             {
                 Result.Result = RulesResult.Failure;
                 Result.AddMessage(
                     HttpContext.GetGlobalResourceObject(
                         string.Format("{0}_Rules", HLConfigManager.Platform), "CantPurchase").ToString());
                 cart.RuleResults.Add(Result);
                 return(Result);
             }
             DateTime currentLocalDatetime = HL.Common.Utilities.DateUtils.ConvertToLocalDateTime(DateTime.Now, Country);
             if (currentLocalDatetime.Subtract(DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, Country).ApplicationDate).TotalHours < 24)
             {
                 Result.Result = RulesResult.Failure;
                 Result.AddMessage(
                     HttpContext.GetGlobalResourceObject(
                         string.Format("{0}_Rules", HLConfigManager.Platform), "CroatiaNewMemberError").ToString());
                 cart.RuleResults.Add(Result);
             }
         }
         catch (Exception ex)
         {
             LoggerHelper.Error(
                 string.Format(
                     "Error while performing Add to Cart Rule for Chilean distributor: {0}, Cart Id:{1}, \r\n{2}",
                     cart.DistributorID, cart.ShoppingCartID, ex));
         }
     }
     return(Result);
 }
Esempio n. 25
0
        /// <summary>
        /// Returns true if ordered quantity is within limit.
        /// </summary>
        /// <param name="eventProductList"></param>
        /// <param name="cart"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        bool ValidateMaxQtyDependsOnSpouseName(CartItemWithDetailList eventProductList, ShoppingCart_V02 cart, ShoppingCartRuleResult result)
        {
            bool ret = true;

            LoadSkuPurchasedCount(eventProductList, cart.DistributorID);

            foreach (var item in eventProductList)
            {
                if (item.TotalQty <= MaxQtyIfNoSpouseName)
                {
                    continue;
                }

                RulesResult rslt  = RulesResult.Unknown;
                string      msg   = null;
                int         limit = 0;

                var user = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, this.Country);
                if (string.IsNullOrWhiteSpace(user.SpouseLocalName))
                {
                    #region no spouse name
                    limit = MaxQtyIfNoSpouseName;

                    if (item.TotalQty > limit)
                    {
                        DeductEventProductQty(item, limit, cart);

                        rslt = (item.CurrentItem.Quantity <= 0) ? RulesResult.Failure : RulesResult.Feedback;

                        msg = GetRulesResourceString("EventProductLimitedToNAsNoSpouseName");
                        msg = string.Format(msg, item.SKU.Product.DisplayName, limit);
                    }
                    #endregion
                }
                else
                {
                    #region has spouse name
                    limit = MaxQtyIfHasSpouseName;
                    if (item.TotalQty > limit)
                    {
                        DeductEventProductQty(item, limit, cart);

                        rslt = (item.CurrentItem.Quantity <= 0) ? RulesResult.Failure : RulesResult.Feedback;

                        msg = GetRulesResourceString("EventProductLimitedToNAsHasSpouseName");
                        msg = string.Format(msg, item.SKU.Product.DisplayName, limit);
                    }
                    #endregion
                }

                if (rslt != RulesResult.Unknown)
                {
                    ret           = false;
                    result.Result = rslt;

                    if (item.QuantityAlreadyPurchased >= limit)
                    {
                        msg = GetRulesResourceString("EventProductAlreadyBeenPurchased");
                        msg = string.Format(msg, item.SKU.Product.DisplayName);
                    }

                    result.Messages.Add(msg);
                }

                LoggingTrace(string.Format("ValidateMaxQtyDependsOnSpouseName: {0}, {1}", rslt, msg));
            }

            return(ret);
        }
        /// <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);
        }
Esempio n. 27
0
        private void DoApfDue(string distributorID,
                              ShoppingCart_V01 result,
                              string cacheKey,
                              string locale,
                              bool cartHasItems,
                              ShoppingCartRuleResult ruleResult,
                              bool justEntered)
        {
            var cart = result as MyHLShoppingCart;

            if (cart == null)
            {
                return;
            }

            try
            {
                string level;
                if (DistributorProfileModel != null)
                {
                    level = DistributorProfileModel.TypeCode.ToUpper();
                }
                else
                {
                    level = GetMemberLevelFromDistributorProfile(cart.DistributorID);
                }

                var distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID,
                                                                                               cart.CountryCode);
                if ((distributorOrderingProfile.HardCashOnly &&
                     !HLConfigManager.Configurations.PaymentsConfiguration.AllowWireForHardCash))
                {
                    return;
                }
                var apfItems = new List <ShoppingCartItem_V01>();
                if (cart.CartItems != null && cart.CartItems.Count > 0)
                {
                    //Stash off all non-APF items - to be re-added if appropriate
                    var nonApfItems =
                        (from c in cart.CartItems where APFDueProvider.IsAPFSku(c.SKU.Trim()) == false select c)
                        .ToList <ShoppingCartItem_V01>();
                    apfItems =
                        (from c in cart.CartItems where APFDueProvider.IsAPFSku(c.SKU.Trim()) select c)
                        .ToList <ShoppingCartItem_V01>();
                    if (nonApfItems.Count > 0 ||
                        HLConfigManager.Configurations.APFConfiguration.StandaloneAPFOnlyAllowed)
                    {
                        // Clear the cart
                        cart.DeleteItemsFromCart(null, true);
                        //if (APFDueProvider.CanEditAPFOrder(distributorID, locale, level))
                        //{
                        //Global rule - they can always edit the cart ie add remove products at least
                        var list =
                            CatalogProvider.GetCatalogItems((from p in nonApfItems select p.SKU).ToList(), Country);
                        var products =
                            (from c in list where c.Value.ProductType == ProductType.Product select c.Value.SKU).ToList();
                        var nonproducts =
                            (from c in list where c.Value.ProductType != ProductType.Product select c.Value.SKU).ToList();
                        if (!HLConfigManager.Configurations.APFConfiguration.AllowNonProductItemsWithStandaloneAPF)
                        //We don't allow non product items alone on an apf order
                        {
                            if (products.Count == 0)
                            {
                                if (nonproducts.Count > 0)
                                {
                                    ruleResult.Result = RulesResult.Success;
                                    ruleResult.AddMessage(
                                        HttpContext.GetGlobalResourceObject(
                                            string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                                            "NonProductItemsRemovedForStandaloneAPF") as string);
                                    cart.RuleResults.Add(ruleResult);
                                }
                            }
                            else
                            {
                                cart.AddItemsToCart(nonApfItems, true);
                            }
                        }
                        else
                        {
                            if (!HLConfigManager.Configurations.APFConfiguration.StandaloneAPFOnlyAllowed)
                            {
                                cart.AddItemsToCart(nonApfItems, true);
                            }
                        }
                    }
                }
                else if (null != cart && null != cart.RuleResults)
                {
                    var rules =
                        (from rule in cart.RuleResults
                         where rule.RuleName == RuleName && rule.Result == RulesResult.Failure
                         select rule);
                    if (null != rules && rules.Count() > 0)
                    {
                        cart.RuleResults.Remove(rules.First());
                    }
                }

                //Add the APF in
                var apfSku = new List <ShoppingCartItem_V01>();
                var sku    = APFDueProvider.GetAPFSku();
                apfSku.Add(new ShoppingCartItem_V01(0, sku, 1, DateTime.Now));
                if (!cart.APFEdited)
                {
                    apfSku[0].Quantity = 1; //CalcQuantity(distributorOrderingProfile.ApfDueDate);
                    if (cart.CartItems.Exists(c => c.SKU == apfSku[0].SKU))
                    {
                        var apf =
                            (from a in cart.CartItems where a.SKU == apfSku[0].SKU select a).First();
                        cart.DeleteItemsFromCart(
                            (from a in cart.CartItems where a.SKU == apfSku[0].SKU select a.SKU).ToList(), true);
                    }
                    if (cart.CartItems.Count == 0) //This is now a Standalone APF
                    {
                        SetAPFDeliveryOption(cart);
                    }
                    cart.AddItemsToCart(apfSku, true);

                    if (justEntered)
                    {
                        ruleResult.AddMessage(
                            HttpContext.GetGlobalResourceObject(
                                string.Format("{0}_ErrorMessage", HLConfigManager.Platform), "APFDueAdded") as string);
                        ruleResult.Result = RulesResult.Success;

                        SetApfRuleResponse(ruleResult, ApfAction.None, sku, "ApfRule", TypeOfApf.CantDSRemoveAPF,
                                           "APFDueAdded");

                        cart.RuleResults.Add(ruleResult);
                    }
                    else
                    {
                        foreach (ShoppingCartRuleResult r in cart.RuleResults)
                        {
                            if (r.RuleName == RuleName)
                            {
                                r.Messages.Clear();
                                r.AddMessage(string.Empty);
                            }
                        }
                    }
                }
                //else
                //{
                //    if (APFDueProvider.CanRemoveAPF(distributorID, locale, level))
                //    {
                //        cart.AddItemsToCart(apfSku, true);
                //    }
                //}
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("doAPFDue DS:{0} ERR:{1}", distributorID, ex));
            }
        }
Esempio n. 28
0
        /// <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)
        {
            var dpm = DistributorProfileModel;

            CurrentSession = (dpm != null)
                ? SessionInfo.GetSessionInfo(dpm.Id, Locale)
                : SessionInfo.GetSessionInfo(cart.DistributorID, Locale);
            string dsid = string.Empty;

            if (CurrentSession.IsReplacedPcOrder)
            {
                dsid = CurrentSession.ReplacedPcDistributorOrderingProfile != null && CurrentSession.ReplacedPcDistributorOrderingProfile.Id != null ? CurrentSession.ReplacedPcDistributorOrderingProfile.Id : cart.DistributorID;
            }
            else
            {
                dsid = cart.DistributorID;
            }
            //   OrderTotals_V01 totals = (OrderTotals_V01)(cart as MyHLShoppingCart).Totals;
            if (reason == ShoppingCartRuleReason.CartItemsBeingAdded || reason == ShoppingCartRuleReason.CartRetrieved)
            {
                var Cart           = cart as MyHLShoppingCart;
                var calcTheseItems = new List <ShoppingCartItem_V01>();

                var purchasingLimitManager = PurchasingLimitManager(dsid);
                var myhlCart = cart as MyHLShoppingCart;

                if (null == myhlCart)
                {
                    LoggerHelper.Error(
                        string.Format("{0} myhlCart is null {1}", Locale, dsid));
                    Result.Result = RulesResult.Failure;
                    return(Result);
                }

                PurchasingLimits_V01 PurchasingLimits =
                    PurchasingLimitProvider.GetCurrentPurchasingLimits(dsid);

                purchasingLimitManager.SetPurchasingLimits(PurchasingLimits);


                if (null == PurchasingLimits)
                {
                    LoggerHelper.Error(
                        string.Format("{0} PurchasingLimits could not be retrieved for distributor {1}", Locale,
                                      dsid));
                    Result.Result = RulesResult.Failure;
                    return(Result);
                }

                var shoppingCart = cart as MyHLShoppingCart;
                if (shoppingCart == null)
                {
                    return(Result);
                }

                if (PurchasingLimits.MaxPCEarningsLimit == -1)
                {
                    return(Result);
                }
                DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, "CN");
                if ((CurrentSession.ReplacedPcDistributorOrderingProfile != null && CurrentSession.ReplacedPcDistributorOrderingProfile.IsPC) || (distributorOrderingProfile != null && distributorOrderingProfile.IsPC))
                {
                    if (cart.CurrentItems != null)
                    {
                        calcTheseItems.AddRange(from i in cart.CurrentItems
                                                where !APFDueProvider.IsAPFSku(i.SKU)
                                                select
                                                new ShoppingCartItem_V01(i.ID, i.SKU, i.Quantity, i.Updated,
                                                                         i.MinQuantity));
                    }
                    if (cart.CartItems != null)
                    {
                        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 totals = Cart.Calculate(calcTheseItems, false) as OrderTotals_V01;

                    //OrderTotals_V01 totals = (OrderTotals_V01)(cart as MyHLShoppingCart).Totals;
                    if (totals != null && totals.DiscountedItemsTotal > purchasingLimitManager.MaxPersonalPCConsumptionLimit)
                    {
                        if (cart.CurrentItems.Count > 0)
                        {
                            var sessionInfo = SessionInfo.GetSessionInfo(cart.DistributorID, Locale);
                            if (sessionInfo != null && sessionInfo.ShoppingCart != null && sessionInfo.ShoppingCart.CurrentItems != null)
                            {
                                sessionInfo.ShoppingCart.CurrentItems.RemoveAll(x => x.SKU != null);
                            }
                            cart.CurrentItems.RemoveAll(s => s.SKU != null);
                        }
                        Result.Result = RulesResult.Failure;
                        Result.AddMessage(
                            string.Format(
                                HttpContext.GetGlobalResourceObject(
                                    string.Format("{0}_Rules", HLConfigManager.Platform),
                                    "ErrorMessageToPCWhenhittheFOPLimits").ToString(),
                                purchasingLimitManager.MaxPersonalPCConsumptionLimit));
                    }
                    else
                    {
                        var ruleMessage = cart.RuleResults.FirstOrDefault(x => x.Messages != null && x.Messages.Count > 0 && x.RuleName == "PurchasingLimits Rules");
                        if (ruleMessage != null)
                        {
                            cart.RuleResults.Remove(ruleMessage);
                        }
                    }

                    cart.RuleResults.Add(Result);
                }
                else
                {
                    decimal DistributorRemainingVolumePoints = 0;
                    decimal NewVolumePoints = 0;


                    if (null == myhlCart)
                    {
                        LoggerHelper.Error(
                            string.Format("{0} myhlCart is null {1}", Locale, cart.DistributorID));
                        Result.Result = RulesResult.Failure;
                        return(Result);
                    }

                    DistributorRemainingVolumePoints = PurchasingLimits.RemainingVolume;
                    if (cart.CurrentItems != null && cart.CurrentItems.Count > 0)
                    {
                        var currentItem = CatalogProvider.GetCatalogItem(cart.CurrentItems[0].SKU, Country);
                        if (currentItem != null)
                        {
                            NewVolumePoints = currentItem.VolumePoints * cart.CurrentItems[0].Quantity;
                        }
                    }

                    if (NewVolumePoints > 0 || 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;
                                Result.AddMessage(
                                    string.Format(
                                        HttpContext.GetGlobalResourceObject(
                                            string.Format("{0}_Rules", HLConfigManager.Platform),
                                            "VolumePointExceedsThresholdByIncreasingQuantity").ToString(),
                                        purchasingLimitManager.MaxPersonalPCConsumptionLimit));
                                cart.RuleResults.Add(Result);
                                //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));
                                //    }
                                //}
                            }
                        }
                    }
                }
            }
            return(Result);
        }
Esempio n. 29
0
        private decimal GetDonationAmount()
        {
            if (blErrors != null)
            {
                blErrors.Items.Clear();
            }
            decimal _totalDonation = decimal.Zero;

            try
            {
                // ShoppingCartID.Value = ShoppingCart.ShoppingCartID.ToString();
                //divSubmitDonation.Visible = divCancelDonation.Visible = false;

                if (btn5Rmb.Checked || btn10Rmb.Checked || btnOtherAmount.Checked)
                {
                    if (btn5Rmb.Checked)
                    {
                        _selfAmount = 5;
                    }
                    else if (btn10Rmb.Checked)
                    {
                        _selfAmount = 10;
                    }
                    else if (btnOtherAmount.Checked && !String.IsNullOrEmpty(txtOtherAmount.Text.ToString()))
                    {
                        if (decimal.TryParse(txtOtherAmount.Text.ToString(), out _otherAmount))
                        {
                            _selfAmount = _otherAmount;
                        }
                    }
                    else if (btnOtherAmount.Checked)
                    {
                        txtOtherAmount.Enabled = true;
                    }

                    SessionInfo.CancelSelfDonation = SessionInfo.CancelSelfDonation + _selfAmount;
                }

                SessionInfo.CancelBehalfOfDonation = _behalfAmount;
                bool isValidDonation = true;
                if (_selfAmount < 1)
                {
                    isValidDonation = false;
                    ShowError("InvalidDonationAmount");
                }

                var cart = ShoppingCart as MyHLShoppingCart;

                if (_selfAmount > 0)
                {
                    var distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(cart.DistributorID, "CN");
                    if (distributorOrderingProfile.PhoneNumbers.Any())
                    {
                        var phoneNumber = distributorOrderingProfile.PhoneNumbers.Where(p => p.IsPrimary) as PhoneNumber_V03 != null
                                ? distributorOrderingProfile.PhoneNumbers.Where(
                            p => p.IsPrimary) as PhoneNumber_V03
                                : distributorOrderingProfile.PhoneNumbers.FirstOrDefault()
                                          as PhoneNumber_V03;

                        if (phoneNumber != null)
                        {
                            cart.BehalfOfContactNumber = phoneNumber.Number;
                        }
                        else
                        {
                            cart.BehalfOfContactNumber = "21-61033719";
                        }
                    }
                    cart.BehalfDonationName = ProductsBase.DistributorName;
                    cart.BehalfOfMemberId   = DistributorID;

                    if (cart.BehalfOfSelfAmount > 0)
                    {
                        cart.BehalfOfSelfAmount = cart.BehalfOfSelfAmount + _selfAmount;
                    }
                    else
                    {
                        cart.BehalfOfSelfAmount = _selfAmount;
                    }

                    if (cart.BehalfOfAmount > 0)
                    {
                        cart.BehalfOfAmount = cart.BehalfOfAmount;
                    }
                }
                if ((_selfAmount > decimal.Zero) && HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                {
                    var myShoppingCart = (Page as ProductsBase).ShoppingCart;

                    if (myShoppingCart.Totals == null)
                    {
                        myShoppingCart.Totals = new OrderTotals_V02();
                    }

                    OrderTotals_V02 totals = myShoppingCart.Totals as OrderTotals_V02;
                    if (totals == null)
                    {
                        totals = new OrderTotals_V02();
                    }
                    if (_selfAmount > decimal.Zero)
                    {
                        _totalDonation = _selfAmount;
                    }
                }
                if (errors != null && errors.Count > 0)
                {
                    blErrors.DataSource = errors;
                    blErrors.DataBind();
                    errors.Clear();
                    return(0);
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.Error("AddHFFFailed!\n" + ex);
            }
            return(_totalDonation);
        }
        public void CreateInvoiceView(string startYearMonthDay, string endYearMonthDay)
        {
            #region determine startDate and endDate
            DateTime?startDate;
            if (IsValidDate(startYearMonthDay))
            {
                startDate = DateTime.ParseExact(startYearMonthDay, YearMonthDayFormat, CultureInfo.InvariantCulture);
            }
            else
            {
                var proposedStartDate = DateTime.Now.AddDays(-30);
                startDate         = new DateTime(proposedStartDate.Year, proposedStartDate.Month, proposedStartDate.Day);
                txtStartDate.Text = startDate.Value.ToString(YearMonthDayFormat);
            }

            DateTime?endDate;
            if (IsValidDate(endYearMonthDay))
            {
                endDate = DateTime.ParseExact(endYearMonthDay, YearMonthDayFormat, CultureInfo.InvariantCulture).AddDays(1).AddMilliseconds(-1);
            }
            else
            {
                endDate         = DateTime.Now;
                txtEndDate.Text = endDate.Value.ToString(YearMonthDayFormat);
            }
            #endregion


            var htmlTable = new StringBuilder();
            htmlTable.Append("<div>");
            htmlTable.Append("<table id=\"TABLE-ID\" class=\"rgMasterTable order-list-view\" border=\"0\" >");
            htmlTable.Append("<thead>" +
                             "<tr>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("OrderNumberResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("OrderSourceResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("DCResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("OrderMonthResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("DeliveryMethodResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("OrderStatusResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("OrderDateResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("SubTotalResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("FreightResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("TotalAmountResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("VolumeTotalResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("InvoiceStatusResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("ActionResource.Text") + "</th>" +
                             "<th class=\"rgHeader\" scope=\"col\">" + GetLocalResourceObject("RegisteredNoResource.Text") + "</th>" +
                             "</tr>" +
                             "</thead>");
            htmlTable.Append("<tbody>");

            DateTime pStartDate = (DateTime)startDate;
            DateTime pEndDate   = (DateTime)endDate;

            var    pOrders     = new List <OnlineOrder>();
            string cacheKey    = string.Format(InvoiceOrderDetails, DistributorID);
            var    cacheResult = HttpRuntime.Cache[cacheKey] as List <OnlineOrder>;

            if (cacheResult != null)
            {
                pOrders = cacheResult;
            }
            else
            {
                pOrders = OrderProvider.GetOrdersWithDetail(DistributorID,
                                                            DistributorOrderingProfileProvider.GetProfile(DistributorID, CountryCode).CNCustomorProfileID,
                                                            CountryCode, pStartDate, pEndDate, Providers.China.OrderStatusFilterType.Complete, "", "", true);
                HttpRuntime.Cache.Insert(cacheKey, pOrders, null, DateTime.Now.AddMinutes(InvoiceStatusCacheMin),
                                         Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
            }

            // ensure that the order only belong to GDO
            var orders     = pOrders.OrderByDescending(x => x.ReceivedDate).ToList();
            var etoSkuList = Settings.GetRequiredAppSetting("ETOSkuList", string.Empty).Split('|');
            var pureOrders = (from items in orders from ordersItem in items.OrderItems where ordersItem.SKU == null || (ordersItem.SKU.Trim() == "9909" && items.OrderItems.Count == 1 || etoSkuList.Contains(ordersItem.SKU.Trim())) select items).ToList();
            foreach (var item in pureOrders)
            {
                orders.Remove(item);
            }
            string[] orderNumbers = orders.Select(o => o.OrderID).ToArray();
            var      orderStatus  = OrderProvider.GetOrderStatus(orderNumbers, DistributorID);

            if (orders != null)
            {
                int maximumRows = 5;
                int startIndex  = PagingControl1.FirstItemIndex;
                PagingControl1.TotalRecordsCount = orders.Count;


                //var maxRows = startIndex + maximumRows > orders.Count? orders.Count - startIndex: maximumRows;

                //orders = orders.GetRange(maxRows >= 0 ? startIndex : 0, maxRows >= 0 ? maxRows : 0);
                if (orders.Count > 0)
                {
                    if (orders.Count < 5)
                    {
                        PagingControl1.Visible = false;
                    }
                    if (InvoiceStatusddl.SelectedValue == "0" || InvoiceStatusddl.SelectedValue == "01")
                    {
                        if (orders.Count <= maximumRows)
                        {
                            orders = orders.GetRange(0, orders.Count);
                        }
                        else
                        {
                            if (startIndex > 0)
                            {
                                var maxrow = orders.Count - startIndex <= maximumRows ? orders.Count - startIndex : maximumRows;
                                orders = orders.GetRange(startIndex, maxrow);
                            }
                            else
                            {
                                orders = orders.GetRange(0, maximumRows);
                            }
                        }
                    }
                    //orders = orders.GetRange((startIndex == 0) ? 0 : startIndex + 1, orders.Count - 1 - startIndex > 5 ? 5 : orders.Count - 1 - startIndex);
                    PagingControl1.Visible = true;
                    lblNoRecords.Visible   = false;
                }
                else
                {
                    lblNoRecords.Text = GetLocalResourceString("GridNoRecordsMessage.Text");
                    TimeSpan span = _dtEndDate.Subtract(_dtStartDate);
                    if (span.TotalDays > 90)
                    {
                        lblNoRecords.Text = GetLocalResourceString("Error3MonthsRangeOnly.Text");
                    }


                    lblNoRecords.Visible   = true;
                    PagingControl1.Visible = false;
                }
                int i = 0;
                int y = 0;

                foreach (var order in orders)
                {
                    i++;

                    var invoiceDetailStatus = orderStatus.FirstOrDefault(z => z.OrderNumber == order.OrderID);
                    if (invoiceDetailStatus == null)
                    {
                        invoiceDetailStatus = new InvoiceInfoObject();
                        invoiceDetailStatus.InvoiceStatus = "01";
                    }
                    if (invoiceDetailStatus != null && (invoiceDetailStatus.InvoiceStatus == InvoiceStatusddl.SelectedValue) || (InvoiceStatusddl.SelectedValue == "0"))
                    {
                        y++;

                        decimal Apfprice = 0;
                        var     apfSku   = (from c in order.OrderItems where APFDueProvider.IsAPFSku((c.SKU != null ? c.SKU.Trim() : "")) select c).FirstOrDefault();

                        if (order.OrderItems[0].SKU != null && apfSku != null)
                        {
                            var APFSkuDetails = CatalogProvider.GetCatalogItem(apfSku.SKU.Trim(), CountryCode);
                            Apfprice = APFSkuDetails.ListPrice;
                        }

                        var invoiceStatus = invoiceDetailStatus != null?GetInvoiceStatus(invoiceDetailStatus.InvoiceStatus) : GetLocalResourceString("InvoiceStatusUnbilled.Text");

                        var priceInfo    = order.Pricing as ServiceProvider.OrderChinaSvc.OrderTotals_V01 ?? new ServiceProvider.OrderChinaSvc.OrderTotals_V01();
                        var priceInfoV02 = order.Pricing as ServiceProvider.OrderChinaSvc.OrderTotals_V02;
                        var shipInfo     = order.Shipment as ServiceProvider.OrderChinaSvc.ShippingInfo_V01;
                        //Mapping object issue
                        decimal freightCharges = priceInfoV02 != null && null != priceInfoV02.ChargeList && priceInfoV02.ChargeList.Any() ? GetFreightCharges(priceInfoV02.ChargeList as ServiceProvider.OrderChinaSvc.ChargeList) : decimal.Zero;
                        // decimal freightCharges = 0;
                        string carrier;
                        if (shipInfo != null && shipInfo.Carrier == "EXP")
                        {
                            carrier = GetLocalResourceString("InvoiceDeliveryMethod.Text");
                        }
                        else if (shipInfo != null && shipInfo.Carrier == "SD")
                        {
                            carrier = GetLocalResourceString("InvoicePickupFromStoreMethod.Text");
                        }
                        else
                        {
                            carrier = GetLocalResourceString("InvoiceSelftPickupMethod.Text");
                        }

                        htmlTable.Append("<tr class='" + ((i % 2 != 0) ? "rgRow" : "rgAltRow") + "'>");
                        //htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\" onclick='ShowOrHideDetail(" + order.OrderID + ",\"" + (order.InvoiceOrder == null?"":order.InvoiceOrder.Category) + "\")' >" + order.OrderID + "</span></td>");
                        if (order.InvoiceOrder != null && order.InvoiceOrder.InvoiceId < 1)
                        {
                            htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + order.OrderID + "</td>");
                        }
                        else
                        {
                            htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\"><a href=\"onlineinvoicedetail.aspx?type=view&orderid=" + order.OrderID + "&startDate=" + _startDate + "&endDate=" + _endDate + "\" >" + order.OrderID + "</td>");
                        }
                        //htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\"><a href=\"onlineinvoicedetail.aspx?type=view&orderid=" + order.OrderID + "\" >" + order.OrderID + "</td>");

                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + order.ChannelInfo + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + order.RDCName + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + order.OrderMonth + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + carrier + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + order.Status + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + order.ReceivedDate.ToString("yyyy-MM-dd") + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + (priceInfo.ItemsTotal - Apfprice).ToString("0.##") + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + freightCharges.ToString("0.##") + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + (priceInfo.ItemsTotal + freightCharges - Apfprice).ToString("0.##") + "</span></td>");
                        //htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + priceInfoV02.ItemsTotal.ToString("0.##") + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + priceInfo.VolumePoints.ToString("0.##") + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + invoiceStatus + "</span></td>");
                        htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\"><span>");
                        if (order.InvoiceOrder != null && order.InvoiceOrder.InvoiceId < 1)
                        {
                            if (invoiceDetailStatus.PostNumber == null)
                            {
                                htmlTable.Append("<a onclick=\"showModalPopUp('single','" + order.OrderID + "','" + _startDate + "','" + _endDate + "')\" runat=\"server\">" + GetLocalResourceString("OnlineInvoiceSingleBilling.Text") + "</asp:HyperLink>");
                                htmlTable.Append("<br/><br/><a onclick=\"showModalPopUp('split','" + order.OrderID + "','" + _startDate + "','" + _endDate + "')\" runat=\"server\">" + GetLocalResourceString("OnlineInvoiceSplitBilling.Text") + "</asp:HyperLink>");
                            }

                            //htmlTable.Append("<a href=\"onlineinvoicedetail.aspx?type=single&orderid=" + order.OrderID + "&startDate=" + _startDate + "&endDate=" + _endDate + "\">"  + "开票");
                            //htmlTable.Append("<br/><a href=\"onlineinvoicedetail.aspx?type=split&orderid=" + order.OrderID + "&startDate=" + _startDate + "&endDate=" + _endDate + "\">" + "拆票");
                        }
                        htmlTable.Append("</span></td>");

                        if (invoiceDetailStatus != null)
                        {
                            htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + invoiceDetailStatus.PostNumber + "</span></td>");
                        }
                        else
                        {
                            htmlTable.Append("<td class=\"olv-vpoints\" scope=\"col\"><span id=\"lblVolumeCoulmn\">" + "" + "</span></td>");
                        }
                        htmlTable.Append("</tr>");
                    }

                    if (invoiceDetailStatus != null && (invoiceDetailStatus.InvoiceStatus == InvoiceStatusddl.SelectedValue) || (InvoiceStatusddl.SelectedValue == "0"))
                    {
                        PagingControl1.Visible = true;
                        lblNoRecords.Visible   = false;
                    }
                    else if (y < 1)
                    {
                        lblNoRecords.Text      = GetLocalResourceString("GridNoRecordsMessage.Text");
                        lblNoRecords.Visible   = true;
                        PagingControl1.Visible = false;
                    }
                }
                htmlTable.Append("</tbody>");
                htmlTable.Append("</table>");
                htmlTable.Append("</div>");
                htmlTable.Append("<div align='right'>" + GetLocalResourceString("OnlineInvoiceDetailFooter.Text") + "</div>");
                var result = htmlTable.ToString();
                OrderViewPlaceHolder.Controls.Clear();
                OrderViewPlaceHolder.Controls.Add(new Literal {
                    Text = result
                });
            }
        }