Esempio n. 1
0
        protected void btnClearBehalfDonation_Click(object sender, EventArgs e)
        {
            OrderTotals_V02 totals = ShoppingCart.Totals as OrderTotals_V02;

            if (totals != null)
            {
                if (totals.Donation > SessionInfo.CancelBehalfOfDonation)
                {
                    totals.Donation = totals.Donation - SessionInfo.CancelBehalfOfDonation;
                }
                else
                {
                    totals.Donation = 0;
                }
                ShoppingCart.Calculate();
                OnQuoteRetrieved(null, null);
                lblHFFMsg.Text = "";
                divMsg.Visible = true;
                ClearBehalfDonation2.Visible = false;
            }
            SessionInfo.CancelBehalfOfDonation = decimal.Zero;
            btnBehalf5Rmb.Checked   = btnBehalf10Rmb.Checked = btnBehalfOther.Checked = false;
            txtOtherAmount2.Text    = txtDonatorName.Text = txtContactNumber.Text = string.Empty;
            txtOtherAmount2.Enabled = false;
            var cart = ShoppingCart as MyHLShoppingCart;

            cart.BehalfOfAmount = decimal.Zero;
            //  SessionInfo.ClearStandAloneDonation();
        }
 public Order_V01 Getorder(OrderViewModel orderViewModel,
                           ref List <ValidationErrorViewModel> errors,
                           OrderTotals_V02 orderTotalsV02, OrderTotals_V01 orderTotalsV01, out decimal amount)
 {
     return(MobileOrderProvider.ModelConverter.ConvertOrderViewModelToOrderV01(orderViewModel,
                                                                               ref errors, orderTotalsV02,
                                                                               orderTotalsV01,
                                                                               out amount));
 }
        private void GetQuotes(Order order, OrderTotals total, bool calcFreight, out OrderTotals_V02 totals)
        {
            var shoppingCartLaoder = Substitute.For <IShoppingCartProviderLoader>();

            shoppingCartLaoder.GetQuote(order, total, calcFreight).Returns(GetQuote(order, out totals, calcFreight));

            decimal AmountDues = totals.AmountDue - totals.ItemsTotal;

            Assert.AreEqual(AmountDues, 60);
        }
        private OrderTotals GetQuote(Order order, out OrderTotals_V02 total, bool calcFreight)
        {
            total = new OrderTotals_V02();
            var orderTotalsV02 = total;

            orderTotalsV02.Donation  = 60;
            orderTotalsV02.AmountDue = 329 + orderTotalsV02.Donation;
            total.ItemsTotal         = 329M;
            OrderFreight orderfreight = new OrderFreight
            {
                FreightCharge = 0.0M,
            };

            total.OrderFreight   = orderfreight;
            total.DiscountAmount = 0;
            total = orderTotalsV02;
            return(total);
        }
        private OrderTotals GetQuote(Order order, out OrderTotals_V02 total, bool calcFreight)
        {
            total = new OrderTotals_V02();
            var orderTotalsV02 = total;

            orderTotalsV02.VolumePoints = 600;
            orderTotalsV02.AmountDue    = 4000;
            OrderFreight orderfreight = new OrderFreight
            {
                FreightCharge = 0.0M,
            };

            total.OrderFreight = orderfreight;

            total.DiscountAmount = 0;
            total = orderTotalsV02;
            return(total);
        }
        public void ProcessDonation_Test()
        {
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("CN640521", "zh-CN", "3", "888",
                                                                      new ShippingAddress_V02());

            cart.CartItems = new ShoppingCartItemList
            {
                ShoppingCartItemHelper.GetCartItem(1, 1, "1316"),
            };

            var order = new Order_V01();

            order.DistributorID = "CN640521";

            var orderitem1 = new OnlineOrderItem()
            {
                Quantity    = 1,
                SKU         = "1316",
                Description = "Test",
                RetailPrice = 0,
                IsPromo     = false,
            };

            MyHerbalife3.Ordering.Providers.Shipping.DeliveryOption deliveryOption = new MyHerbalife3.Ordering.Providers.Shipping.DeliveryOption();
            order.CountryOfProcessing = "CN";
            order.OrderItems          = new OrderItems {
                orderitem1
            };
            order.Shipment = new ShippingInfo_V01
            {
                Address = new MyHerbalife3.Ordering.ServiceProvider.OrderSvc.Address
                {
                    City    = "眉山市",
                    Country = "cn"
                },
                ShippingMethodID = "22",
                WarehouseCode    = "888"
            };

            var ordertotal = new OrderTotals_V02();

            GetQuotes(order, ordertotal, false, out ordertotal);
            cart.Totals = ordertotal;
        }
Esempio n. 7
0
        public void ProcessFreightPromotion_Not_Eligible()
        {
            PromotionalRules rules = new PromotionalRules();
            //rules.ProcessCart();


            var promotion = Substitute.For <IPromotionLoader>();

            promotion.GetPromotions().Returns(promotionSet);
            promotion.getCurrentSessionFromMock().Returns(sessionInfo);
            promotion.GetDistributorOrderingProfilefromMock().Returns(distributorProfile);

            rules.setPromotion(promotion);
            rules.ProcessCart(cart, ShoppingCartRuleReason.CartCalculated);

            var             testCart = cart as MyHLShoppingCart;
            OrderTotals_V02 total    = (OrderTotals_V02)testCart.Totals;

            total.AmountDue = 499;
            Assert.AreEqual(499, total.AmountDue);
        }
Esempio n. 8
0
        protected void btnClearDonation_Click(object sender, EventArgs e)
        {
            OrderTotals_V02 totals = ShoppingCart.Totals as OrderTotals_V02;

            if (totals != null)
            {
                if (ShoppingCart.CartItems == null || ShoppingCart.CartItems.Count == 0)
                {
                    ShoppingCart.Totals = new OrderTotals_V02();
                }
                else
                {
                    totals.Donation = decimal.Zero;
                    ShoppingCart.Calculate();
                }
                OnQuoteRetrieved(null, null);

                lblHFFMsg.Text        = "";
                divMsg.Visible        = true;
                ClearDonation.Visible = ClearDonation2.Visible = false;
            }
        }
        private void DisplayEmptyTotals()
        {
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                if (totals_V02 != null)
                {
                    trDiscountTotal.Visible = totals_V02.DiscountAmount > 0;
                }
            }

            lblOrderMonthVolume.Text = ProductsBase.CurrentMonthVolume;
            lblDiscountRate.Text     = ProductsBase.DistributorDiscount.ToString() + "%";
            lblVolumePoints.Text     = GetVolumeString(0.00M);
            lblEarnBase.Text         = getAmountString((decimal)0.00);
            lblRetailPrice.Text      = getAmountString((decimal)0.00);
            lblSubtotal.Text         = getAmountString((decimal)0.00);
            lblOtherCharges.Text     = getAmountString((decimal)0.00);
            lblLocalTax.Text         = getAmountString((decimal)0.00);
            lblPackageHandling.Text  = getAmountString((decimal)0.00);
            lblShippingCharges.Text  = getAmountString((decimal)0.00);
            lblTaxVAT.Text           = getAmountString((decimal)0.00);
        }
Esempio n. 10
0
        private void DonationClicked(decimal donationAmount)
        {
            decimal quantity = donationAmount;

            //if (int.TryParse(tbQuantity.Text.Trim(), out quantity))
            if (quantity > 0)
            {
                var myShoppingCart = (Page as ProductsBase).ShoppingCart;

                //Add the donation amount to cart
                if (!string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku))
                {
                    try
                    {
                        if (quantity > 0)
                        {
                            int quantiti = Decimal.ToInt32(quantity);
                            if (!ProductsBase.AddHFFSKU(quantiti))
                            {
                                lblHFFMsg.Text =
                                    string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                            "AddHFFFailed"));
                                divMsg.Visible = true;
                            }
                            else
                            {
                                lblHFFMsg.Text =
                                    string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                            "AddHFFSucceeded"));
                                divMsg.Visible = true;
                            }
                        }
                        //else
                        //{
                        //    lblHFFMsg.Text =
                        //        string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero"));
                        //    divMsg.Visible = true;
                        //}
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error("HFF Herbalife Can not be added to cart!\n" + ex);
                    }
                }
                else if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                {
                    if (myShoppingCart.Totals == null)
                    {
                        myShoppingCart.Totals = new OrderTotals_V02();
                    }

                    if (myShoppingCart.Totals != null)
                    {
                        OrderTotals_V02 totals = myShoppingCart.Totals as OrderTotals_V02;
                        if (totals != null)
                        {
                            if (totals != null && totals.Donation > 0)
                            {
                                totals.Donation = totals.Donation + quantity;
                            }
                            else
                            {
                                totals.Donation = quantity;
                            }
                            myShoppingCart.Calculate();
                            OnQuoteRetrieved(null, null);

                            lblHFFMsg.Text =
                                string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                        "AddHFFSucceeded"));
                            divMsg.Visible        = true;
                            ClearDonation.Visible = true;
                            if (SessionInfo.CancelSelfDonation > 0)
                            {
                                ClearDonation2.Visible = true;
                            }
                            else
                            {
                                ClearDonation2.Visible = false;
                            }
                            if (SessionInfo.CancelBehalfOfDonation > 0)
                            {
                                ClearBehalfDonation2.Visible = true;
                            }
                            else
                            {
                                ClearBehalfDonation2.Visible = false;
                            }
                        }
                    }

                    //tbQuantity.Text = HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeDefaultValue.ToString();
                }
                else
                {
                    LoggerHelper.Error(string.Format("HFF SKU missing from Config for {0}.", Locale));
                }
            }
            //else
            //{
            //    //tbQuantity.Text = string.Empty;
            //    lblHFFMsg.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero");
            //    divMsg.Visible = true;
            //}
        }
