//private decimal s_orderMaxAmount; private decimal GetOrderMaxAmount() { OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01; var maxAmount = totals.ItemsTotal - 1; return(maxAmount <= 0 ? 0 : maxAmount); }
private static List <TopSellerProductModel> GetTopSellerProductModel(IEnumerable <TopSellerSku_V01> skus, string id, string locale) { var totals = new OrderTotals_V01(); var ShoppingCartItem = new List <ShoppingCartItem_V01>(); ShoppingCartItem.AddRange(from i in skus select new ShoppingCartItem_V01(0, i.Sku, 1, DateTime.Now)); var existingCart = ShoppingCartProvider.GetShoppingCart(id, locale); totals = existingCart != null?existingCart.Calculate(ShoppingCartItem.ToList()) as OrderTotals_V01 : null; var topSellerProductModelList = skus.Select(topsellerSku => new TopSellerProductModel { ImageUrl = topsellerSku.ImageUrl, Quantity = 1, // default quantity "1" Sku = topsellerSku.Sku, Name = topsellerSku.Name, Price = GetTopSellerSkuPrice(skus, topsellerSku, locale, totals), CurrencySymbol = topsellerSku.CurrencySymbol, DisplayPrice = String.Format("{0}{1}", HLConfigManager.Configurations.CheckoutConfiguration.CurrencySymbol, GetTopSellerSkuPrice(skus, topsellerSku, locale, totals)) }).ToList(); return(topSellerProductModelList); }
internal static void AppendCartItems(OrderTotals_V01 totals, List <DistributorShoppingCartItem> cartItems, string eventState) { if (totals == null || totals.ItemTotalsList == null) { return; } var items = new List <object>(); foreach (var lineTotal in totals.ItemTotalsList.Cast <ItemTotal_V01>()) { var cartItem = cartItems.FirstOrDefault(n => n.SKU == lineTotal.SKU); if (cartItem == null) { continue; } var fee = FindCharge("FREIGHT", lineTotal.ChargeList); var freight = fee == null ? 0m : fee.Amount; var analyticsItem = CreateAnalyticsCartItem(lineTotal.SKU, lineTotal.Quantity, lineTotal.DiscountedPrice, cartItem.Description, lineTotal.LineTax, freight); items.Add(analyticsItem); } AnalyticsProvider.Set(AnalyticsFact.PricedCart, items); string orderId = eventState.Replace("purchase|", ""); AnalyticsProvider.Set(AnalyticsFact.OrderId, orderId); }
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); }
private static void CalculateYourPrice(InvoiceLineModel invoiceLine, InvoicePriceModel invoicePrice, OrderTotals_V01 response, decimal staticDiscount) { if (null != response.ItemTotalsList && response.ItemTotalsList.Any()) { var itemTotal = (ItemTotal_V01)response.ItemTotalsList.Find(p => ((ItemTotal_V01)p).SKU == invoiceLine.Sku); if (null != itemTotal) { invoiceLine.YourPrice = itemTotal.DiscountedPrice; invoiceLine.DisplayYourPrice = invoiceLine.YourPrice.FormatPrice(); } else { LoggerHelper.Error("CalculateYourPrice itemTotal is null"); invoiceLine.YourPrice = 0m; invoiceLine.DisplayYourPrice = invoiceLine.YourPrice.FormatPrice(); } } else { LoggerHelper.Error("CalculateYourPrice ItemTotalsList is null"); invoiceLine.YourPrice = 0m; invoiceLine.DisplayYourPrice = invoiceLine.YourPrice.FormatPrice(); } }
private static void CalculateTaxAmount(InvoiceModel invoice, OrderTotals_V01 response) { if (invoice.InvoicePrice.TaxPercentage > 0) { invoice.InvoicePrice.CalcTaxAmount = decimal.Round( ((invoice.InvoicePrice.SubTotal - invoice.InvoicePrice.CalcDiscountAmount) * (invoice.InvoicePrice.TaxPercentage / 100)), 2); invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice(); } else if (invoice.InvoicePrice.TaxAmount > 0) { invoice.InvoicePrice.CalcTaxAmount = invoice.InvoicePrice.TaxAmount; invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice(); } else if (invoice.InvoicePrice.TaxAmount == 0 && invoice.InvoicePrice.TaxPercentage == 0 && (invoice.IsCustomerTaxEdited && !invoice.ResetCustomerTaxValue)) { invoice.InvoicePrice.CalcTaxAmount = invoice.InvoicePrice.TaxAmount; invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice(); } else { invoice.InvoicePrice.CalcTaxAmount = response.TaxAmount; invoice.InvoicePrice.TaxAmount = invoice.InvoicePrice.CalcTaxAmount; invoice.InvoicePrice.DisplayCalculatedTax = invoice.InvoicePrice.CalcTaxAmount.FormatPrice(); } }
protected override ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { if (reason == ShoppingCartRuleReason.CartItemsBeingAdded) { var myhlCart = cart as MyHLShoppingCart; if (null == myhlCart) { LoggerHelper.Error( string.Format("{0} myhlCart is null {1}", Locale, cart.DistributorID)); Result.Result = RulesResult.Failure; return(Result); } // to set purchasing limit type var theLimits = GetPurchasingLimits(cart.DistributorID, myhlCart.SelectedDSSubType ?? string.Empty); var currentLimits = theLimits[PurchasingLimitProvider.GetOrderMonth()]; if (currentLimits.PurchaseLimitType == PurchaseLimitType.Earnings) { var itemsToCalc = new List <ShoppingCartItem_V01>(); itemsToCalc.AddRange(myhlCart.CartItems); if (myhlCart.CurrentItems != null && myhlCart.CurrentItems.Count > 0) { itemsToCalc.Add(myhlCart.CurrentItems[0]); } OrderTotals_V01 orderTotals = myhlCart.Calculate(itemsToCalc) as OrderTotals_V01; if (orderTotals != null && orderTotals.DiscountPercentage != 0.0M) { myhlCart.SetDiscountForLimits(orderTotals.DiscountPercentage); myhlCart.Totals = orderTotals; } } } return(base.PerformRules(cart, reason, Result)); }
private static void CalculateDiscountedAmount(InvoiceModel invoice, OrderTotals_V01 response) { var totalAmount = invoice.Type == "Distributor" ? invoice.InvoicePrice.TotalEarnBase : invoice.InvoicePrice.SubTotal; if (invoice.InvoicePrice.DiscountPercentage > 0 && invoice.InvoicePrice.DiscountPercentage == response.DiscountPercentage) { invoice.InvoicePrice.CalcDiscountAmount = response.ItemsTotal - response.DiscountedItemsTotal; } else if (invoice.InvoicePrice.DiscountPercentage > 0) { invoice.InvoicePrice.CalcDiscountAmount = decimal.Round((totalAmount * (invoice.InvoicePrice.DiscountPercentage / 100)), 2); } else if (invoice.InvoicePrice.DiscountAmount > 0) { invoice.InvoicePrice.CalcDiscountAmount = invoice.InvoicePrice.DiscountAmount; } else { invoice.InvoicePrice.CalcDiscountAmount = invoice.InvoicePrice.DiscountAmount; } invoice.InvoicePrice.DisplayDiscountedAmount = string.Format("-{0}", invoice.InvoicePrice.CalcDiscountAmount.FormatPrice()); invoice.InvoicePrice.TotalDiscountedAmount = invoice.InvoicePrice.SubTotal - invoice.InvoicePrice.CalcDiscountAmount; }
public decimal GetSubTotalValue(OrderTotals_V01 totals, string countryCode) { switch (countryCode) { case "EC": { var 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); var 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); //calculate the taxable skus decimal taxAmountTotal = 0; foreach (var item in totals.ItemTotalsList as List <ItemTotal> ) { taxAmountTotal += (item as ItemTotal_V01).DiscountedPrice; } return(taxAmountTotal + pHCharge.Amount + freightCharge.Amount); } break; default: return(totals.TaxableAmountTotal); break; } }
protected override void BindTotals() { List <DistributorShoppingCartItem> lstShoppingCartItems = (Page as ProductsBase).ShoppingCart.ShoppingCartItems; try { if (lstShoppingCartItems.Count > 0 && ShoppingCart.Totals != null) { OrderTotals_V01 totals = _shoppingCart.Totals as OrderTotals_V01; lblDiscountRate.Text = _shoppingCart.Totals == null ? "0%" : (totals.DiscountPercentage).ToString() + "%"; lblGrandTotal.Text = getAmountString(totals.AmountDue); lblOrderMonth.Text = GetOrderMonthString(); lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume; lblRetailPrice.Text = getAmountString(GetTotalEarnBase(lstShoppingCartItems)); //getAmountString(totals.ItemsTotal); lblVolumePoints.Text = totals.VolumePoints.ToString("N2"); } else { DisplayEmptyLabels(); } } catch (Exception ex) { //Log Exception LoggerHelper.Error("Exception while displaying totals - " + ex); DisplayEmptyLabels(); } }
private void GetEligibleUsePoint() { string msg = (string)GetLocalResourceObject("EligiblePCLearningPoint.Text"); decimal eligibleAmt = 0; OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01; 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); decimal PCLearningPoint = ShoppingCart.PCLearningPoint; if (PCLearningPoint == 0) { eligibleAmt = 0; } else if (freightCharge.Amount >= PCLearningPoint) { eligibleAmt = Math.Truncate(PCLearningPoint); } else if (PCLearningPoint > freightCharge.Amount) { eligibleAmt = Math.Truncate(freightCharge.Amount); } lblEligiblePCLearningPoint.Text = string.Format(msg, PCLearningPoint.ToString(), eligibleAmt.ToString()); }
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)); }
protected void Page_Load(object sender, EventArgs e) { (Page.Master as OrderingMaster).EventBus.RegisterObject(this); _orderTotals = GetTotals(); lblErrorMessages.Text = string.Empty; SetupPaymentMethodDisplay(); if (!IsPostBack) { LoadCards(); } SetupGridRows(); ShowMessages(); }
protected override ShoppingCartRuleResult PerformRules(MyHLShoppingCart cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { var currentlimits = GetCurrentPurchasingLimits(cart.DistributorID, GetCurrentOrderMonth()); if (cart == null || currentlimits == null) { return(Result); } Result = performRules(cart, Result, currentlimits); if (cart.ItemsBeingAdded != null && cart.ItemsBeingAdded.Count > 0) { if (currentlimits.PurchaseLimitType == PurchaseLimitType.Earnings && cart.OrderSubType == "B1") { bool bExceed = false; List <string> skuToAdd = new List <string>(); var itemsToCalc = new List <ShoppingCartItem_V01>(); itemsToCalc.AddRange(cart.CartItems); foreach (var item in cart.ItemsBeingAdded) { if (bExceed == true) { Result = reportError(cart, item, Result); continue; } itemsToCalc.Add(item); OrderTotals_V01 orderTotals = cart.Calculate(itemsToCalc, false) as OrderTotals_V01; if (orderTotals != null) { decimal earningsInCart = ProductEarningsInCart(itemsToCalc, orderTotals.DiscountPercentage); if (currentlimits.RemainingEarnings - earningsInCart < 0) { bExceed = true; Result = reportError(cart, item, Result); } else { skuToAdd.Add(item.SKU); } } } cart.ItemsBeingAdded.RemoveAll(s => !skuToAdd.Contains(s.SKU)); } } return(Result); }
protected override ShoppingCartRuleResult PerformRules(MyHLShoppingCart cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult Result) { base.PerformRules(cart, reason, Result); if (cart.ItemsBeingAdded != null && cart.ItemsBeingAdded.Count > 0) { var currentlimits = GetCurrentPurchasingLimits(cart.DistributorID, GetCurrentOrderMonth()); if (currentlimits.PurchaseLimitType == PurchaseLimitType.DiscountedRetail) { var itemsToCalc = new List <ShoppingCartItem_V01>(); itemsToCalc.AddRange(cart.CartItems); bool bExceed = false; List <string> skuToAdd = new List <string>(); foreach (var item in cart.ItemsBeingAdded) { if (bExceed == true) { Result = reportError(cart, item, Result); continue; } itemsToCalc.Add(item); OrderTotals_V01 orderTotals = cart.Calculate(itemsToCalc, false) as OrderTotals_V01; if (orderTotals != null) { decimal discountedRetailInCart = orderTotals.ItemTotalsList.Sum(x => (x as ItemTotal_V01).DiscountedPrice); var currentItem = CatalogProvider.GetCatalogItem(item.SKU, Country); if ((currentlimits.RemainingVolume - discountedRetailInCart < 0) && currentItem.ProductType == MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.ProductType.Product) { Result.Result = RulesResult.Failure; bExceed = true; Result = reportError(cart, item, Result); continue; } else { skuToAdd.Add(item.SKU); } } } cart.ItemsBeingAdded.RemoveAll(s => !skuToAdd.Contains(s.SKU)); } } return(Result); }
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 static void RegisterOmnitureCartScript(Page currentPage, OrderTotals_V01 totals, List <DistributorShoppingCartItem> shoppingCartItems, string eventState) { try { AppendCartItems(totals, shoppingCartItems, eventState); var writer = new StringWriter(); writer.WriteLine(string.Format("<!-- {0} -->", CartItemListScriptName)); AnalyticsProvider.Render(writer); currentPage.ClientScript.RegisterClientScriptBlock(currentPage.GetType(), CartItemListScriptName, writer.GetStringBuilder().ToString(), false); } catch (Exception ex) { LoggerHelper.Exception("System.Exception", ex, "Error setting Omniture Analytics variables:"); } }
public void GetSubTotalValueTest_EC_NoItemtotalList_0_0() { CheckoutTotalsDetailed_SAM target = new CheckoutTotalsDetailed_SAM(); OrderTotals_V01 totals = new OrderTotals_V01(); totals.ChargeList = new ChargeList(); totals.ItemTotalsList = new ItemTotalsList(); string countryCode = "EC"; decimal expected = 0M; decimal actual; actual = target.GetSubTotalValue(totals, countryCode); Assert.AreEqual(expected, actual); }
private static void CalculateMemberTax(OrderTotals_V01 response, InvoiceModel invoice) { if (invoice.MakeMemberTaxZero) { invoice.InvoicePrice.MemberTax = 0; invoice.InvoicePrice.DisplayMemberTax = invoice.InvoicePrice.MemberTax.FormatPrice(); return; } if (!invoice.IsMemberTaxEdited && invoice.InvoicePrice.MemberTax == 0) { invoice.InvoicePrice.MemberTax = response.TaxAmount; invoice.InvoicePrice.DisplayMemberTax = invoice.InvoicePrice.MemberTax.FormatPrice(); return; } invoice.InvoicePrice.DisplayMemberTax = invoice.InvoicePrice.MemberTax.FormatPrice(); }
public void GetSubTotalValueTest_EC_NochargeList_90_90() { CheckoutTotalsDetailed_SAM target = new CheckoutTotalsDetailed_SAM(); OrderTotals_V01 totals = new OrderTotals_V01(); totals.ChargeList = new ChargeList(); totals.ItemTotalsList = new ItemTotalsList(); totals.ItemTotalsList.Add(new ItemTotal_V01("0020", 1, 120, 100, 90, 5, 50, null)); string countryCode = "EC"; decimal expected = 90M; decimal actual; actual = target.GetSubTotalValue(totals, countryCode); Assert.AreEqual(expected, actual); }
private static void CalculateMemberFreight(OrderTotals_V01 response, InvoiceModel invoice) { if (invoice.MakeMemberHandlingFeeZero) { invoice.InvoicePrice.MemberFreight = 0; invoice.InvoicePrice.DisplayMemberFreight = invoice.InvoicePrice.MemberFreight.FormatPrice(); return; } if (!invoice.IsMemberHandlingFeeEdited && invoice.InvoicePrice.MemberFreight == 0) { var chargeListV01S = (from item in response.ChargeList where item as Charge_V01 != null select item as Charge_V01); if (!chargeListV01S.Any()) { return; } var distributorCharges = chargeListV01S.Where(p => (p.ChargeType == ChargeTypes.FREIGHT)); if (!distributorCharges.Any()) { return; } var distributorCharge = distributorCharges.Single(); invoice.InvoicePrice.MemberFreight = distributorCharge.Amount; invoice.InvoicePrice.DisplayMemberFreight = invoice.InvoicePrice.MemberFreight.FormatPrice(); if (invoice.InvoicePrice.ShippingAmount == 0 && invoice.InvoicePrice.ShippingPercentage == 0) { invoice.InvoicePrice.ShippingAmount = invoice.InvoicePrice.MemberFreight; invoice.InvoicePrice.CalcShippingAmount = invoice.InvoicePrice.MemberFreight; } return; } if (invoice.InvoicePrice.ShippingAmount == 0 && invoice.InvoicePrice.ShippingPercentage == 0) { invoice.InvoicePrice.ShippingAmount = invoice.InvoicePrice.MemberFreight; invoice.InvoicePrice.CalcShippingAmount = invoice.InvoicePrice.MemberFreight; } invoice.InvoicePrice.DisplayMemberFreight = invoice.InvoicePrice.MemberFreight.FormatPrice(); }
/// <summary>Load the distributors payment cards from storage</summary> public void LoadCards() { if (!IsPostBack) { SetPaymentInformation(null); } lblCardsLimitMessage.Text = (_maxCardsToDisplay > 1) ? string.Format(lblCardsLimitMessage.Text, _maxCardsToDisplay) : string.Empty; var totals = GetTotals(); if (null != totals) { totalWireDue.Text = DisplayAsCurrency(totals.AmountDue, true); totalDirectDepositDue.Text = totalWireDue.Text; totalPaymentGatewayDue.Text = totalWireDue.Text; txtGrandTotal.Text = totalWireDue.Text; Page.ClientScript.RegisterClientScriptBlock(typeof(string), "TotalCreditDue", string.Format(ScriptBlock, string.Concat("var amount = '", string.Format("{0:F2}", totals .AmountDue), "';"))); } if (_CurrentPaymentsList != null && _CurrentPaymentsList.Count > 0) { if ((_orderTotals = totals) != null) { totalAmountBalance.Text = DisplayAsCurrency(totals.AmountDue, false); } if (!IsPostBack) { //SetPaymentInformation(_CurrentPaymentsList, _locale, _distributorId); _CurrentPaymentsList = GetCurrentCardsList(); dataListCardInfo.DataSource = _CurrentPaymentsList; dataListCardInfo.DataBind(); } } ResolvePayments(); }
public void GetSubTotalValueTest_EC_NoPH_NoFreight_80_80() { CheckoutTotalsDetailed_SAM target = new CheckoutTotalsDetailed_SAM(); OrderTotals_V01 totals = new OrderTotals_V01(); totals.ChargeList = new ChargeList(); totals.ChargeList.Add(new Charge_V01(ChargeTypes.PH, 0M)); totals.ChargeList.Add(new Charge_V01(ChargeTypes.FREIGHT, 0M)); totals.ItemTotalsList = new ItemTotalsList(); totals.ItemTotalsList.Add(new ItemTotal_V01("0020", 1, 120, 100, 80, 5, 50, null)); string countryCode = "EC"; decimal expected = 80M; decimal actual; actual = target.GetSubTotalValue(totals, countryCode); Assert.AreEqual(expected, actual); }
private static void CalculateShippingAmount(InvoiceModel invoice, OrderTotals_V01 response) { if (invoice.InvoicePrice.ShippingPercentage > 0) { invoice.InvoicePrice.CalcShippingAmount = decimal.Round( ((invoice.InvoicePrice.SubTotal - invoice.InvoicePrice.CalcDiscountAmount) * (invoice.InvoicePrice.ShippingPercentage / 100)), 2); } else if (invoice.InvoicePrice.ShippingAmount > 0) { invoice.InvoicePrice.CalcShippingAmount = invoice.InvoicePrice.ShippingAmount; } else if (invoice.InvoicePrice.ShippingAmount == 0 && invoice.InvoicePrice.ShippingPercentage == 0 && (invoice.IsCustomerShippingHandlingEdited && !invoice.ResetCustomerTaxValue)) { invoice.InvoicePrice.CalcShippingAmount = 0; } else { var chargeListV01S = (from item in response.ChargeList where item as Charge_V01 != null select item as Charge_V01); if (!chargeListV01S.Any()) { return; } var distributorCharges = chargeListV01S.Where(p => (p.ChargeType == ChargeTypes.FREIGHT)); if (!distributorCharges.Any()) { return; } var distributorCharge = distributorCharges.Single(); invoice.InvoicePrice.CalcShippingAmount = distributorCharge.Amount; invoice.InvoicePrice.ShippingAmount = invoice.InvoicePrice.CalcShippingAmount; } invoice.InvoicePrice.DisplayShipping = invoice.InvoicePrice.CalcShippingAmount.FormatPrice(); }
public void DeductPCLearningFee() { int learningPoint = 10; var pcProvider = Substitute.For <IOrderProviderLoader>(); pcProvider.DeductPCLearningPoint(req.DistributorID, req.OrderNumber, req.VolumeMonth, req.Point, req.Platform).Returns(learningPoint); int point = 0; point = pcProvider.DeductPCLearningPoint(req.DistributorID, req.OrderNumber, req.VolumeMonth, req.Point, req.Platform); OrderTotals_V01 total = shoppingCart.Totals as OrderTotals_V01; total.AmountDue -= Convert.ToDecimal(point); Assert.AreEqual(total.AmountDue, 90); total.AmountDue = 100.5m; total.AmountDue -= Convert.ToDecimal(point); Assert.AreEqual(total.AmountDue, 90.5m); }
public void GetPCLearningFee() { int learningPoint = 10; var pcProvider = Substitute.For <IOrderProviderLoader>(); pcProvider.GetAccumulatedPCLearningPoint("testid", "pcpoint").Returns(learningPoint); int point = 0; point = pcProvider.GetAccumulatedPCLearningPoint("testid", "pcpoint"); OrderTotals_V01 total = shoppingCart.Totals as OrderTotals_V01; total.AmountDue -= Convert.ToDecimal(point); Assert.AreEqual(total.AmountDue, 90); total.AmountDue = 100.5m; total.AmountDue -= Convert.ToDecimal(point); Assert.AreEqual(total.AmountDue, 90.5m); }
private void BindTotals() { decimal earnBase = 0.00M; var lstShoppingCartItems = (Page as ProductsBase).ShoppingCart.ShoppingCartItems; try { if (lstShoppingCartItems.Count > 0 && _shoppingCart.Totals != null) { OrderTotals_V01 totals = _shoppingCart.Totals as OrderTotals_V01; foreach (DistributorShoppingCartItem shoppingCartItem in lstShoppingCartItems) { earnBase += shoppingCartItem.EarnBase; } lblDiscountRate.Text = _shoppingCart.Totals == null ? "0%" : (totals.DiscountPercentage).ToString() + "%"; lblEarnBase.Text = getAmountString(CheckoutTotalsDetailed.GetTotalEarnBase(lstShoppingCartItems)); lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume; lblRetailPrice.Text = getAmountString(totals.ItemsTotal); lblSubtotal.Text = getAmountString(totals.DiscountedItemsTotal); lblVolumePoints.Text = totals.VolumePoints.ToString("N2"); } else { DisplayEmptyTotals(); } } catch (Exception ex) { //Log Exception LoggerHelper.Error("Exception while displaying totals - " + ex); DisplayEmptyTotals(); } }
private int GetFeeAmount() { int installments = 0; decimal feePrice = 0.0M; decimal totalDue = 0M; if (int.TryParse(ddlInstallments.SelectedValue, out installments)) { if (installments > 1) { OrderTotals_V01 totals = _page.ShoppingCart.Totals as OrderTotals_V01; SKU_V01 feeSku = null; if (_page.AllSKUS.TryGetValue(_cards.FeeSKU, out feeSku)) { feePrice = feeSku.CatalogItem.ListPrice; var fees = new AdditionalFees(_cards); decimal coefficient = fees.GetCoefficient(ddlCards.SelectedValue, installments); if (totals.ItemsTotal > 0) { totalDue = (totals.AmountDue) * (coefficient); } } else { string errorMessage = string.Format( "Cannot find Credit Card Installment SKU {0}. Cannot calculate fees for Payment Installments", _cards.FeeSKU); LoggerHelper.Error(errorMessage); throw new ApplicationException(errorMessage); } } } return((totalDue > 0) ? int.Parse(Math.Ceiling(totalDue / feePrice).ToString()) : 0); }
protected override void BindTotals() { decimal earnBase = 0.00M; List <DistributorShoppingCartItem> lstShoppingCartItems = (Page as ProductsBase).ShoppingCart.ShoppingCartItems; try { if (lstShoppingCartItems.Count > 0 && _shoppingCart.Totals != null) { OrderTotals_V01 totals = _shoppingCart.Totals as OrderTotals_V01; foreach (DistributorShoppingCartItem shoppingCartItem in lstShoppingCartItems) { earnBase += shoppingCartItem.EarnBase; } lblDiscountRate.Text = _shoppingCart.Totals == null ? "0%" : (totals.DiscountPercentage).ToString() + "%"; lblDistributorSubtotal.Text = getAmountString(totals.DiscountedItemsTotal); lblEarnBase.Text = getAmountString(GetTotalEarnBase(lstShoppingCartItems)); 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 (decimal.TryParse((Page as ProductsBase).CurrentMonthVolume, out currentMonthVolume)) { lblOrderMonthVolume.Text = HLConfigManager.Configurations.CheckoutConfiguration.UseUSPricesFormat ? currentMonthVolume.ToString("N", CultureInfo.GetCultureInfo("en-US")) : currentMonthVolume.ToString("N2"); } 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); lblOtherCharges.Text = getAmountString(otherCharges.Amount); Charge_V01 localTaxCharge = OrderProvider.GetLocalTax(_shoppingCart.Totals as OrderTotals_V01); lblLocalTax.Text = getAmountString(localTaxCharge.Amount); lblPackageHandling.Text = getAmountString(pHCharge.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); var amount = GetSubTotalValue(totals, CountryCode); lblSubtotal.Text = getAmountString(amount); lblRetailPrice.Text = getAmountString(totals.ItemsTotal); lblShippingCharges.Text = getAmountString(freightCharge.Amount); lblTaxVAT.Text = getAmountString(OrderProvider.GetTaxAmount(_shoppingCart.Totals as OrderTotals_V01)); Charge_V01 taxedNet = totals.ChargeList.Find( delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.TAXEDNET); }) as Charge_V01 ?? new Charge_V01(ChargeTypes.TAXEDNET, (decimal)0.0); lblTaxedNet.Text = getAmountString(taxedNet.Amount); lblVolumePoints.Text = HLConfigManager.Configurations.CheckoutConfiguration.UseUSPricesFormat ? totals.VolumePoints.ToString("N", CultureInfo.GetCultureInfo( "en-US")) : totals.VolumePoints.ToString("N2"); lblGrandTotal.Text = getAmountString(totals.AmountDue); } else { DisplayEmptyLabels(); } if (HLConfigManager.Configurations.CheckoutConfiguration.HasTotalTaxable) { trTaxedNet.Visible = true; trTax.Visible = false; } if (_shoppingCart.Totals != null) { OrderTotals_V01 totals = _shoppingCart.Totals as OrderTotals_V01; if (HLConfigManager.Configurations.CheckoutConfiguration.HasTaxPercentage) { trTaxPercentage.Visible = true; //lblPercentage.Text = HLConfigManager.Configurations.CheckoutConfiguration.TaxPercentage + "%"; lblPercentage.Text = _shoppingCart.Totals != null ? getAmountString(OrderProvider.GetTaxAmount(_shoppingCart.Totals as OrderTotals_V01)) : string.Empty; } if (HLConfigManager.Configurations.CheckoutConfiguration.HasTotalDiscount) { trTotalDiscount.Visible = true; lblTotalDiscount2.Text = _shoppingCart.Totals != null ? getAmountString(totals.TotalItemDiscount) : string.Empty; } // hide this row if there is no local tax return trLocalTax.Visible = OrderProvider.HasLocalTax(totals); } } catch (Exception ex) { //Log Exception LoggerHelper.Error("Exception while displaying totals - " + ex); DisplayEmptyLabels(); } }
private List <string> GenerateHash(string payClubPublicKey, string herbalifePrivateKey, string acquirerId, string storeId, string orderNumber, string amount, string returnUrl, string vectorId, string localId) { var cipheredDataList = new List <string>(); MyHLShoppingCart myCart; SessionInfo sessionInfoMyCart = SessionInfo.GetSessionInfo(this._distributorId, this._locale); myCart = sessionInfoMyCart.ShoppingCart ?? ShoppingCartProvider.GetShoppingCart(this._distributorId, this._locale); var plugin = new PlugInClientSend(); string xmlRequest = ""; string xmlFirma = ""; string xmlGenerateKeyI = ""; plugin.setLocalID(localId); plugin.setTransacctionID(orderNumber); plugin.setReferencia1("xxx"); plugin.setReferencia2("xxx"); plugin.setReferencia3("xxx"); plugin.setReferencia4("xxx"); plugin.setReferencia5("xxx"); //Int32 valor = 100 * Convert.ToInt32(amount); OrderTotals_V01 totals = myCart.Totals as OrderTotals_V01; string valor = (string.Format(getPriceFormat((null != myCart.Totals ? totals.TaxableAmountTotal : 0)), (null != myCart.Totals ? totals.TaxableAmountTotal : 0)).Replace(".", "")).Replace (",", ""); // Only positive values are accepted.Value without formatting.Two last digits are cents. Eg. 1234 = 12.34. plugin.setTransacctionValue(valor); string taxValue1 = (string.Format(getPriceFormat((null != myCart.Totals ? totals.TaxAmount : 0)), (null != totals ? totals.TaxAmount : 0)).Replace(".", "")).Replace(",", ""); plugin.setTaxValue1(taxValue1); plugin.setTaxValue2("000"); plugin.setTipValue("000"); plugin.setCurrencyID("840"); plugin.setIV(vectorId); //read from file, validate the paths plugin.setSignPrivateKey(RSAEncryption.readFile(herbalifePrivateKey)); plugin.setCipherPublicKeyFromFile(payClubPublicKey); xmlGenerateKeyI = plugin.CreateXMLGENERATEKEY(); HttpRequest masquerader = new HttpRequest(_context.Request.FilePath, _context.Request.Url.OriginalString.Replace("http://", "https://").Replace(":80", string.Empty), _context.Request.Url.Query); plugin.XMLProcess(masquerader); xmlRequest = plugin.getXMLREQUEST(); xmlFirma = plugin.getXMLDIGITALSIGN(); cipheredDataList.Add(xmlRequest); cipheredDataList.Add(xmlFirma); cipheredDataList.Add(xmlGenerateKeyI); return(cipheredDataList); }