示例#1
0
            /// <summary>
            /// Create a new instance of the <see cref="PriceContext"/> class for price or discount calculation.
            /// </summary>
            /// <param name="pricingDataManager">Pricing data manager.</param>
            /// <param name="currencyAndRoundingHelper">Currency and rounding helper.</param>
            /// <param name="priceCalculationMode">Price calculation mode.</param>
            /// <param name="discountCalculationMode">Discount calculation mode.</param>
            /// <param name="itemIds">Item Ids.</param>
            /// <param name="catalogIds">Catalog identifiers.</param>
            /// <param name="affiliationLoyaltyTiers">Affiliation or loyalty tier identifiers.</param>
            /// <param name="customerId">Customer Id.</param>
            /// <param name="customerPriceGroup">Customer price group.</param>
            /// <param name="customerLinePriceGroup">Customer line discount price group.</param>
            /// <param name="customerMultipleLinePriceGroup">Customer multiple line discount price group.</param>
            /// <param name="customerTotalPriceGroup">Customer total discount price group.</param>
            /// <param name="priceIncludesTax">Price includes tax.</param>
            /// <param name="currencyCode">Currency code.</param>
            /// <param name="activeDate">Active date.</param>
            /// <returns>A new instance of the <see cref="PriceContext"/> class.</returns>
            public static PriceContext CreatePriceContext(
                IPricingDataAccessor pricingDataManager,
                ICurrencyOperations currencyAndRoundingHelper,
                PricingCalculationMode priceCalculationMode,
                DiscountCalculationMode discountCalculationMode,
                ISet <string> itemIds,
                ISet <long> catalogIds,
                IEnumerable <AffiliationLoyaltyTier> affiliationLoyaltyTiers,
                string customerId,
                string customerPriceGroup,
                string customerLinePriceGroup,
                string customerMultipleLinePriceGroup,
                string customerTotalPriceGroup,
                bool priceIncludesTax,
                string currencyCode,
                DateTimeOffset activeDate)
            {
                if (pricingDataManager == null)
                {
                    throw new ArgumentNullException("pricingDataManager");
                }

                PriceContext priceContext = new PriceContext
                {
                    CurrencyAndRoundingHelper = currencyAndRoundingHelper,
                    ActiveDate                     = activeDate,
                    CurrencyCode                   = currencyCode,
                    CustomerAccount                = customerId,
                    CustomerPriceGroup             = customerPriceGroup,
                    CustomerLinePriceGroup         = customerLinePriceGroup,
                    CustomerMultipleLinePriceGroup = customerMultipleLinePriceGroup,
                    CustomerTotalPriceGroup        = customerTotalPriceGroup,
                    PriceParameters                = pricingDataManager.GetPriceParameters(),
                    IsTaxInclusive                 = priceIncludesTax,
                    PriceCalculationMode           = priceCalculationMode,
                    DiscountCalculationMode        = discountCalculationMode,
                };

                PriceContextHelper.InitializePriceContexOfAlgorithmMode(priceContext, pricingDataManager);
                PriceContextHelper.InitializePriceContexOfPriceGroups(priceContext, pricingDataManager, catalogIds, affiliationLoyaltyTiers);
                PriceContextHelper.InitializeItemCache(priceContext, pricingDataManager, itemIds);

                return(priceContext);
            }
示例#2
0
            private static void InitializePriceContextOfInferredProperties(
                PriceContext priceContext,
                IPricingDataAccessor pricingDataManager,
                RequestContext requestContext,
                ISet <string> itemIds,
                ISet <long> catalogIds,
                IEnumerable <AffiliationLoyaltyTier> affiliationLoyaltyTiers)
            {
                if (priceContext == null)
                {
                    throw new ArgumentNullException("priceContext");
                }

                if (requestContext == null)
                {
                    throw new ArgumentNullException("requestContext");
                }

                if (pricingDataManager == null)
                {
                    throw new ArgumentNullException("pricingDataManager");
                }

                if (string.IsNullOrWhiteSpace(priceContext.CurrencyCode))
                {
                    string currencyCode = requestContext.GetChannelConfiguration().Currency;
                    priceContext.CurrencyCode = currencyCode;
                }

                if (priceContext.PriceParameters == null)
                {
                    priceContext.PriceParameters = pricingDataManager.GetPriceParameters();
                }

                InitializePriceContexOfAlgorithmMode(priceContext, pricingDataManager);
                InitializePriceContexOfPriceGroups(priceContext, pricingDataManager, catalogIds, affiliationLoyaltyTiers);
                InitializeItemCache(priceContext, pricingDataManager, itemIds);
            }
示例#3
0
            /// <summary>
            /// Get discount parameters from the database. These parameters tell what search possibilities are active.
            /// Populate the internal set of enabled trade agreement combinations based on fetched values.
            /// </summary>
            /// <param name="pricingDataManager">The data manager which returns pricing data.</param>
            private void GetDiscountParameters(IPricingDataAccessor pricingDataManager)
            {
                var priceParameters = pricingDataManager.GetPriceParameters();

                this.GetDiscountParameters(priceParameters);
            }