Esempio n. 11
0
        public MyHLShoppingCart LoadOrderAcknowledgement(string orderNumber, string locale, string distributorID)
        {
            var req = new GetPendingOrdersRequest_V03();

            req.CountryCode         = locale;
            req.DistributorId       = distributorID;
            req.IncludeXmlOrderData = true;
            req.OrderNumberList     = new List <string> {
                orderNumber
            };

            var proxy = ServiceClientProvider.GetOrderServiceProxy();

            var rsp = proxy.GetOrders(new GetOrdersRequest1(req)).GetOrdersResult as GetPendingOrdersResponse_V01;

            if (!Helper.Instance.ValidateResponse(rsp))
            {
                Helper.Instance.LogError(rsp.Message, string.Format("{0}.LoadOrderAcknowledgement()", ThisClassName));
                return(null);
            }

            var cart = new MyHLShoppingCart();

            var pendingOdr = rsp.PendingOrders.FirstOrDefault();

            XElement xRoot = XElement.Parse(pendingOdr.XmlOrderData.OuterXml);

            var xBTOrder = GetChild(xRoot, "BTOrder");
            var xOrder   = GetChild(xRoot, "Order");

            #region ShoppingCart

            cart.CountryCode     = GetChildValue(xBTOrder, "countryOfProcessingField");
            cart.DistributorID   = GetChildValue(xBTOrder, "distributorIDField");
            cart.Locale          = GetChildValue(xBTOrder, "localeField");
            cart.OrderMonth      = int.Parse(GetChildValue(xBTOrder, "orderMonthField"));
            cart.OrderSubType    = GetChildValue(xBTOrder, "orderSubTypeField");
            cart.SMSNotification = GetChildValue(xBTOrder, "sMSNumberField");

            cart.EmailAddress = GetChildValue(xRoot, "Email");

            #region DeliveryInfo

            var xShipment = GetChild(xOrder, "Shipment");

            ShippingInfo_V01 shpInfoV01 = new ShippingInfo_V01
            {
                Carrier          = GetChildValue(xShipment, "Carrier"),
                FreightVariant   = GetChildValue(xShipment, "FreightVariant"),
                Phone            = GetChildValue(xShipment, "Phone"),
                Recipient        = GetChildValue(xShipment, "Recipient"),
                ShippingMethodID = GetChildValue(xShipment, "ShippingMethodID"),
                Version          = GetChildValue(xShipment, "Version"),
                WarehouseCode    = GetChildValue(xShipment, "WarehouseCode"),
                DeliveryNickName = GetChildValue(xShipment, "DeliveryNickName"),
            };

            var phone = shpInfoV01.Phone;
            if (!string.IsNullOrWhiteSpace(phone))
            {
                // trim the start and end with -
                if (phone.StartsWith("-") && phone.EndsWith("-") && (phone.Length >= 2))
                {
                    shpInfoV01.Phone = phone.Substring(1, phone.Length - 2);
                }
            }

            var deliveryInfo = new MyHerbalife3.Ordering.Providers.Shipping.ShippingInfo
            {
                //Description
                DeliveryNickName = shpInfoV01.DeliveryNickName,
                FreightCode      = shpInfoV01.ShippingMethodID,
                FreightVariant   = shpInfoV01.FreightVariant, // somehow FreightVariant will be null, due to the prop get implementation
                //Id
                WarehouseCode = shpInfoV01.WarehouseCode,
            };

            deliveryInfo.Option = DeliveryOptionTypes.Convert(shpInfoV01.FreightVariant);

            cart.FreightCode = deliveryInfo.FreightCode;

            #region ShippingAddress_V01

            var shippingAddr = new ServiceProvider.ShippingSvc.ShippingAddress_V01
            {
                Alias = shpInfoV01.DeliveryNickName,
                //AreaCode
                //DisplayName
                Phone     = shpInfoV01.Phone,
                Recipient = shpInfoV01.Recipient,
            };

            #region Address_V01

            var xAddress = GetChild(xShipment, "Address");
            var addr     = new ServiceProvider.ShippingSvc.Address_V01
            {
                City                   = GetChildValue(xAddress, "City"),
                Country                = GetChildValue(xAddress, "Country"),
                CountyDistrict         = GetChildValue(xAddress, "CountyDistrict"),
                Line1                  = GetChildValue(xAddress, "Line1"),
                Line2                  = GetChildValue(xAddress, "Line2"),
                Line3                  = GetChildValue(xAddress, "Line3"),
                Line4                  = GetChildValue(xAddress, "Line4"),
                PostalCode             = GetChildValue(xAddress, "PostalCode"),
                StateProvinceTerritory = GetChildValue(xAddress, "StateProvinceTerritory"),
            };

            shippingAddr.Address = addr;

            #endregion

            deliveryInfo.Address = shippingAddr;

            #endregion

            #region HandlingInfo_V01

            var xHandling = GetChild(xOrder, "Handling");
            HandlingInfo_V01 handlingInfoV01 = new HandlingInfo_V01
            {
                PickupName           = GetChildValue(xHandling, "PickupName"),
                ShippingInstructions = GetChildValue(xHandling, "ShippingInstructions"),
                Version = GetChildValue(xHandling, "Version"),
            };

            deliveryInfo.Instruction = handlingInfoV01.ShippingInstructions;

            #endregion

            cart.DeliveryInfo = deliveryInfo;

            #endregion

            #region ShoppingCartItems, CartItems

            cart.ShoppingCartItems = new List <DistributorShoppingCartItem>();
            cart.CartItems         = new ServiceProvider.CatalogSvc.ShoppingCartItemList();

            var itemList     = new List <DistributorShoppingCartItem>();
            var cartItemList = new List <ServiceProvider.CatalogSvc.ShoppingCartItem_V01>();

            var xOrderItemsField = GetChild(xBTOrder, "orderItemsField");
            var xBTItemList      = GetChildList(xOrderItemsField, "Item");

            var xOrderItems = GetChild(xOrder, "OrderItems");
            var xItemList   = GetChildList(xOrderItems, "Item");

            foreach (var xItem in xItemList)
            {
                var sku = GetChildValue(xItem, "SKU");

                #region Shared.Providers.DistributorShoppingCartItem

                DistributorShoppingCartItem item = new DistributorShoppingCartItem
                {
                    Description  = GetChildValue(xItem, "Description"),
                    IsPromo      = GetChildValue <bool>(xItem, "IsPromo"),
                    RetailPrice  = GetChildValue <decimal>(xItem, "RetailPrice"),
                    Quantity     = GetChildValue <int>(xItem, "Quantity"),
                    SKU          = sku,
                    VolumePoints = GetChildValue <decimal>(xItem, "VolumePoint"),
                };

                var xBTItem = LookupBTOrderItem(xBTItemList, sku);
                if (xBTItem != null)
                {
                    item.DiscountPrice = GetChildValue <decimal>(xBTItem, "discountAmountField");
                    item.EarnBase      = GetChildValue <decimal>(xBTItem, "earnBaseField");
                    item.Flavor        = GetChildValue(xBTItem, "flavorField");
                }

                #endregion

                #region ShoppingCartItem_V01

                var cartItem = new ServiceProvider.CatalogSvc.ShoppingCartItem_V01
                {
                    IsPromo  = GetChildValue <bool>(xItem, "IsPromo"),
                    Quantity = GetChildValue <int>(xItem, "Quantity"),
                    SKU      = sku,
                };

                #endregion

                itemList.Add(item);
                cartItemList.Add(cartItem);
            }

            var itemListSorted     = itemList.OrderBy(x => x.SKU).ToList();
            var cartItemListSorted = cartItemList.OrderBy(x => x.SKU).ToList();

            cart.ShoppingCartItems.AddRange(itemListSorted);
            cart.CartItems.AddRange(cartItemListSorted);

            #endregion

            #region Totals

            var xPricing = GetChild(xOrder, "Pricing");

            #region ChargeList

            var        xChargeList = GetChild(xPricing, "ChargeList");
            ChargeList chargeList  = new ChargeList();

            var xChargeList_List = GetChildList(xChargeList, "Charge");
            foreach (var xCharge in xChargeList_List)
            {
                #region Charge_V01

                if (GetAttributeValue(xCharge, "type") == "Charge_V01")
                {
                    Charge_V01 chargeV01 = new Charge_V01(ChargeTypes.None, 0)
                    {
                        Amount    = GetChildValue <decimal>(xCharge, "Amount"),
                        TaxAmount = GetChildValue <decimal>(xCharge, "TaxAmount"),
                        Type      = GetChildValue(xCharge, "Type"),
                        Version   = GetChildValue(xCharge, "Version"),
                    };

                    chargeList.Add(chargeV01);
                }

                #endregion
            }

            #endregion

            #region ItemTotalsList

            var xItemTotalsList = GetChild(xPricing, "ItemTotalsList");
            var itemTotalsList  = new ServiceProvider.OrderSvc.ItemTotalsList();

            var xItemTotalsList_List = GetChildList(xItemTotalsList, "ItemTotal");
            foreach (var xItemTotal in xItemTotalsList_List)
            {
                #region ItemTotal_V01

                ItemTotal_V01 itemTotalV01 = new ItemTotal_V01
                {
                    AfterDiscountTax = GetChildValue <decimal>(xItemTotal, "AfterDiscountTax"),
                    ChargeList       = new ChargeList(), // just empty list
                    Discount         = GetChildValue <decimal>(xItemTotal, "Discount"),
                    DiscountedPrice  = GetChildValue <decimal>(xItemTotal, "DiscountedPrice"),
                    EarnBase         = GetChildValue <decimal>(xItemTotal, "EarnBase"),
                    LinePrice        = GetChildValue <decimal>(xItemTotal, "LinePrice"),
                    LineTax          = GetChildValue <decimal>(xItemTotal, "LineTax"),
                    //ProductType = GetChildValue(xItemTotal, "ProductType"),
                    Quantity      = GetChildValue <int>(xItemTotal, "Quantity"),
                    RetailPrice   = GetChildValue <decimal>(xItemTotal, "RetailPrice"),
                    SKU           = GetChildValue(xItemTotal, "SKU"),
                    TaxableAmount = GetChildValue <decimal>(xItemTotal, "TaxableAmount"),
                    VolumePoints  = GetChildValue <decimal>(xItemTotal, "VolumePoints"),
                    Version       = GetChildValue(xItemTotal, "Version"),
                };

                itemTotalsList.Add(itemTotalV01);

                var itemMatch = cart.ShoppingCartItems.FirstOrDefault(x => x.SKU == itemTotalV01.SKU);
                if (itemMatch != null)
                {
                    itemMatch.DiscountPrice = itemTotalV01.DiscountedPrice;
                }

                #endregion
            }

            #endregion

            #region OrderFreight

            var xOrderFreight = GetChild(xPricing, "OrderFreight");

            #region Packages

            var            xPackages   = GetChild(xOrderFreight, "Packages");
            List <Package> packageList = new List <Package>();

            var xPackageList = GetChildList(xPackages, "Package");
            foreach (var xPck in xPackageList)
            {
                #region Package

                var pck = new Package
                {
                    Packagetype = GetChildValue(xPck, "Packagetype"),
                    Unit        = GetChildValue <int>(xPck, "Unit"),
                    Volume      = GetChildValue <decimal>(xPck, "Volume"),
                };

                #endregion

                packageList.Add(pck);
            }

            #endregion

            var ordFreight = new OrderFreight
            {
                ActualFreight         = GetChildValue <decimal>(xOrderFreight, "ActualFreight"),
                BeforeDiscountFreight = GetChildValue <decimal>(xOrderFreight, "BeforeDiscountFreight"),
                BeforeWeight          = GetChildValue <decimal>(xOrderFreight, "BeforeWeight"),
                CaseRate       = GetChildValue <decimal>(xOrderFreight, "CaseRate"),
                FreightCharge  = GetChildValue <decimal>(xOrderFreight, "FreightCharge"),
                Insurance      = GetChildValue <decimal>(xOrderFreight, "Insurance"),
                InsuranceRate  = GetChildValue <decimal>(xOrderFreight, "InsuranceRate"),
                MaterialFee    = GetChildValue <decimal>(xOrderFreight, "MaterialFee"),
                Packages       = packageList,
                PackageType    = GetChildValue(xOrderFreight, "PackageType"),
                PackageWeight  = GetChildValue <decimal>(xOrderFreight, "PackageWeight"),
                PhysicalWeight = GetChildValue <decimal>(xOrderFreight, "PhysicalWeight"),
                Unit           = GetChildValue <int>(xOrderFreight, "Unit"),
                VolumeWeight   = GetChildValue <decimal>(xOrderFreight, "VolumeWeight"),
                Weight         = GetChildValue <decimal>(xOrderFreight, "Weight"),
            };

            #endregion

            #region OrderTotals_V02

            if (GetAttributeValue(xPricing, "type") == "OrderTotals_V02")
            {
                var total = new OrderTotals_V02
                {
                    AmountDue            = GetChildValue <decimal>(xPricing, "AmountDue"),
                    BalanceAmount        = GetChildValue <decimal>(xPricing, "BalanceAmount"),
                    ChargeList           = chargeList,
                    DiscountedItemsTotal = GetChildValue <decimal>(xPricing, "DiscountedItemsTotal"),
                    DiscountPercentage   = GetChildValue <decimal>(xPricing, "DiscountPercentage"),
                    DiscountType         = GetChildValue(xPricing, "DiscountType"),
                    Donation             = GetChildValue <decimal>(xPricing, "Donation"),
                    Donation2            = GetChildValue <decimal>(xPricing, "Donation2"),
                    ExciseTax            = GetChildValue <decimal>(xPricing, "ExciseTax"),
                    IcmsTax                 = GetChildValue <decimal>(xPricing, "IcmsTax"),
                    IpiTax                  = GetChildValue <decimal>(xPricing, "IpiTax"),
                    ItemsTotal              = GetChildValue <decimal>(xPricing, "ItemsTotal"),
                    ItemTotalsList          = itemTotalsList,
                    LiteratureRetailAmount  = GetChildValue <decimal>(xPricing, "LiteratureRetailAmount"),
                    MiscAmount              = GetChildValue <decimal>(xPricing, "MiscAmount"),
                    OrderFreight            = ordFreight,
                    PricingServerName       = GetChildValue(xPricing, "PricingServerName"),
                    ProductRetailAmount     = GetChildValue <decimal>(xPricing, "ProductRetailAmount"),
                    ProductTaxTotal         = GetChildValue <decimal>(xPricing, "ProductTaxTotal"),
                    PromotionRetailAmount   = GetChildValue <decimal>(xPricing, "PromotionRetailAmount"),
                    TaxableAmountTotal      = GetChildValue <decimal>(xPricing, "TaxableAmountTotal"),
                    TaxAfterDiscountAmount  = GetChildValue <decimal>(xPricing, "TaxAfterDiscountAmount"),
                    TaxAmount               = GetChildValue <decimal>(xPricing, "TaxAmount"),
                    TaxBeforeDiscountAmount = GetChildValue <decimal>(xPricing, "TaxBeforeDiscountAmount"),
                    TotalEarnBase           = GetChildValue <decimal>(xPricing, "TotalEarnBase"),
                    TotalItemDiscount       = GetChildValue <decimal>(xPricing, "TotalItemDiscount"),
                    Version                 = GetChildValue(xPricing, "Version"),
                    VolumePoints            = GetChildValue <decimal>(xPricing, "VolumePoints"),
                };

                cart.Totals = total;
            }

            #endregion

            #endregion

            #endregion

            var xEmailInfoField = GetChild(xBTOrder, "emailInfoField");

            cart.InvoiceOption = GetChildValue(xEmailInfoField, "invoiceOptionField");

            return(cart);
        }
        protected virtual void BindTotals()
        {
            List <DistributorShoppingCartItem> lstShoppingCartItems =
                (Page as ProductsBase).ShoppingCart.ShoppingCartItems;

            try
            {
                if ((HLConfigManager.Configurations.DOConfiguration.CalculateWithoutItems &&
                     _shoppingCart.Totals != null &&
                     (_shoppingCart.Totals as OrderTotals_V01).AmountDue != decimal.Zero) || (lstShoppingCartItems.Count > 0 && ShoppingCart.Totals != null))
                {
                    OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01;

                    lblDiscountRate.Text = _shoppingCart.Totals == null
                                               ? "0%"
                                               : ((_shoppingCart.Totals as OrderTotals_V01).DiscountPercentage).ToString() + "%";
                    _shoppingCart.EmailValues.DistributorSubTotal          = OrderProvider.GetDistributorSubTotal(_shoppingCart.Totals as OrderTotals_V01);
                    _shoppingCart.EmailValues.DistributorSubTotalFormatted = getAmountString(_shoppingCart.EmailValues.DistributorSubTotal);
                    lblDistributorSubtotal.Text = _shoppingCart.EmailValues.DistributorSubTotalFormatted;
                    lblEarnBase.Text            = getAmountString(GetTotalEarnBase(lstShoppingCartItems));
                    if (lblDiscountTotal != null)
                    {
                        lblDiscountTotal.Text =
                            getAmountString(CheckoutTotalsDetailed.GetDiscountTotal(lstShoppingCartItems));
                    }
                    if (IsChina && (DistributorOrderingProfile.IsPC || (ShoppingCart.OrderCategory == OrderCategoryType.ETO && SessionInfo != null && !SessionInfo.IsReplacedPcOrder)))
                    {
                        lblPCLearningPointAmount.Text = getAmountString(_shoppingCart.pcLearningPointOffSet);
                    }
                    // added for China DO
                    if (HLConfigManager.Configurations.CheckoutConfiguration.HasDiscountAmount)
                    {
                        OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                        if (totals_V02 != null)
                        {
                            HLRulesManager.Manager.PerformDiscountRules(_shoppingCart, null, Locale,
                                                                        ShoppingCartRuleReason.CartCalculated);
                            lblDiscountAmount.Text = getAmountString(totals_V02.DiscountAmount);
                            trDiscountRate.Visible = false;
                        }
                    }
                    if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                    {
                        if (trDonationAmount != null)
                        {
                            trDonationAmount.Visible = true;
                            OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                            if (totals_V02 != null)
                            {
                                lblDonationAmount.Text = getAmountString(totals_V02.Donation);
                            }
                        }
                    }
                    if (ProductsBase.IsEventTicketMode)
                    {
                        var orderMonthShortString = string.Empty;
                        var ordermonth            = OrderMonth.DualOrderMonthForEventTicket(true, out orderMonthShortString); // dual ordermonth should be desable for ETO
                        lblOrderMonth.Text = string.IsNullOrWhiteSpace(ordermonth) ? GetOrderMonthString() : ordermonth;
                        var currentSession = SessionInfo;

                        if (null != currentSession && !string.IsNullOrWhiteSpace(orderMonthShortString))
                        {
                            currentSession.OrderMonthString      = ordermonth;
                            currentSession.OrderMonthShortString = orderMonthShortString;
                        }
                    }
                    else
                    {
                        lblOrderMonth.Text = GetOrderMonthString();
                    }

                    decimal currentMonthVolume = 0;
                    if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayFormatNeedsDecimal)
                    {
                        lblOrderMonthVolume.Text = decimal.TryParse(ProductsBase.CurrentMonthVolume, NumberStyles.Any, CultureInfo.InstalledUICulture, out currentMonthVolume)
                            ? ProductsBase.GetVolumePointsFormat(currentMonthVolume) :
                                                   (Page as ProductsBase).CurrentMonthVolume;
                    }
                    else
                    {
                        lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume;
                    }

                    Charge_V01 otherCharges =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.OTHER); }) as
                        Charge_V01 ?? new Charge_V01(ChargeTypes.OTHER, (decimal)0.0);
                    Charge_V01 pHCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.PH); }) as Charge_V01 ??
                        new Charge_V01(ChargeTypes.PH, (decimal)0.0);
                    Charge_V01 freightCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.FREIGHT); }) as
                        Charge_V01 ?? new Charge_V01(ChargeTypes.FREIGHT, (decimal)0.0);
                    Charge_V01 localTaxCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOCALTAX); }) as
                        Charge_V01 ?? new Charge_V01(ChargeTypes.LOCALTAX, (decimal)0.0);
                    lblOtherCharges.Text = getAmountString(otherCharges.Amount);
                    lblLocalTax.Text     = getAmountString(localTaxCharge.Amount);
                    Charge_V01 logisticCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOGISTICS_CHARGE); })
                        as Charge_V01 ?? new Charge_V01(ChargeTypes.LOGISTICS_CHARGE, (decimal)0.0);
                    lblLogisticCharges.Text = getAmountString(logisticCharge.Amount);
                    lblPackageHandling.Text = getAmountString(pHCharge.Amount);
                    lblShippingCharges.Text = getAmountString(freightCharge.Amount);
                    lblRetailPrice.Text     = getAmountString(totals.ItemsTotal);
                    lblTaxVAT.Text          = getAmountString(totals.TaxAmount);
                    if (lblSubtotal != null)
                    {
                        lblSubtotal.Text = getAmountString(logisticCharge.Amount);
                    }
                    if (lblAdditionalDiscount != null)
                    {
                        lblAdditionalDiscount.Text = getAmountString(otherCharges.Amount);
                    }
                    lblVolumePoints.Text = ProductsBase.GetVolumePointsFormat(totals.VolumePoints);

                    //added for HR
                    if (HLConfigManager.Configurations.CheckoutConfiguration.MergePHAndShippingCharges)
                    {
                        decimal phShippingCharges = pHCharge.Amount + freightCharge.Amount;
                        lblPackageHandling.Text = getAmountString(phShippingCharges);
                    }

                    if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayWeight && !SessionInfo.IsEventTicketMode && lblWeight != null)
                    {
                        lblWeight.Text = ShoppingCartProvider.GetWeight(ShoppingCart);
                    }
                }
                else
                {
                    if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                    {
                        if (trDonationAmount != null)
                        {
                            trDonationAmount.Visible = true;
                            OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                            if (totals_V02 != null)
                            {
                                lblDonationAmount.Text = getAmountString(totals_V02.Donation);
                            }
                        }
                    }

                    DisplayEmptyLabels();
                }
            }
            catch (Exception ex)
            {
                //Log Exception
                LoggerHelper.Error("Exception while displaying totals - " + ex);
                DisplayEmptyLabels();
            }
        }
