private void DisplayRemainingValuesFOP(string DSSubType, bool Refresh, PurchasingLimits_V01 limits)
        {
            trRemainingVal.Visible = true;
            ShoppingCart.EmailValues.RemainingVolume = string.Empty;

            decimal cartVolume = ShoppingCart.VolumeInCart;

            if (null != limits)
            {
                decimal remaining = (limits.RemainingVolume - cartVolume);

                if (remaining < 0)
                {
                    remaining = 0;
                }
                lblRemainingValDisplay.Text = GetLocalResourceObject("RemainingVolume").ToString();
                lblRemainingVal.Text        = ProductsBase.GetVolumePointsFormat(remaining);
                ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text;
            }
        }
Beispiel #2
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();
            }
        }
        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();
            }
        }
 protected string GetVolumeString(decimal volumePoints)
 {
     return(ProductsBase.GetVolumePointsFormat(volumePoints));
 }
Beispiel #5
0
        private void loadCart()
        {
            decimal distributorDiscount = ProductsBase.DistributorDiscount;

            Totals = null;

            trSubtotal.Visible = HLConfigManager.Configurations.CheckoutConfiguration.DisplaySubTotalOnMinicart;
            if (ShoppingCart != null && ShoppingCart.CartItems != null)
            {
                totalQuantity = getTotalNumberItems(ShoppingCart.ShoppingCartItems);

                if (HLConfigManager.Configurations.DOConfiguration.IsResponsive && (Master as OrderingMaster).IsMobile())
                {
                    (Master as OrderingMaster).setTotalItemsMobile(totalQuantity);
                }

                if (HLConfigManager.Configurations.DOConfiguration.ShowTotalItems)
                {
                    TotalQty.Visible   = true;
                    lbNumItems.Visible = true;
                    TotalQty.Text      = totalQuantity.ToString();
                }
                else
                {
                    TotalQty.Visible   = false;
                    lbNumItems.Visible = false;
                }
                CartItemListView.DataSource = ShoppingCart.SelectMaxItems();
                CartItemListView.DataBind();
                if (ShoppingCart.Totals != null && ShoppingCart.CartItems.Count > 0)
                {
                    OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01;
                    if (HLConfigManager.Configurations.CheckoutConfiguration.YourPriceWithAllCharges &&
                        null != totals.ItemTotalsList)
                    {
                        uxSubtotal.Text = getAmountString(OrderProvider.getPriceWithAllCharges(ShoppingCart.Totals as OrderTotals_V01));
                    }
                    else
                    {
                        uxSubtotal.Text = getAmountString(totals.DiscountedItemsTotal);
                    }

                    uxVolume.Text = ProductsBase.GetVolumePointsFormat(totals.VolumePoints);
                    if (DistributorOrderingProfile != null && DistributorOrderingProfile.IsPC)
                    {
                        TxtVolumePoint.Visible = uxVolume.Visible = false;
                    }
                    if (!HLConfigManager.Configurations.CheckoutConfiguration.HasOrderMonthVolumePoints)
                    {
                        trOrderMonthVP.Visible = false;
                    }
                    if (HLConfigManager.Configurations.CheckoutConfiguration.ShowVolumePointRange)
                    {
                        uxVolumePointRange.Text = HLRulesManager.Manager.PerformDiscountRangeRules(ShoppingCart, Locale,
                                                                                                   ProductsBase
                                                                                                   .DistributorDiscount);
                        trVolumePointRange.Visible = !string.IsNullOrEmpty(uxVolumePointRange.Text);
                        trDiscountRate.Visible     = false;
                    }
                    else
                    {
                        uxDiscountRate.Text = (totals.DiscountPercentage).ToString() + "%";
                    }
                    Totals = ShoppingCart.Totals as OrderTotals_V01;
                }
                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);
                        }
                    }

                    uxVolume.Text = ProductsBase.GetVolumePointsFormat(0.00M);
                    if (DistributorOrderingProfile != null && DistributorOrderingProfile.IsPC)
                    {
                        TxtVolumePoint.Visible = uxVolume.Visible = false;
                    }
                    if (HLConfigManager.Configurations.CheckoutConfiguration.ShowVolumePointRange)
                    {
                        uxVolumePointRange.Text = HLRulesManager.Manager.PerformDiscountRangeRules(ShoppingCart, Locale,
                                                                                                   ProductsBase
                                                                                                   .DistributorDiscount);
                        trVolumePointRange.Visible = !string.IsNullOrEmpty(uxVolumePointRange.Text);
                        trDiscountRate.Visible     = false;
                    }
                    else
                    {
                        uxDiscountRate.Text = (distributorDiscount).ToString() + "%";
                    }
                    uxSubtotal.Text = getAmountString((0.00M));
                }

                lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume;
                if (!HLConfigManager.Configurations.CheckoutConfiguration.HasOrderMonthVolumePoints)
                {
                    trOrderMonthVP.Visible = false;
                }

                //New Code to hide/display the ?

                string levelDSType = (Page as ProductsBase).Level;
                if (levelDSType == "DS")
                {
                    imgOrderMonth.Visible = true;
                }
                else
                {
                    imgOrderMonth.Visible = false;
                }

                noItem.Visible           = false;
                noItemToPurchase.Visible = false;
                if (ShoppingCart.CartItems.Count == 0)
                {
                    //New use case  GlobalDO_UC_08.0 Can checkout with empty cart
                    //this.noItem.Visible = true;
                    //this.noItemToPurchase.Visible = false;
                    //this.RecentlyAdded.Visible = false;
                }
            }
            else
            {
                if (HLConfigManager.Configurations.CheckoutConfiguration.ShowVolumePointRange)
                {
                    uxVolumePointRange.Text = HLRulesManager.Manager.PerformDiscountRangeRules(ShoppingCart, Locale,
                                                                                               ProductsBase
                                                                                               .DistributorDiscount);
                    trVolumePointRange.Visible = !string.IsNullOrEmpty(uxVolumePointRange.Text);
                    trDiscountRate.Visible     = false;
                }
                else
                {
                    uxDiscountRate.Text = (distributorDiscount).ToString() + "%";
                }
                noItem.Visible           = true;
                noItemToPurchase.Visible = false;

                if (!HLConfigManager.Configurations.CheckoutConfiguration.HasOrderMonthVolumePoints)
                {
                    trOrderMonthVP.Visible = false;
                }
            }

            // Only call the update if the control has not been rendered yet.
            // This may need to be re-worked to properly update when the quote is recalculated
            // on changes of shipping location, etc by the ShippingInfoControl.
            //if (!this._isRendered)
            //{
            //upMiniCart.Update();
            //}
            ShowClearCartLink();
        }
