private OrderTotals_V01 GetTotals()
        {
            var totals = new OrderTotals_V01();
            var cart   = (Page as ProductsBase).ShoppingCart;

            if (null != cart)
            {
                if (null != cart.Totals)
                {
                    totals.AmountDue = (cart.Totals as OrderTotals_V01).AmountDue;
                }
            }
            //totals.AmountDue = 3566M;

            if (HLConfigManager.Configurations.CheckoutConfiguration.ConvertAmountDue)
            {
                decimal amountDue = OrderProvider.GetConvertedAmount((cart.Totals as OrderTotals_V01).AmountDue,
                                                                     (Page as ProductsBase).CountryCode);
                if (amountDue == 0.0M)
                {
                    LoggerHelper.Error("Exception while getting the currency conversion - ");
                    lblErrorMessages.Text = PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                      "CurrencyConversionFailed");
                    lblErrorMessages.Visible = true;
                    return(totals);
                }
                totals.AmountDue = amountDue;
            }

            return(totals);
        }
Esempio n. 2
0
        private decimal getAmountDue()
        {
            MyHLShoppingCart myCart;
            SessionInfo      sessionInfoMyCart = SessionInfo.GetSessionInfo(this._distributorId, this._locale);

            myCart = sessionInfoMyCart.ShoppingCart;
            if (myCart == null)
            {
                myCart = ShoppingCartProvider.GetShoppingCart(this._distributorId, this._locale);
            }

            OrderTotals_V01 totals = myCart.Totals as OrderTotals_V01;

            return(OrderProvider.GetConvertedAmount(totals.AmountDue, this._country));
        }
 public override void Submit()
 {
     try
     {
         PaymentRequest request = HttpContext.Current.Session["PGHInterface.aspx"] as PaymentRequest;
         if (null != request)
         {
             if (HLConfigManager.Configurations.PaymentsConfiguration.ConvertAmountDue)
             {
                 request.Amount = OrderProvider.GetConvertedAmount(request.Amount, this._country);
             }
             request.Submit();
         }
     }
     catch (Exception ex)
     {
         //Logging
         string s = ex.Message;
     }
     finally
     {
         HttpContext.Current.Session.Remove("PGHInterface.aspx");
     }
 }