Esempio n. 13
0
        private void setupCart()
        {
            MyHLShoppingCart _cart = new MyHLShoppingCart
            {
                CurrentItems      = new ShoppingCartItemList(),
                CartItems         = new ShoppingCartItemList(),
                CountryCode       = "CN",
                DeliveryInfo      = new MyHerbalife3.Ordering.Providers.Shipping.ShippingInfo(),
                DistributorID     = "test123",
                RuleResults       = new List <ShoppingCartRuleResult> {
                },
                Totals            = new HL.Order.ValueObjects.OrderTotals(),
                ShoppingCartItems = new List <Shared.Providers.DistributorShoppingCartItem>(),
            };

            OrderTotals_V02 totals = new OrderTotals_V02
            {
                AmountDue  = 500,
                ChargeList = new HL.Order.ValueObjects.ChargeList {
                    new HL.Order.ValueObjects.Charge_V01 {
                        ChargeType       = HL.Order.ValueObjects.ChargeTypes.FREIGHT,
                        Amount           = 25,
                        DiscountedAmount = 1
                    }
                },
                DiscountAmount = 1,
                ItemsTotal     = 500,
                OrderFreight   = new OrderFreight {
                    ActualFreight = 1, Packages = new List <Package> {
                        new Package {
                            Packagetype = "C", Unit = 1, Volume = 0.0078045M
                        }
                    },
                }
            };

            _cart.CartItems.Add(new ShoppingCartItem_V01()
            {
                SKU = "1316", ID = 1, Quantity = 2
            });
            _cart.CurrentItems.Add(new ShoppingCartItem_V01()
            {
                SKU = "1316", ID = 1, Quantity = 2
            });
            _cart.RuleResults.Add(new ShoppingCartRuleResult {
                RuleName = "ETO Rules"
            });
            _cart.DeliveryInfo = new MyHerbalife3.Ordering.Providers.Shipping.ShippingInfo {
                FreightCode = "22", AddressType = "EXP", WarehouseCode = "3019", Option = HL.Common.ValueObjects.DeliveryOptionType.Shipping
            };
            _cart.Totals       = totals;
            _cart.DeliveryInfo = new MyHerbalife3.Ordering.Providers.Shipping.ShippingInfo
            {
                Address = new HL.Shipping.ValueObjects.ShippingAddress_V01
                {
                    Address = new HL.Common.ValueObjects.Address_V01 {
                        StateProvinceTerritory = "广西壮族自治区", City = "梧州市", Country = "CN", CountyDistrict = "蝶山区", PostalCode = "111111"
                    }
                },
                AddressType = "EXP"
            };

            cart = _cart;

            var onePromo = new PromotionElement
            {
                AmountMinInclude = 500,
                PromotionType    = HL.Order.ValueObjects.China.PromotionType.Freight,
                StartDate        = DateTime.Now.ToString("MM-dd-yyyy"),
                EndDate          = DateTime.Now.ToString("MM-dd-yyyy"),
                excludedExpID    = new List <string> {
                    "10,30"
                },
                CustTypeList = new List <string> {
                    "PC,CS"
                },
                CustCategoryTypeList = new List <string> {
                    "PC"
                },
                Code = "DecPCPromo"
            };

            promotionSet.Add(onePromo);

            // Session
            sessionInfo = new SessionInfo
            {
                ShippingAddresses = new List <HL.Shipping.ValueObjects.ShippingAddress_V02>()
                {
                    new HL.Shipping.ValueObjects.ShippingAddress_V02
                    {
                        Address = new HL.Common.ValueObjects.Address_V01 {
                            City = "南宁市", StateProvinceTerritory = "广西壮族自治区", CountyDistrict = "青秀区", Country = "CN"
                        }
                    }
                }
            };

            //DistributorProfile
            distributorProfile = new DistributorOrderingProfile
            {
                CNAPFStatus        = 2,
                CNCustCategoryType = "PC",
                CNCustType         = "PC",
                IsPC            = true,
                Id              = "test123",
                CNStoreProvince = "广西壮族自治区"
            };
        }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((null != ProductsBase.SessionInfo && ProductsBase.SessionInfo.IsEventTicketMode) || this.ShoppingCart.OrderCategory == ServiceProvider.CatalogSvc.OrderCategoryType.HSO)
            {
                divHFF.Visible = false;
                hffPanel.Update();
                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    hlHFF.Visible    = false;
                    hffPanel.Visible = false;
                }
                return;
            }
            if (HLConfigManager.Configurations.DOConfiguration.HaveNewHFF)
            {
                OldHFF.Visible = false;
            }
            else
            {
                NewHFF.Visible = false;
            }
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                if (CatalogProvider.IsPreordering(ShoppingCart.CartItems, (ShoppingCart.DeliveryInfo != null ? ShoppingCart.DeliveryInfo.WarehouseCode : string.Empty)))
                {
                    hlHFF.Visible    = false;
                    hffPanel.Visible = false;
                    return;
                }
            }
            // Verify special rules to show the module
            ShowModule();
            if (!divHFF.Visible)
            {
                return;
            }

            hlHFF.NavigateUrl = HLConfigManager.Configurations.DOConfiguration.HFFUrl;
            hlHFF.Visible     = !string.IsNullOrEmpty(hlHFF.NavigateUrl) &&
                                HLConfigManager.Configurations.DOConfiguration.ShowHFFBox;

            if (!IsPostBack)
            {
                tbQuantity.Attributes["onkeypress"] = "Numeric(event, this)";

                tbQuantity.Text      = HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeDefaultValue.ToString();
                tbQuantity.MaxLength = HLConfigManager.Configurations.DOConfiguration.HFFSkuMaxQuantity.ToString().Length;

                lblHFFMsg.Text = string.Empty;
                divMsg.Visible = false;
            }

            lblHFFCurrencyType.Text = HLConfigManager.Configurations.DOConfiguration.HasHFFUnitDescription
                                          ? HLConfigManager.Configurations.DOConfiguration.HFFUnitDescription
                                          : HLConfigManager.Configurations.CheckoutConfiguration.CurrencySymbol;
            ClearDonation.Visible = ClearDonation2.Visible = HLConfigManager.Configurations.DOConfiguration.CanCancelDonation;

            if (ClearDonation.Visible || ClearDonation2.Visible)
            {
                if (this.ShoppingCart.Totals != null)
                {
                    OrderTotals_V02 totals = ShoppingCart.Totals as OrderTotals_V02;
                    if (totals != null)
                    {
                        ClearDonation.Visible = ClearDonation2.Visible = totals.Donation > decimal.Zero;
                    }
                }
            }
        }
