Ejemplo n.º 1
0
            /// <summary>
            /// Create a new instance of the <see cref="PriceContext"/> class.
            /// </summary>
            /// <param name="requestContext">Request context.</param>
            /// <param name="pricingDataManager">Pricing data manager.</param>
            /// <param name="priceParameters">Price parameters.</param>
            /// <param name="currencyAndRoundingHelper">Currency and rounding helper.</param>
            /// <param name="itemIds">Item Ids.</param>
            /// <param name="catalogIds">Catalog identifiers.</param>
            /// <param name="activeDate">Active date.</param>
            /// <param name="priceCalculationMode">Price calculation mode.</param>
            /// <param name="discountCalculationMode">Discount calculation mode.</param>
            /// <returns>A new instance of the <see cref="PriceContext"/> class.</returns>
            public static PriceContext CreatePriceContext(
                RequestContext requestContext,
                IPricingDataAccessor pricingDataManager,
                PriceParameters priceParameters,
                ICurrencyOperations currencyAndRoundingHelper,
                ISet <string> itemIds,
                ISet <long> catalogIds,
                DateTimeOffset activeDate,
                PricingCalculationMode priceCalculationMode,
                DiscountCalculationMode discountCalculationMode)
            {
                if (requestContext == null)
                {
                    throw new ArgumentNullException("requestContext");
                }

                PriceContext priceContext = new PriceContext
                {
                    CurrencyAndRoundingHelper = currencyAndRoundingHelper,
                    ActiveDate              = activeDate,
                    PriceParameters         = priceParameters,
                    PriceCalculationMode    = priceCalculationMode,
                    DiscountCalculationMode = discountCalculationMode,
                };

                PriceContextHelper.InitializePriceContextOfInferredProperties(priceContext, pricingDataManager, requestContext, itemIds, catalogIds, null);

                return(priceContext);
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Create a new instance of the <see cref="PriceContext"/> class.
            /// </summary>
            /// <param name="requestContext">Request context.</param>
            /// <param name="pricingDataManager">Pricing data manager.</param>
            /// <param name="transaction">Current transaction.</param>
            /// <param name="currencyAndRoundingHelper">Currency and rounding helper.</param>
            /// <param name="activeDate">Active date.</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="priceCalculationMode">Price calculation mode.</param>
            /// <param name="discountCalculationMode">Discount calculation mode.</param>
            /// <param name="calculateForNewSalesLinesOnly">A flag indicating whether to calculate for new sales lines only.</param>
            /// <param name="newSalesLineIdSet">New sales line id set.</param>
            /// <returns>A new instance of the <see cref="PriceContext"/> class.</returns>
            public static PriceContext CreatePriceContext(
                RequestContext requestContext,
                IPricingDataAccessor pricingDataManager,
                SalesTransaction transaction,
                ICurrencyOperations currencyAndRoundingHelper,
                DateTimeOffset activeDate,
                string customerId,
                string customerPriceGroup,
                string customerLinePriceGroup,
                string customerMultipleLinePriceGroup,
                string customerTotalPriceGroup,
                bool priceIncludesTax,
                PricingCalculationMode priceCalculationMode,
                DiscountCalculationMode discountCalculationMode,
                bool calculateForNewSalesLinesOnly,
                HashSet <string> newSalesLineIdSet)
            {
                if (requestContext == null)
                {
                    throw new ArgumentNullException("requestContext");
                }

                PriceContext priceContext = new PriceContext
                {
                    CurrencyAndRoundingHelper = currencyAndRoundingHelper,
                    ActiveDate                     = activeDate,
                    CustomerAccount                = customerId,
                    CustomerPriceGroup             = customerPriceGroup,
                    CustomerLinePriceGroup         = customerLinePriceGroup,
                    CustomerMultipleLinePriceGroup = customerMultipleLinePriceGroup,
                    CustomerTotalPriceGroup        = customerTotalPriceGroup,
                    IsTaxInclusive                 = priceIncludesTax,
                    PriceCalculationMode           = priceCalculationMode,
                    DiscountCalculationMode        = discountCalculationMode,
                    CalculateForNewSalesLinesOnly  = calculateForNewSalesLinesOnly,
                };

                if (newSalesLineIdSet != null && newSalesLineIdSet.Count > 0)
                {
                    priceContext.NewSalesLineIdSet.AddRange(newSalesLineIdSet);
                }

                ISet <long> catalogIds = GetCatalogIds(transaction);
                IEnumerable <AffiliationLoyaltyTier> affiliationLoyaltyTiers = GetAffiliationLoyalTierIds(transaction);
                ISet <string> itemIds = GetItemIds(transaction);

                PriceContextHelper.InitializePriceContextOfInferredProperties(priceContext, pricingDataManager, requestContext, itemIds, catalogIds, affiliationLoyaltyTiers);

                return(priceContext);
            }
Ejemplo n.º 3
0
            /// <summary>
            /// Create a new instance of the <see cref="PriceContext"/> class.
            /// </summary>
            /// <param name="requestContext">Request context.</param>
            /// <param name="pricingDataManager">Pricing data manager.</param>
            /// <param name="transaction">Current transaction.</param>
            /// <param name="priceParameters">Price parameters.</param>
            /// <param name="currencyAndRoundingHelper">Currency and rounding helper.</param>
            /// <param name="activeDate">Active date.</param>
            /// <param name="customerId">Customer Id.</param>
            /// <param name="customerPriceGroup">Customer price group.</param>
            /// <param name="priceIncludesTax">Price includes tax.</param>
            /// <param name="priceCalculationMode">Price calculation mode.</param>
            /// <param name="discountCalculationMode">Discount calculation mode.</param>
            /// <returns>A new instance of the <see cref="PriceContext"/> class.</returns>
            public static PriceContext CreatePriceContext(
                RequestContext requestContext,
                IPricingDataAccessor pricingDataManager,
                SalesTransaction transaction,
                PriceParameters priceParameters,
                ICurrencyOperations currencyAndRoundingHelper,
                DateTimeOffset activeDate,
                string customerId,
                string customerPriceGroup,
                bool priceIncludesTax,
                PricingCalculationMode priceCalculationMode,
                DiscountCalculationMode discountCalculationMode)
            {
                if (requestContext == null)
                {
                    throw new ArgumentNullException("requestContext");
                }

                PriceContext priceContext = new PriceContext
                {
                    CurrencyAndRoundingHelper = currencyAndRoundingHelper,
                    ActiveDate              = activeDate,
                    CustomerAccount         = customerId,
                    CustomerPriceGroup      = customerPriceGroup,
                    IsTaxInclusive          = priceIncludesTax,
                    PriceParameters         = priceParameters,
                    PriceCalculationMode    = priceCalculationMode,
                    DiscountCalculationMode = discountCalculationMode,
                };

                ISet <long> catalogIds = GetCatalogIds(transaction);
                IEnumerable <AffiliationLoyaltyTier> affiliationLoyaltyTiers = GetAffiliationLoyalTierIds(transaction);
                ISet <string> itemIds = GetItemIds(transaction);

                PriceContextHelper.InitializePriceContextOfInferredProperties(priceContext, pricingDataManager, requestContext, itemIds, catalogIds, affiliationLoyaltyTiers);

                return(priceContext);
            }