Esempio n. 4
0
        protected override void DoPageLoad()
        {
            if (HLConfigManager.Configurations.PaymentsConfiguration.ShowBigGrandTotal)
            {
                lblGrandTotal.Attributes.Add("class", "Title");
                lblDisplayGrandTotal.Attributes.Add("class", "Title");
            }

            _shoppingCart = (Page as ProductsBase).ShoppingCart;
            BindTotals();

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

            // if (_shoppingCart.CartItems.Count > 0 && ShoppingCart.Totals != null)
            {
                OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01;
                if (HLConfigManager.Configurations.CheckoutConfiguration.ConvertAmountDue)
                {
                    decimal amountDue = OrderProvider.GetConvertedAmount(totals.AmountDue, CountryCode);
                    if (amountDue == 0.0M)
                    {
                        LoggerHelper.Error("Exception while getting the currency conversion - ");
                        DisplayEmptyLabels();
                        var eventArgs = new PageVisitRefusedEventArgs(Request.Url.PathAndQuery, String.Empty,
                                                                      PageVisitRefusedReason.UnableToPrice);
                        OnPageVisitRefused(this, eventArgs);
                        return;
                    }
                    if (HLConfigManager.Configurations.PaymentsConfiguration.RoundAmountDue == "Standard")
                    {
                        amountDue = Math.Round(amountDue);
                    }
                    lblGrandTotal.Text = getAmountString(amountDue, true);
                }
                else
                {
                    if (HLConfigManager.Configurations.PaymentsConfiguration.RoundAmountDue == "Standard")
                    {
                        totals.AmountDue = Math.Round(totals.AmountDue);
                    }
                    lblGrandTotal.Text =
                        getAmountString(_shoppingCart.Totals != null ? totals.AmountDue : (decimal)0.00);
                }
            }

            if (_shoppingCart.OrderCategory == OrderCategoryType.ETO ||
                !HLConfigManager.Configurations.CheckoutConfiguration.HasEarnBase)
            {
                if (_shoppingCart.OrderCategory == OrderCategoryType.ETO ||
                    !HLConfigManager.Configurations.CheckoutConfiguration.HasSummaryEarnBase)
                {
                    trEarnBase.Visible = false;
                }
            }

            //if (_shoppingCart.OrderCategory == HL.Common.ValueObjects.OrderCategoryType.ETO || HLConfigManager.Configurations.CheckoutConfiguration.HidePHShippingForETO)
            //{
            //    trPackageHandling.Visible = trShippingCharges.Visible = false;
            //}

            var control = loadPurchasingLimitsControl(true);

            if (control != null)
            {
                trLimits.Visible = true;
                pnlPurchaseLimits.Controls.Add(control);
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.HasOtherCharges)
            {
                trOtherCharges.Visible = true;
            }

            // Conditioning tax vat row visibility.
            if (trTaxVat != null)
            {
                trTaxVat.Visible = HLConfigManager.Configurations.CheckoutConfiguration.HasTaxVat;
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.HasLocalTax)
            {
                trLocalTax.Visible = true;
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.HasDiscountAmount)
            {
                trDiscountAmount.Visible = true;
            }

            if (trAdditionalDiscount != null)
            {
                trAdditionalDiscount.Visible = HLConfigManager.Configurations.CheckoutConfiguration.MergePHAndShippingCharges;
            }
            if (trSubtotal != null)
            {
                trSubtotal.Visible = HLConfigManager.Configurations.CheckoutConfiguration.MergePHAndShippingCharges;
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.HidePHShippingForETO)
            {
                if (SessionInfo.IsEventTicketMode)
                {
                    trPackingHandling.Visible = false;
                    trShippingCharge.Visible  = false;
                    if (!HLConfigManager.Configurations.CheckoutConfiguration.ShowVolumePoinsForETO)
                    {
                        trVolumePoints.Visible = false;
                    }
                    if (HLConfigManager.Configurations.CheckoutConfiguration.HasSubTotalOnTotalsDetailed)
                    {
                        trDistributorSubtotal.Visible = false;
                    }
                    else
                    {
                        trDistributorSubtotal.Visible = true;
                    }
                }
            }

            if (DistributorOrderingProfile != null && DistributorOrderingProfile.IsPC)
            {
                trVolumePoints.Visible = trOrderMonthVolume.Visible = false;
            }
            if (!HLConfigManager.Configurations.CheckoutConfiguration.HasOrderMonthVolumePoints)
            {
                trOrderMonthVolume.Visible = false;
            }
            if (HLConfigManager.Configurations.CheckoutConfiguration.HideFreightCharges && _shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup)
            {
                trShippingCharge.Visible = false;
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.HideShippingCharges)
            {
                trShippingCharge.Visible = false;
            }

            if (!HLConfigManager.Configurations.CheckoutConfiguration.HasRetailPrice)
            {
                if (trRetailPrice != null)
                {
                    trRetailPrice.Visible = false;
                }
            }
            else if (SessionInfo.IsEventTicketMode && trRetailPrice != null)
            {
                trRetailPrice.Visible = HLConfigManager.Configurations.CheckoutConfiguration.HasRetailPriceForETO;
            }

            if (HLConfigManager.Configurations.CheckoutConfiguration.HasLogisticCharges)
            {
                if (trLogisticCharge != null)
                {
                    trLogisticCharge.Visible = true;
                }
            }

            if (_shoppingCart.DeliveryInfo != null)
            {
                if (_shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Pickup)
                {
                    if (HLConfigManager.Configurations.CheckoutConfiguration.HasPickupCharge)
                    {
                        if (lblDisplayShippingCharges != null)
                        {
                            lblDisplayShippingCharges.Text = (string)GetLocalResourceObject("lblDisplayPickupCharges");
                        }
                    }
                    else
                    {
                        trShippingCharge.Visible = false;
                    }
                }
            }

            //New Code to hide/display the ?

            string levelDSType = (Page as ProductsBase).Level;

            if (levelDSType == "DS")
            {
                imgOrderMonth.Visible = true;
            }
            else
            {
                imgOrderMonth.Visible = false;
            }

            // Check for NPS updates.
            if (imgEarnBase != null)
            {
                imgEarnBase.Visible = ShowEarnBaseHelpInfo();
            }

            if (trDiscountTotal != null)
            {
                trDiscountTotal.Visible = HLConfigManager.Configurations.CheckoutConfiguration.ShowDisocuntTotal;
            }

            if (RemovePHCharge())
            {
                if (trPackingHandling != null)
                {
                    trPackingHandling.Visible = false;
                }
            }
        }
Esempio n. 5
0
 public decimal GetConvertedAmount(decimal amountDue, string CountryCode)
 {
     return(OrderProvider.GetConvertedAmount(amountDue, CountryCode));
 }
        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();
            }
        }