Esempio n. 15
0
        private decimal GetBehalfDonationAmount()
        {
            if (blErrors != null)
            {
                blErrors.Items.Clear();
            }
            decimal _totalDonation = decimal.Zero;

            try
            {
                _otherAmount = 0;
                string phone =
                    txtContactNumber.Text.Replace("_", String.Empty)
                    .Replace("(", String.Empty)
                    .Replace(")", String.Empty)
                    .Replace("-", String.Empty)
                    .Trim();
                if (btnBehalf5Rmb.Checked)
                {
                    _behalfAmount = 5;
                }
                else if (btnBehalf10Rmb.Checked)
                {
                    _behalfAmount = 10;
                }
                else if (!String.IsNullOrEmpty(txtOtherAmount2.Text.ToString()) && decimal.TryParse(txtOtherAmount2.Text.ToString(), out _otherAmount))
                {
                    _behalfAmount = _otherAmount;
                }
                else if (btnBehalfOther.Checked)
                {
                    txtOtherAmount2.Enabled = true;
                }

                SessionInfo.CancelBehalfOfDonation = SessionInfo.CancelBehalfOfDonation + _behalfAmount;

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

                var cart = ShoppingCart as MyHLShoppingCart;

                if (_behalfAmount > 0)
                {
                    if (String.IsNullOrEmpty(txtDonatorName.Text.Trim()))
                    {
                        //isValidDonation = false;
                        //ShowError("NoCustomerNameEntered");
                        txtDonatorName.Text = "匿名";
                    }

                    if (String.IsNullOrEmpty(phone) || phone.Length < 11)
                    {
                        isValidDonation = false;
                        ShowError("NoCustomerPhoneNoEntered");
                    }
                    if (!isValidDonation)
                    {
                        if (errors != null && errors.Count > 0)
                        {
                            blErrors.DataSource = errors;
                            blErrors.DataBind();
                            errors.Clear();
                            return(0);
                        }
                    }
                    cart.BehalfDonationName    = txtDonatorName.Text;
                    cart.BehalfOfContactNumber = phone;
                    cart.BehalfOfMemberId      = DistributorID;

                    if (cart.BehalfOfAmount > 0)
                    {
                        cart.BehalfOfAmount = cart.BehalfOfAmount + _behalfAmount;
                    }
                    else
                    {
                        cart.BehalfOfAmount = _behalfAmount;
                    }

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

                if ((_behalfAmount > 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 (_behalfAmount > decimal.Zero)
                    {
                        _totalDonation = _behalfAmount;
                    }
                }
                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);
        }
Esempio n. 16
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);
        }
        private void GetQuotes(Order order, OrderTotals total, bool calcFreight, out OrderTotals_V02 totals)
        {
            var shoppingCartLaoder = Substitute.For <IShoppingCartProviderLoader>();

            shoppingCartLaoder.GetQuote(order, total, calcFreight).Returns(GetQuote(order, out totals, calcFreight));
        }
        public void ProcessVolumePromotionPCFebPromo_Test()
        {
            var promoelement = new PromotionElement
            {
                StartDate            = "02-01-2016",
                EndDate              = "05-01-2016",
                PromotionType        = MyHerbalife3.Ordering.ServiceProvider.OrderChinaSvc.PromotionType.Volume,
                HasIncrementaldegree = true,
                VolumeMinInclude     = 200,
                CustTypeList         = new List <string>
                {
                    "DS", "FM", "SC", "SP", "SQ"
                },
                FreeSKUList = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "543P"
                    },
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "547P"
                    },
                },
                SelectableSKUList = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 2,
                        SKU      = "1447"
                    },
                },
            };

            promoelement.Code = "00015";
            var cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("CN640521", "zh-CN", "20", "3019",
                                                                      new ShippingAddress_V02());

            cart.CartItems = new ShoppingCartItemList
            {
                ShoppingCartItemHelper.GetCartItem(1, 1, "1316"),
                ShoppingCartItemHelper.GetCartItem(2, 1, "1447"),
            };
            var order = new Order_V01();

            order.DistributorID = "CN1632369";
            var orderitem1 = new OnlineOrderItem()
            {
                Quantity    = 10,
                SKU         = "1316",
                Description = "",
                RetailPrice = 0,
                IsPromo     = false,
            };
            var orderitem2 = new OnlineOrderItem()
            {
                Quantity    = 2,
                SKU         = "1447",
                Description = "",
                RetailPrice = 0,
                IsPromo     = false,
            };

            order.OrderItems = new OrderItems {
                orderitem1, orderitem2
            };
            order.Shipment = new ShippingInfo_V01
            {
                Address = new MyHerbalife3.Ordering.ServiceProvider.OrderSvc.Address
                {
                    City    = "眉山市",
                    Country = "cn"
                },
                ShippingMethodID = "22",
                WarehouseCode    = "3019"
            };
            order.CountryOfProcessing = "CN";
            var ordertotal = new OrderTotals_V02();

            GetQuotes(order, ordertotal, false, out ordertotal);
            var promorule = new MyHerbalife3.Ordering.Rules.Promotional.zh_CN.PromotionalRules();

            cart.Totals = ordertotal;
            FreeSKUCollection skuCollection = promorule.DSPromo(promoelement, cart);

            Assert.AreEqual(skuCollection[0].Quantity, 2);
        }
