/// <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); }
/// <summary> /// Create a new instance of the <see cref="PriceContext"/> class for price 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="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, bool priceIncludesTax, string currencyCode, DateTimeOffset activeDate) { PriceContext priceContext = CreatePriceContext( pricingDataManager, currencyAndRoundingHelper, priceCalculationMode, discountCalculationMode, itemIds, catalogIds, affiliationLoyaltyTiers, customerId, customerPriceGroup, string.Empty, string.Empty, string.Empty, priceIncludesTax, currencyCode, activeDate); return(priceContext); }
/// <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); }
/// <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); }
/// <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); }