Beispiel #6
0
        private void DisplayRemaining(string orderSubType)
        {
            //string DSType = ProductsBase.LevelSubType;
            ShoppingCart.EmailValues.RemainingVolume = string.Empty;
            //ShoppingCart.SelectedDSSubType = orderSubType;

            PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, orderSubType);
            decimal cartVolume          = 0M;

            if (null != limits)
            {
                if (FOPEnabled)
                {
                    if (limits.PurchaseLimitType == PurchaseLimitType.TotalPaid)
                    {
                        cartVolume = TotalsExcludeAPF(ShoppingCart, this.CountryCode);
                        lblRemainingValDisplay.Text = GetLocalResourceObject("RemainingAmount").ToString();
                    }
                    else
                    {
                        cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart;
                    }
                }
                else
                {
                    var purchasingLimitManager = PurchasingLimitManager(this.DistributorID);
                    cartVolume = (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) ? ShoppingCart.VolumeInCart : ShoppingCart.ProductVolumeInCart;
                }
                decimal remaining = (limits.RemainingVolume - cartVolume);

                if (remaining < 0)
                {
                    remaining = 0;
                }

                if (limits.PurchaseLimitType == PurchaseLimitType.Volume)
                {
                    lblRemainingVal.Text = ProductsBase.GetVolumePointsFormat(remaining);
                }
                //else
                //{
                //    lblRemainingVal.Text = ProductsBase.getAmountString(remaining);
                //}
            }

            if (PurchasingLimitProvider.DisplayLimits(DistributorID, CountryCode))
            {
                if (HasMemberVPLimitations())
                {
                    trRemainingVal.Visible = null != limits ? true : false;
                    //trRemainingVal.Visible = null != limits &&
                    //                         (limits.PurchaseLimitType == PurchaseLimitType.Earnings ||
                    //                          limits.PurchaseLimitType == PurchaseLimitType.Volume ||
                    //                          limits.PurchaseLimitType == PurchaseLimitType.TotalPaid);
                    PurchaseLimitType limitType = PurchaseLimitType.Volume;
                    limits.PurchaseLimitType = limitType;
                }
                else
                {
                    if (limits.LimitsRestrictionType == LimitsRestrictionType.FOP)
                    {
                        trRemainingVal.Visible = null != limits ? true : false; //Show remaining VP when FOP regardless of Limitations
                    }
                    else
                    {
                        trRemainingVal.Visible = false;
                    }
                }
            }
            else
            {
                trRemainingVal.Visible = false;
            }

            if (trRemainingVal.Visible)
            {
                ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text;
            }
        }