Esempio n. 19
0
        private void DonationClicked()
        {
            int quantity = 0;

            if (int.TryParse(tbQuantity.Text.Trim(), out quantity))
            {
                var myShoppingCart = (Page as ProductsBase).ShoppingCart;

                //Add the donation amount to cart
                if (!string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku) ||
                    (HLConfigManager.Configurations.DOConfiguration.HFFSkuList != null && HLConfigManager.Configurations.DOConfiguration.HFFSkuList.Count > 0))
                {
                    try
                    {
                        if (quantity > 0)
                        {
                            if (!ProductsBase.AddHFFSKU(quantity))
                            {
                                lblHFFMsg.Text =
                                    string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                            "AddHFFFailed"));
                                divMsg.Visible = true;
                            }
                            else
                            {
                                lblHFFMsg.Text =
                                    string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                            "AddHFFSucceeded"));
                                divMsg.Visible = true;
                            }
                        }
                        else
                        {
                            lblHFFMsg.Text =
                                string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero"));
                            divMsg.Visible = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error("HFF Herbalife Can not be added to cart!\n" + ex);
                    }
                }
                else if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                {
                    if (myShoppingCart.Totals == null)
                    {
                        myShoppingCart.Totals = new OrderTotals_V02();
                    }

                    if (myShoppingCart.Totals != null)
                    {
                        OrderTotals_V02 totals = myShoppingCart.Totals as OrderTotals_V02;
                        if (totals != null)
                        {
                            totals.Donation = decimal.Parse(quantity.ToString());
                            myShoppingCart.Calculate();
                            OnQuoteRetrieved(null, null);

                            lblHFFMsg.Text =
                                string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                        "AddHFFSucceeded"));
                            divMsg.Visible        = true;
                            ClearDonation.Visible = ClearDonation2.Visible = true;
                        }
                    }

                    tbQuantity.Text = HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeDefaultValue.ToString();
                }
                else
                {
                    LoggerHelper.Error(string.Format("HFF SKU missing from Config for {0}.", Locale));
                }
            }
            else
            {
                tbQuantity.Text = string.Empty;
                lblHFFMsg.Text  = PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero");
                divMsg.Visible  = true;
            }
        }
Esempio n. 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((null != ProductsBase.SessionInfo && ProductsBase.SessionInfo.IsEventTicketMode) || this.ShoppingCart.OrderCategory == OrderCategoryType.HSO)
            {
                divHFF.Visible = false;
                hffPanel.Update();
                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    hlHFF.Visible    = false;
                    hffPanel.Visible = false;
                }
                return;
            }
            if (HLConfigManager.Configurations.DOConfiguration.IsChina)
            {
                if (CatalogProvider.IsPreordering(ShoppingCart.CartItems, (ShoppingCart.DeliveryInfo != null ? ShoppingCart.DeliveryInfo.WarehouseCode : string.Empty)))
                {
                    hlHFF.Visible    = false;
                    hffPanel.Visible = false;
                    return;
                }
            }
            // Verify special rules to show the module
            ShowModule();
            if (!divHFF.Visible)
            {
                return;
            }

            hlHFF.NavigateUrl = HLConfigManager.Configurations.DOConfiguration.HFFUrl;
            hlHFF.Visible     = !string.IsNullOrEmpty(hlHFF.NavigateUrl) &&
                                HLConfigManager.Configurations.DOConfiguration.ShowHFFBox;

            if (!IsPostBack)
            {
                //tbQuantity.Attributes["onkeypress"] = "Numeric(event, this)";

                // tbQuantity.Text = HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeDefaultValue.ToString();
                var OrderTotals = ShoppingCart != null ? ShoppingCart.Totals != null ? ShoppingCart.Totals as OrderTotals_V02 : null : null;
                if (HLConfigManager.Configurations.DOConfiguration.IsChina && OrderTotals != null && OrderTotals.Donation > 0 && SessionInfo.StandAloneDonationNotSubmit > 0)
                {
                    SessionInfo.ClearStandAloneDonation();
                    OnStandAloneDonationClear(this, e);
                }
                lblHFFMsg.Text = string.Empty;
                divMsg.Visible = false;
                DefaultRightRialDonation();
                btnSelf.CssClass = "activeTab";
            }
            if (!IsChina)
            {
                lblHFFCurrencyType.Text = HLConfigManager.Configurations.DOConfiguration.HasHFFUnitDescription
                                              ? HLConfigManager.Configurations.DOConfiguration.HFFUnitDescription
                                              : HLConfigManager.Configurations.CheckoutConfiguration.CurrencySymbol;
            }
            ClearDonation.Visible = ClearDonation2.Visible = ClearBehalfDonation2.Visible = HLConfigManager.Configurations.DOConfiguration.CanCancelDonation;

            if (ClearDonation.Visible || ClearDonation2.Visible || ClearBehalfDonation2.Visible)
            {
                if (this.ShoppingCart.Totals != null)
                {
                    OrderTotals_V02 totals = ShoppingCart.Totals as OrderTotals_V02;
                    if (totals != null)
                    {
                        ClearDonation.Visible = ClearDonation2.Visible = ClearBehalfDonation2.Visible = totals.Donation > decimal.Zero;
                    }
                }
            }
        }
        public void ProcessOtherMarchPromotionPC_Test()
        {
            var Promotion = new PromotionElement
            {
                StartDate            = "01-01-2016",
                EndDate              = "01-31-2016",
                PromotionType        = ServiceProvider.OrderChinaSvc.PromotionType.Other,
                HasIncrementaldegree = true,
                AmountMinInclude     = 2000,
                CustTypeList         = new List <string>
                {
                    "PC", "CS"
                },
                FreeSKUList = new FreeSKUCollection
                {
                    new FreeSKU
                    {
                        Quantity = 1,
                        SKU      = "560P"
                    }
                },
            };

            Promotion.Code = "00017";
            var Cart = MyHLShoppingCartGenerator.GetBasicShoppingCart("CN1632369 ", "zh-CN", "20", "3019",
                                                                      new ShippingAddress_V02());

            Cart.CartItems = new ShoppingCartItemList
            {
                ShoppingCartItemHelper.GetCartItem(1, 1, "1316"),
                ShoppingCartItemHelper.GetCartItem(2, 1, "1317"),
            };

            var Order = new Order_V01();

            Order.DistributorID = "CN1632369";
            var order1 = new OnlineOrderItem()
            {
                Quantity    = 10,
                SKU         = "1316",
                Description = "",
                RetailPrice = 0,
                IsPromo     = false,
            };

            Order.OrderItems = new OrderItems {
                order1
            };
            Order.Shipment = new ShippingInfo_V01
            {
                Address = new ServiceProvider.OrderSvc.Address()
                {
                    City    = "眉山市",
                    Country = "cn"
                },
                ShippingMethodID = "22",
                WarehouseCode    = "3019"
            };

            Order.CountryOfProcessing = "CN";
            var ordertotal = new OrderTotals_V02();

            GetQuotes(Order, ordertotal, false, out ordertotal);
            var promorule = new MyHerbalife3.Ordering.Rules.Promotional.zh_CN.PromotionalRules();

            Cart.Totals = ordertotal;
            FreeSKUCollection skuCollection = promorule.CheckPcPromo(Promotion, Cart);

            Assert.AreEqual(skuCollection[0].Quantity, 2);
        }