Beispiel #7
0
        private void DisplayRemaining()
        {
            string DSType = ProductsBase.LevelSubType;

            ShoppingCart.EmailValues.RemainingVolume = string.Empty;

            PurchasingLimits_V01 limits = PurchasingLimitProvider.GetPurchasingLimits(DistributorID, DSType);

            ShoppingCart.SelectedDSSubType = !countries.Trim().Contains(Locale.Substring(3)) ? DSType : "";
            //var purchasingLimitManager = PurchasingLimitManager(this.DistributorID);
            //decimal cartVolume = (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) ? ShoppingCart.VolumeInCart : ShoppingCart.ProductVolumeInCart;
            decimal cartVolume = 0M;

            if (null != limits)
            {
                if (FOPEnabled)
                {
                    if (limits.PurchaseLimitType == PurchaseLimitType.TotalPaid)
                    {
                        cartVolume = TotalsExcludeAPF(ShoppingCart, this.CountryCode);
                        lblRemainingValDisplay.Text = GetLocalResourceObject("RemainingAmount").ToString();
                    }
                    else
                    {
                        cartVolume = (limits.LimitsRestrictionType == LimitsRestrictionType.PurchasingLimits) ? ShoppingCart.ProductPromoVolumeInCart : ShoppingCart.VolumeInCart;
                    }
                }
                else
                {
                    var purchasingLimitManager = PurchasingLimitManager(this.DistributorID);
                    cartVolume = (purchasingLimitManager.PurchasingLimitsRestriction == PurchasingLimitRestrictionType.MarketingPlan) ? ShoppingCart.VolumeInCart : ShoppingCart.ProductVolumeInCart;
                }
                decimal remaining = (limits.RemainingVolume - cartVolume);

                if (remaining < 0)
                {
                    remaining = 0;
                }

                if (limits.PurchaseLimitType == PurchaseLimitType.Volume)
                {
                    lblRemainingVal.Text = ProductsBase.GetVolumePointsFormat(remaining);
                }
                else
                {
                    lblRemainingVal.Text = ProductsBase.getAmountString(remaining);
                }
            }

            if (PurchasingLimitProvider.DisplayLimits(DistributorID, CountryCode))
            {
                trRemainingVal.Visible = null != limits &&
                                         (limits.PurchaseLimitType == PurchaseLimitType.Earnings ||
                                          limits.PurchaseLimitType == PurchaseLimitType.Volume ||
                                          limits.PurchaseLimitType == PurchaseLimitType.TotalPaid);
            }
            else
            {
                trRemainingVal.Visible = false;
            }

            if (trRemainingVal.Visible)
            {
                ShoppingCart.EmailValues.RemainingVolume = lblRemainingVal.Text;
            }
        }
        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();
            }
        }