Esempio n. 22
0
        protected override void BindTotals()
        {
            var lstShoppingCartItems = (Page as ProductsBase).ShoppingCart.ShoppingCartItems;

            try
            {
                if ((HLConfigManager.Configurations.DOConfiguration.CalculateWithoutItems &&
                     _shoppingCart.Totals != null &&
                     (_shoppingCart.Totals as OrderTotals_V01).AmountDue != decimal.Zero) || (lstShoppingCartItems.Count > 0 && ShoppingCart.Totals != null))

                //                if (lstShoppingCartItems.Count > 0 && ShoppingCart.Totals != null)
                {
                    OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01;

                    lblDiscountRate.Text = _shoppingCart.Totals == null
                                               ? "0%"
                                               : ((_shoppingCart.Totals as OrderTotals_V01).DiscountPercentage).ToString() + "%";
                    _shoppingCart.EmailValues.DistributorSubTotal          = OrderProvider.GetDistributorSubTotal(_shoppingCart.Totals as OrderTotals_V01);
                    _shoppingCart.EmailValues.DistributorSubTotalFormatted = getAmountString(_shoppingCart.EmailValues.DistributorSubTotal);
                    lblDistributorSubtotal.Text = _shoppingCart.EmailValues.DistributorSubTotalFormatted;
                    lblEarnBase.Text            = getAmountString(GetTotalEarnBase(lstShoppingCartItems));
                    if (lblDiscountTotal != null)
                    {
                        lblDiscountTotal.Text =
                            getAmountString(CheckoutTotalsDetailed.GetDiscountTotal(lstShoppingCartItems));
                    }

                    // added for China DO
                    if (HLConfigManager.Configurations.CheckoutConfiguration.HasDiscountAmount)
                    {
                        OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                        if (totals_V02 != null)
                        {
                            HLRulesManager.Manager.PerformDiscountRules(_shoppingCart, null, Locale,
                                                                        ShoppingCartRuleReason.CartCalculated);
                            lblDiscountAmount.Text = getAmountString(totals_V02.DiscountAmount);
                            trDiscountRate.Visible = false;
                        }
                    }
                    if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                    {
                        if (trDonationAmount != null)
                        {
                            trDonationAmount.Visible = true;
                            OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                            if (totals_V02 != null)
                            {
                                lblDonationAmount.Text = getAmountString(totals_V02.Donation);
                            }
                        }
                    }
                    lblOrderMonth.Text = GetOrderMonthString();

                    decimal currentMonthVolume = 0;
                    if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayFormatNeedsDecimal)
                    {
                        lblOrderMonthVolume.Text = decimal.TryParse(ProductsBase.CurrentMonthVolume, NumberStyles.Any, CultureInfo.InstalledUICulture, out currentMonthVolume)
                            ? ProductsBase.GetVolumePointsFormat(currentMonthVolume) :
                                                   (Page as ProductsBase).CurrentMonthVolume;
                    }
                    else if (decimal.TryParse((Page as ProductsBase).CurrentMonthVolume, out currentMonthVolume))
                    {
                        lblOrderMonthVolume.Text = ProductsBase.GetVolumePointsFormat(currentMonthVolume);
                    }
                    else
                    {
                        lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume;
                    }


                    Charge_V01 otherCharges =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.OTHER); }) as
                        Charge_V01 ?? new Charge_V01(ChargeTypes.OTHER, (decimal)0.0);
                    Charge_V01 pHCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.PH); }) as Charge_V01 ??
                        new Charge_V01(ChargeTypes.PH, (decimal)0.0);
                    Charge_V01 freightCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.FREIGHT); }) as
                        Charge_V01 ?? new Charge_V01(ChargeTypes.FREIGHT, (decimal)0.0);
                    Charge_V01 localTaxCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOCALTAX); }) as
                        Charge_V01 ?? new Charge_V01(ChargeTypes.LOCALTAX, (decimal)0.0);
                    lblOtherCharges.Text = getAmountString(otherCharges.Amount);
                    lblLocalTax.Text     = getAmountString(localTaxCharge.Amount);
                    Charge_V01 logisticCharge =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOGISTICS_CHARGE); })
                        as Charge_V01 ?? new Charge_V01(ChargeTypes.LOGISTICS_CHARGE, (decimal)0.0);
                    lblLogisticCharges.Text = getAmountString(logisticCharge.Amount);
                    lblPackageHandling.Text = getAmountString(pHCharge.Amount + totals.MarketingFundAmount);
                    lblShippingCharges.Text = getAmountString(freightCharge.Amount);
                    lblRetailPrice.Text     = getAmountString(totals.ItemsTotal);

                    decimal vatTax = totals.VatTax != null ? (decimal)totals.VatTax : decimal.Zero;
                    lblTaxVAT.Text = getAmountString(vatTax);

                    //Changes as per User Story 235045
                    bool    hideLabels = RemovePHCharge();
                    decimal serviceTax = totals.ServiceTax != null ? (decimal)totals.ServiceTax: decimal.Zero;
                    lblServiceTax.Text = getAmountString(serviceTax);
                    if (serviceTax == 0)
                    {
                        serviceTAX.Visible = hideLabels ? false : true;
                    }

                    decimal bharatTax = totals.SwachhBharatCess != null ? (decimal)totals.SwachhBharatCess : decimal.Zero;
                    lblBharatCessTax.Text = getAmountString(bharatTax);
                    if (bharatTax == 0)
                    {
                        bharatCessTAX.Visible = hideLabels ? false : true;
                    }

                    var kkcEnabled = HL.Common.Configuration.Settings.GetRequiredAppSetting("KKCEnabled", false);
                    if (kkcEnabled)
                    {
                        decimal krishiTax = totals.KrishiKalyanCess != null ? (decimal)totals.KrishiKalyanCess : decimal.Zero;
                        lblKKCTax.Text = getAmountString(krishiTax);
                        if (krishiTax == 0)
                        {
                            kkcTax.Visible = hideLabels ? false : true;
                        }
                    }
                    else
                    {
                        kkcTax.Visible = false;
                    }
                    //User Story 251995:GDO[PRODUCTION SUPPORT]: IN: For fixing the Tax display issue on GDO Checkout page for Additional/Exceptional Tax applicable states
                    decimal AdditionalTax = totals.AdditionalTaxCess != null ? (decimal)totals.AdditionalTaxCess : decimal.Zero;
                    lblAdditionalTax.Text = getAmountString(AdditionalTax);
                    if (AdditionalTax == 0)
                    {
                        additionalTax.Visible = hideLabels ? false : true;
                    }
                    decimal CSTTax = totals.CstTax != null ? (decimal)totals.CstTax : decimal.Zero;
                    lblCSTTax.Text = getAmountString(CSTTax);
                    if (CSTTax == 0)
                    {
                        cstTax.Visible = hideLabels ? false : true;
                    }
                    //

                    if (lblSubtotal != null)
                    {
                        lblSubtotal.Text = getAmountString(logisticCharge.Amount);
                    }
                    if (lblAdditionalDiscount != null)
                    {
                        lblAdditionalDiscount.Text = getAmountString(otherCharges.Amount);
                    }
                    lblVolumePoints.Text = ProductsBase.GetVolumePointsFormat(totals.VolumePoints);
                }
                else
                {
                    if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                    {
                        if (trDonationAmount != null)
                        {
                            trDonationAmount.Visible = true;
                            OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                            if (totals_V02 != null)
                            {
                                lblDonationAmount.Text = getAmountString(totals_V02.Donation);
                            }
                        }
                    }

                    DisplayEmptyLabels();
                }
            }
            catch (Exception ex)
            {
                //Log Exception
                LoggerHelper.Error("Exception while displaying totals - " + ex);
                DisplayEmptyLabels();
            }
        }
        private void BindTotals()
        {
            //init etosku
            InitEtoPanel();
            try
            {
                if (ShoppingCart != null)
                {
                    var lstShoppingCartItems = ShoppingCart.ShoppingCartItems;
                    if (lstShoppingCartItems.Count > 0 && ShoppingCart.Totals != null)
                    {
                        MyHLShoppingCart shoppingCart = ProductsBase.ShoppingCart;
                        OrderTotals_V01  totals       = shoppingCart.Totals as OrderTotals_V01;
                        lblDiscountRate.Text =
                            HLConfigManager.Configurations.CheckoutConfiguration.ShowVolumePointRange ?
                            HLRulesManager.Manager.PerformDiscountRangeRules(shoppingCart, Locale, ProductsBase.DistributorDiscount) : (totals.DiscountPercentage).ToString() + "%";
                        trDiscountRate.Visible = !string.IsNullOrEmpty(lblDiscountRate.Text);

                        if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                        {
                            if (ShoppingCart.OrderCategory == OrderCategoryType.ETO && SessionInfo != null && !SessionInfo.IsReplacedPcOrder)
                            {
                                GetEligibleUseETOPoints();
                            }
                            else
                            {
                                GetEligibleUsePoint();
                            }
                            if (shoppingCart != null && shoppingCart.pcLearningPointOffSet > 0)
                            {
                                txtPCLearningPoint.Text = shoppingCart.pcLearningPointOffSet.ToString();
                            }
                            else
                            {
                                txtPCLearningPoint.Text = "0";
                            }
                            // added for China DO
                            if (HLConfigManager.Configurations.CheckoutConfiguration.HasDiscountAmount)
                            {
                                OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                                if (totals_V02 != null)
                                {
                                    HLRulesManager.Manager.PerformDiscountRules(ShoppingCart, null, Locale,
                                                                                ShoppingCartRuleReason.CartCalculated);
                                    trDiscountTotal.Visible = totals_V02.DiscountAmount > 0;
                                    lblDiscountTotal.Text   = getAmountString(totals_V02.DiscountAmount);
                                    trDiscountRate.Visible  = false;
                                }
                            }

                            if ((HLConfigManager.Configurations.DOConfiguration.CalculateWithoutItems &&
                                 ShoppingCart.Totals != null &&
                                 (ShoppingCart.Totals as OrderTotals_V01).AmountDue != decimal.Zero) || (ShoppingCart.CartItems.Count > 0 && ShoppingCart.Totals != null))
                            {
                                if (HLConfigManager.Configurations.CheckoutConfiguration.ConvertAmountDue)
                                {
                                    decimal amountDue = OrderProvider.GetConvertedAmount(totals.AmountDue, CountryCode);
                                    if (HLConfigManager.Configurations.PaymentsConfiguration.RoundAmountDue == "Standard")
                                    {
                                        amountDue = Math.Round(amountDue);
                                    }
                                    if (DistributorOrderingProfile.IsPC)
                                    {
                                        if (HttpContext.Current.Request.UrlReferrer != null &&
                                            HttpContext.Current.Request.UrlReferrer.ToString().Contains("Checkout.aspx"))
                                        {
                                            totals.AmountDue   = ShoppingCart.AmountduepriorpcLearningoffset;
                                            lblGrandTotal.Text =
                                                getAmountString(shoppingCart.AmountduepriorpcLearningoffset, true);
                                        }
                                        else
                                        {
                                            lblGrandTotal.Text = getAmountString(amountDue, true);
                                        }
                                    }
                                    else
                                    {
                                        lblGrandTotal.Text = getAmountString(amountDue, true);
                                    }
                                }
                                else
                                {
                                    if (HLConfigManager.Configurations.PaymentsConfiguration.RoundAmountDue == "Standard")
                                    {
                                        totals.AmountDue = Math.Round(totals.AmountDue);
                                    }
                                    if (DistributorOrderingProfile.IsPC)
                                    {
                                        if (HttpContext.Current.Request.UrlReferrer != null &&
                                            HttpContext.Current.Request.UrlReferrer.ToString().Contains("Checkout.aspx"))
                                        {
                                            totals.AmountDue   = ShoppingCart.AmountduepriorpcLearningoffset;
                                            lblGrandTotal.Text =
                                                getAmountString(ShoppingCart.AmountduepriorpcLearningoffset);
                                        }
                                        else
                                        {
                                            lblGrandTotal.Text =
                                                getAmountString(ShoppingCart.Totals != null ? totals.AmountDue : (decimal)0.00);
                                        }
                                    }
                                    else
                                    {
                                        lblGrandTotal.Text =
                                            getAmountString(ShoppingCart.Totals != null ? totals.AmountDue : (decimal)0.00);
                                    }
                                }
                            }
                            if (IsReturnFromCheckout && ShoppingCart.OrderCategory == OrderCategoryType.ETO)
                            {
                                lblGrandTotal.Text = getAmountString(totals != null ? totals.ItemsTotal : 0M);
                                lblDisplayPCLearningPoint.ForeColor = System.Drawing.Color.Green;
                                lblDisplayPCLearningPoint.Font.Bold = true;
                            }
                        }
                        else
                        {
                            if (lblDiscountTotal != null)
                            {
                                lblDiscountTotal.Text =
                                    getAmountString(CheckoutTotalsDetailed.GetDiscountTotal(lstShoppingCartItems));
                            }
                        }

                        lblEarnBase.Text = getAmountString(CheckoutTotalsDetailed.GetTotalEarnBase(lstShoppingCartItems));

                        decimal currentMonthVolume = 0.00M;
                        if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayFormatNeedsDecimal)
                        {
                            lblOrderMonthVolume.Text = decimal.TryParse(ProductsBase.CurrentMonthVolume, NumberStyles.Any, CultureInfo.InstalledUICulture, out currentMonthVolume)
                                ? ProductsBase.GetVolumePointsFormat(currentMonthVolume) :
                                                       (Page as ProductsBase).CurrentMonthVolume;
                        }
                        else
                        {
                            lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume;
                        }

                        lblRetailPrice.Text  = getAmountString(totals.ItemsTotal);
                        lblSubtotal.Text     = getAmountString(totals.DiscountedItemsTotal);
                        lblVolumePoints.Text = ProductsBase.GetVolumePointsFormat(totals.VolumePoints);

                        if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                        {
                            if (totals.ChargeList != null)
                            {
                                Charge_V01 otherCharges =
                                    totals.ChargeList.Find(
                                        delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.OTHER); }) as
                                    Charge_V01 ?? new Charge_V01(ChargeTypes.OTHER, (decimal)0.0);
                                Charge_V01 pHCharge =
                                    totals.ChargeList.Find(
                                        delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.PH); }) as Charge_V01 ??
                                    new Charge_V01(ChargeTypes.PH, (decimal)0.0);
                                Charge_V01 freightCharge =
                                    totals.ChargeList.Find(
                                        delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.FREIGHT); }) as
                                    Charge_V01 ?? new Charge_V01(ChargeTypes.FREIGHT, (decimal)0.0);
                                Charge_V01 localTaxCharge =
                                    totals.ChargeList.Find(
                                        delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOCALTAX); }) as
                                    Charge_V01 ?? new Charge_V01(ChargeTypes.LOCALTAX, (decimal)0.0);
                                lblOtherCharges.Text = getAmountString(otherCharges.Amount);
                                lblLocalTax.Text     = getAmountString(localTaxCharge.Amount);
                                Charge_V01 logisticCharge =
                                    totals.ChargeList.Find(
                                        delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOGISTICS_CHARGE); })
                                    as Charge_V01 ?? new Charge_V01(ChargeTypes.LOGISTICS_CHARGE, (decimal)0.0);
                                lblLogisticCharges.Text = getAmountString(logisticCharge.Amount);
                                lblPackageHandling.Text = getAmountString(pHCharge.Amount);
                                lblShippingCharges.Text = getAmountString(freightCharge.Amount);

                                //added for HR
                                if (HLConfigManager.Configurations.CheckoutConfiguration.MergePHAndShippingCharges)
                                {
                                    decimal phShippingCharges = pHCharge.Amount + freightCharge.Amount;
                                    lblPackageHandling.Text = getAmountString(phShippingCharges);
                                }
                            }
                            lblTaxVAT.Text = getAmountString(totals.TaxAmount);
                        }
                        else
                        {
                            lblRetailPrice.Text = getAmountString((ShoppingCart.Totals as OrderTotals_V01).ItemsTotal);
                            lblSubtotal.Text    = getAmountString(OrderProvider.GetDistributorSubTotal(ShoppingCart.Totals as OrderTotals_V01));
                        }
                        if (HLConfigManager.Configurations.DOConfiguration.ShowFreightChrageonCOP1)
                        {
                            if (totals.ChargeList != null)
                            {
                                Charge_V01 freightCharge =
                                    totals.ChargeList.Find(
                                        delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.FREIGHT); }) as
                                    Charge_V01 ?? new Charge_V01(ChargeTypes.FREIGHT, (decimal)0.0);
                                lblShippingCharges.Text  = getAmountString(freightCharge.Amount);
                                trShippingCharge.Visible = !string.IsNullOrEmpty(lblShippingCharges.Text) && HLConfigManager.Configurations.DOConfiguration.ShowFreightChrageonCOP1 &&
                                                           shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping;
                            }
                        }
                        if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayWeight && !SessionInfo.IsEventTicketMode && lblWeight != null)
                        {
                            lblWeight.Text = ShoppingCartProvider.GetWeight(ShoppingCart);
                        }
                    }
                    else
                    {
                        if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                        {
                            if ((ShoppingCart.Totals == null || (ShoppingCart.Totals as OrderTotals_V01).AmountDue == 0.0M) &&
                                !(ShoppingCart.OrderCategory == OrderCategoryType.ETO && HLConfigManager.Configurations.DOConfiguration.AllowZeroPricingEventTicket) &&
                                (ShoppingCart.ShoppingCartItems != null && ShoppingCart.ShoppingCartItems.Any()))
                            {
                                OnQuoteError(null, null);
                            }

                            if (trDonationTotal != null)
                            {
                                trDonationTotal.Visible = true;
                                OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                                if (totals_V02 != null)
                                {
                                    lblDonationTotal.Text = getAmountString(totals_V02.Donation);
                                }
                            }
                            //trDiscountRate.Visible = false;
                            lblGrandTotal.Text = getAmountString(ShoppingCart.Totals != null ? (ShoppingCart.Totals as OrderTotals_V01).AmountDue : (decimal)0.00);
                        }

                        DisplayEmptyTotals();
                    }
                    if (ShoppingCart.Totals != null && HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                    {
                        if (trDonationTotal != null)
                        {
                            trDonationTotal.Visible = true;
                            OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                            if (totals_V02 != null)
                            {
                                lblDonationTotal.Text = getAmountString(totals_V02.Donation);
                            }
                        }
                    }
                }
                else
                {
                    if (trDonationTotal != null)
                    {
                        trDonationTotal.Visible = true;
                        OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                        if (totals_V02 != null)
                        {
                            lblDonationTotal.Text = getAmountString(totals_V02.Donation);
                        }
                    }
                    lblGrandTotal.Text = getAmountString(ShoppingCart.Totals != null ? (ShoppingCart.Totals as OrderTotals_V01).AmountDue : (decimal)0.00);
                    DisplayEmptyTotals();
                }
            }
            catch (Exception ex)
            {
                //Log Exception
                LoggerHelper.Error(string.Format("Exception while displaying totals. Message: {0}, StackTrace: {1}, TargetSite:{2}, DistributorID: {3}", ex.Message, ex.StackTrace, ex.TargetSite, DistributorID));

                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    if (trDonationTotal != null)
                    {
                        trDonationTotal.Visible = true;
                        OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                        if (totals_V02 != null)
                        {
                            lblDonationTotal.Text = getAmountString(totals_V02.Donation);
                        }
                    }
                }

                DisplayEmptyTotals();
            }
        }