Class DefaultPriceInfoService

java.lang.Object
com.broadleafcommerce.pricing.service.DefaultPriceInfoService
All Implemented Interfaces:
PriceInfoService

public class DefaultPriceInfoService extends Object implements PriceInfoService
Author:
Chad Harchar (charchar), Nathan Moore (nathanmoore)
  • Field Details

    • BASE_FIELDS_LIST

      public static String[] BASE_FIELDS_LIST
  • Constructor Details

    • DefaultPriceInfoService

      public DefaultPriceInfoService(PriceDataService<PriceData> priceDataService, com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, PriceableFieldProperties priceableFields, PriceListService<PriceList> priceListService, com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator validator, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
  • Method Details

    • getPriceListPriceDetailComparator

      protected PriceListPriceDetailComparator getPriceListPriceDetailComparator(javax.money.CurrencyUnit requestedCurrency)
    • getBestOverallPriceDetailComparator

      protected Comparator<com.broadleafcommerce.pricing.client.domain.PriceDetailComparable> getBestOverallPriceDetailComparator(javax.money.CurrencyUnit requestedCurrency)
      By default, when comparing price details across phases the system will prefer details in the correct currency followed by the detail with the lowest price.

      If a priceDetailComparator is configured, it will use that over the default logic.

    • retrievePriceInfosByPriceContext

      @Transactional("pricingTransactionManager") public org.springframework.data.domain.Page<com.broadleafcommerce.pricing.client.domain.PriceInfo> retrievePriceInfosByPriceContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext)
      Description copied from interface: PriceInfoService

      First retrieves the PriceListRefs for the PriceContext then retrieves the PriceInfo associated thereto.

      Calls PriceInfoService.retrievePriceInfosByPriceLists(ContextInfo, PriceInfoContext)

      Specified by:
      retrievePriceInfosByPriceContext in interface PriceInfoService
    • updatePriceContextWithVendorRefList

      protected void updatePriceContextWithVendorRefList(com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext)
      To support better query efficiency related to large numbers of vendor price lists, store the list of applicable vendors for this pricing request on the PriceContext.
    • updateContextInfoCurrency

      protected void updateContextInfoCurrency(List<PriceList> priceLists, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • retrievePriceInfosByPriceLists

      public org.springframework.data.domain.Page<com.broadleafcommerce.pricing.client.domain.PriceInfo> retrievePriceInfosByPriceLists(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext)
      Description copied from interface: PriceInfoService
      Retrieves PriceData for the provided PriceInfoContext.getPriceLists() and PriceInfoContext.getPriceableTargets(), then translates them into a list of PriceInfo.
      Specified by:
      retrievePriceInfosByPriceLists in interface PriceInfoService
    • retrievePriceInfosByPriceLists

      protected org.springframework.data.domain.Page<com.broadleafcommerce.pricing.client.domain.PriceInfo> retrievePriceInfosByPriceLists(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext, List<PriceList> priceLists)
    • getTargetsForAllRecurringPeriodTypes

      protected <T extends com.broadleafcommerce.pricing.client.domain.PriceableTarget, R extends PriceData> Set<T> getTargetsForAllRecurringPeriodTypes(@NonNull @NonNull Set<T> priceableTargets, @NonNull @NonNull Set<R> availablePriceData, boolean matchPaymentStrategy)
      Gets a new Set of PriceableTargets with all available term and frequency combinations.

      For example, consider a PriceableTarget with a 2-year term and two matching PriceData distinguished by their recurring period types. One has DefaultRecurringPeriodType.MONTHLY, and one has DefaultRecurringPeriodType.ANNUALLY frequency. This method will return a new set of PriceableTargets with the original PriceableTarget and a clone of it for each available frequency.

      Creating a PriceableTarget for each unique term and frequency combination allows them to be priced independently, which will consequently get the best price for each combination.

      Parameters:
      priceableTargets - the set of original PriceableTargets
      availablePriceData - the set of all the available PriceData
      Returns:
      a new Set of PriceableTargets with all available term and frequency combinations.
      Since:
      Pricing Services 2.2.0, Release Train 2.3.0
    • modifyPriceContext

      protected void modifyPriceContext(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext)
      Extend this if you want to modify the provided price context, for example removing certain attributes for security reasons. Left blank by default.
    • populatePriceContextCurrencies

      protected void populatePriceContextCurrencies(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext)
      Populates the PriceContext.getPriceTargetCurrencies() with the currencies of the PriceInfoContext.getPriceableTargets().
    • prepareEligiblePriceLists

      protected List<PriceList> prepareEligiblePriceLists(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext)
      Reads all priceLists that are in scope for the priceInfo request and splits them in
      Parameters:
      contextInfo -
      priceInfoContext -
      Returns:
    • groupAdjustmentListsByPhase

      protected Map<String,List<PriceList>> groupAdjustmentListsByPhase(List<PriceList> adjPriceLists)
      Moves adjustment price lists into a structure to support processing by phase (e.g. STANDARD, SALE, CONTRACT).
    • isAdjustmentPriceListValidForType

      protected boolean isAdjustmentPriceListValidForType(PriceList priceList, String type)
      Determines if an adjustment price list is targeting a price list phase based on its value for PriceModifier.fieldToModify
    • isFieldValidForStandardPhase

      protected boolean isFieldValidForStandardPhase(String phase)
    • isFieldValidForSalePhase

      protected boolean isFieldValidForSalePhase(String phase)
    • isFieldValidForContractPhase

      protected boolean isFieldValidForContractPhase(String phase)
    • splitPriceListsByType

      protected Map<String,List<PriceList>> splitPriceListsByType(List<PriceList> priceLists)
    • getPriceListPhases

      protected List<String> getPriceListPhases()
      Return an ordered list of price list types. The order of this list is important to ensure that price formulas work as expected since, for example, a STANDARD price could depend on the result of a COST or a SALE could depend on the result of a STANDARD price.
    • getPriceListAndTargetPriceDataMap

      protected Map<org.apache.commons.lang3.tuple.Pair<String,TargetKeyDto>,List<PriceData>> getPriceListAndTargetPriceDataMap(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget> priceableTargets, List<PriceList> priceLists)
    • addTargetToPriceListMapForTarget

      protected void addTargetToPriceListMapForTarget(Map<TargetKeyDto,Map<String,Set<PriceList>>> priceListsByTypeByTarget, TargetKeyDto targetKeyDto, PriceList priceList)
      Adds the given TargetKeyDto and PriceList to the given Map of PriceLists by type by target.

      This should only be used if PriceInfoProperties.isAllowMergingTermFrequencyAcrossPriceLists() is false. The Map of PriceLists by type by target is used to track all the PriceLists that contains the available PriceData for a target, so that at the end, only the PriceData from the highest priority PriceList is kept.

      The recurring details are taken out to track available term and frequency combinations for the same target.

      Parameters:
      priceListsByTypeByTarget - the Map of PriceLists by type by target to keep track of all the PriceLists that contains the available PriceData for a target
      targetKeyDto - the TargetKeyDto to add to the Map of PriceLists by type by target
      priceList - the PriceList that the price data target is from
      Since:
      Pricing Services 2.2.0, Release Train 2.3.0
    • removePriceDataFromLowerPriorityPriceLists

      protected void removePriceDataFromLowerPriorityPriceLists(Map<org.apache.commons.lang3.tuple.Pair<String,TargetKeyDto>,List<PriceData>> priceListAndTargetPriceDataMap, Map<TargetKeyDto,Map<String,Set<PriceList>>> priceListsByTypeByTarget)
      Removes all the PriceData entry from the given Map of PriceData if they are from a lower-priority PriceList, so that only the PriceData entry from the highest priority PriceList is kept.

      This should only be used if PriceInfoProperties.isAllowMergingTermFrequencyAcrossPriceLists() is false.

      Parameters:
      priceListAndTargetPriceDataMap - the Map of PriceData by a Pair of price list id and PriceableTargetRef for the PriceData to remove entries from
      priceListsByTypeByTarget - the Map of PriceLists by type by target to keep track of all the PriceLists that contains the available PriceData for a target
      Since:
      Pricing Services 2.2.0, Release Train 2.3.0
    • hasTermOrFrequency

      protected boolean hasTermOrFrequency(@NonNull @NonNull PriceData priceData)
    • getPriceKey

      protected String getPriceKey(String type)
    • processPriceAdjustments

      protected void processPriceAdjustments(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String,List<PriceList>> adjListsByPhase, String phase, PriceableTargetPriceState priceState, Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> detail)
    • processBackupPriceAdjustments

      protected void processBackupPriceAdjustments(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String,List<PriceList>> adjListsByPhase, String phase, PriceableTargetPriceState priceState, Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> detail)
    • isAdjustmentApplicableToTarget

      protected boolean isAdjustmentApplicableToTarget(PriceList priceList, com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.pricing.client.domain.PriceDetail priceDetail)
    • buildNewPriceDetailForAdjustment

      protected Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> buildNewPriceDetailForAdjustment(String phase, com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
    • targetContainsValidField

      protected boolean targetContainsValidField(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, String fieldName)
    • findMatchingAdjustmentPriceData

      protected Optional<PriceData> findMatchingAdjustmentPriceData(PriceList priceList, com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceableTargetPriceState priceState)
    • checkForTermMatch

      protected boolean checkForTermMatch(PriceData pd, com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
    • checkForRecurringFrequencyMatch

      protected boolean checkForRecurringFrequencyMatch(PriceData pd, com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
    • checkForPaymentStrategyMatch

      protected boolean checkForPaymentStrategyMatch(PriceData pd, com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
    • checkForVendorMatch

      protected boolean checkForVendorMatch(String vendorRef, com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
    • checkForCharacteristicMatch

      protected boolean checkForCharacteristicMatch(PriceData priceData, com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
    • applyPriceDataAdjustment

      protected void applyPriceDataAdjustment(com.broadleafcommerce.pricing.client.domain.PriceDetail priceDetail, PriceData priceData)
    • applyPriceListAdjustment

      protected boolean applyPriceListAdjustment(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.pricing.client.domain.PriceDetail priceDetail, PriceList priceList)
      Return true if a price list adjustment was made.
    • putPricesForType

      protected void putPricesForType(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Map<String,List<PriceList>> listsByType, String type, PriceableTargetPriceState priceState)
    • updateCostFromCostList

      protected void updateCostFromCostList(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, List<PriceList> costPriceLists, PriceableTargetPriceState priceState)
    • getPriceFromListForTarget

      @NonNull @Deprecated(forRemoval=true, since="1.7.14, 2.0.1") protected Optional<javax.money.MonetaryAmount> getPriceFromListForTarget(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList, PriceableTargetPriceState priceState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getPriceDetailFromListForTarget

      @NonNull protected Optional<PriceListPriceDetail> getPriceDetailFromListForTarget(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList, PriceableTargetPriceState priceState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      1. Checks for PriceData for the PriceableTarget
      2. If none, checks for PriceModifiers
      3. If none, works up the PriceList hierarchy look for #1 or #2.
      4. If still none, checks for custom logic to get the price from somewhere else (getPriceFromElsewhere(PriceableTarget, PriceList, ContextInfo))
      5. If still none, returns the PriceableFieldProperties.getBasePrice() (also see PriceableFieldType.BASE_PRICE
    • populatePriceDetailFromSummary

      protected void populatePriceDetailFromSummary(@NonNull @NonNull PriceListPriceDetail priceDetail, @NonNull @NonNull PriceSummary summary)
      Populates fields onto a PriceListPriceDetail from a PriceSummary.
      Parameters:
      priceDetail - Price detail to populate
      summary - Source of price details
      Since:
      Pricing Service 2.1.0, Release Train 2.2.0
    • convertPriceListsToPriceListIds

      protected List<String> convertPriceListsToPriceListIds(Collection<PriceList> priceLists)
    • convertTargetsToTargetKeyDtos

      protected List<TargetKeyDto> convertTargetsToTargetKeyDtos(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTarget> targets)
    • getPriceSummaryFromPriceData

      protected Optional<PriceSummary> getPriceSummaryFromPriceData(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, String priceListId, PriceableTargetPriceState priceState)
      Gets the PriceSummary from a matching PriceData.

      For a PriceableTarget that has a vendorRef, if the exact match of target's type, id, and vendorRef cannot be found, it will fall back to a price data that has only has the match of target's type and id with null vendorRef. If both price data exist, then the exact match takes precedence.

      Parameters:
      target - the PriceableTarget to match
      priceListId - the PriceList.getId() to look for
      priceState - the current PriceableTargetPriceState
      Returns:
      an Optional<PriceSummary>.
    • priceDataMatchesTarget

      protected boolean priceDataMatchesTarget(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceableTarget target, @NonNull @NonNull PriceData priceData, @NonNull @NonNull PriceableTargetPriceState priceState)
      Compares the terms and characteristics of the priceData to those requested on the target to ensure it matches. The priceData should already match the target's id and type by this point.
      Parameters:
      target - The requested target to be priced
      priceData - The potential PriceData matching the target
      Returns:
      Whether priceData matches the terms and characteristics on the target.
      Since:
      Pricing Service 2.1.0, Release Train 2.2.0
    • priceDataMatchesTarget

      protected boolean priceDataMatchesTarget(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceableTarget target, @NonNull @NonNull PriceData priceData, @Nullable PriceableTargetPriceState priceState, boolean checkTerm, boolean checkRecurringFrequency, boolean checkPaymentStrategy)
      Compares the terms and characteristics of the priceData to those requested on the target to ensure it matches. The priceData should already match the target's id and type by this point.
      Parameters:
      target - The requested target to be priced
      priceData - The potential PriceData matching the target
      Returns:
      Whether priceData matches the terms and characteristics on the target.
      Since:
      Pricing Services 2.2.0, Release Train 2.3.0
    • buildSummaryFromPriceData

      protected PriceSummary buildSummaryFromPriceData(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceableTarget target, @NonNull @NonNull PriceData data)
      Builds a PriceSummary of data. This was introduced along with the new fields for recurring and usage prices.
      Parameters:
      target - The requested target to be priced
      data - The PriceData matching the target
      Returns:
      A PriceSummary of the data that matched target
      Since:
      Pricing Service 2.1.0, Release Train 2.2.0
      See Also:
    • filterPriceDataTiers

      protected List<PriceDataTier> filterPriceDataTiers(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceData priceData)
      Filters the tiers on the provided PriceData based on the attribute or characteristic. Typically, this will only be called when the PriceData.getTierPricingStrategy() is set to TierPricingStrategyType.TWO_FACTOR.
      Parameters:
      target - the priceable target
      priceData - the price data containing the tiers to filter
      Returns:
      the filtered list of price data tiers
      Since:
      Pricing Service 2.2.0, Release Train 2.3.0
    • getAttributeQuantity

      protected Integer getAttributeQuantity(Object targetAttribute)
      Hook point to get the quantity of an attribute used for tier filtering.
      Parameters:
      targetAttribute - the attribute value
      Returns:
      the quantity of the attribute
      Since:
      Pricing Service 2.2.0, Release Train 2.3.0
    • getCharacteristicQuantity

      protected Integer getCharacteristicQuantity(String targetCharacteristic)
      Hook point to get the quantity of a characteristic used for tier filtering.
      Parameters:
      targetCharacteristic - the attribute value
      Returns:
      the quantity of the attribute
      Since:
      Pricing Service 2.2.0, Release Train 2.3.0
    • filterTiersByAttributeQuantity

      protected List<PriceDataTier> filterTiersByAttributeQuantity(Integer totalAttributeQuantity, List<PriceDataTier> potentialTiers)
      Return only tiers that have the greatest PriceDataTier.getAttributeMinValue() that is greater or equal to the total attribute quantity. If no match, returns an empty list.
      Parameters:
      totalAttributeQuantity - the total attribute quantity
      potentialTiers - the potential tiers to filter
      Since:
      Pricing Service 2.2.0, Release Train 2.3.0
    • determineMaxTier

      protected Optional<PriceDataTier> determineMaxTier(com.broadleafcommerce.pricing.client.domain.PriceableTarget priceableTarget, List<PriceDataTier> priceDataTiers)
    • getPriceListPriceDetailFromModifier

      protected Optional<PriceListPriceDetail> getPriceListPriceDetailFromModifier(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList, PriceableTargetPriceState priceState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildModifiedPriceTiersList

      protected List<com.broadleafcommerce.pricing.client.domain.PriceDataTierRef> buildModifiedPriceTiersList(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceDetail priceDetail, String operationType, @NonNull @NonNull BigDecimal value)
    • buildModifiedPriceTiersList

      protected List<com.broadleafcommerce.pricing.client.domain.PriceDataTierRef> buildModifiedPriceTiersList(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceDetail originalDetail, PriceModifier priceModifier, com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList)
    • cloneTierRef

      protected com.broadleafcommerce.pricing.client.domain.PriceDataTierRef cloneTierRef(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceDataTierRef original, @NonNull @NonNull javax.money.MonetaryAmount newAmount)
      Returns a copy of the passed in PriceDataTierRef with an updated amount
      Parameters:
      original - PriceDataTierRef to clone
      newAmount - Price to set on the clone
      Returns:
      The clone with updated price
      Since:
      Pricing Service 2.2.0, Release Train 2.3.0
    • baseAmountFromState

      protected Optional<javax.money.MonetaryAmount> baseAmountFromState(String fieldToModify, PriceableTargetPriceState priceState)
    • isBaseField

      protected boolean isBaseField(String field)
    • getPriceModifierForTarget

      protected Optional<PriceModifier> getPriceModifierForTarget(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList)
    • getPriceModifierForTarget

      protected Optional<PriceModifier> getPriceModifierForTarget(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList, PriceableTargetPriceState priceState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • modifyPrice

      protected javax.money.MonetaryAmount modifyPrice(javax.money.MonetaryAmount baseAmount, String modificationType, BigDecimal modAmount)
      Performs the PriceModifier.getModificationType() on the base price.
    • modifyPrice

      protected javax.money.MonetaryAmount modifyPrice(javax.money.MonetaryAmount baseAmount, PriceModifier priceModifier, com.broadleafcommerce.pricing.client.domain.PriceableTarget priceableTarget, PriceList priceList)
    • performOtherOperation

      protected javax.money.MonetaryAmount performOtherOperation(String modificationType, BigDecimal modificationAmount, javax.money.MonetaryAmount baseAmount)
      Extension point for performing custom PriceModifier operations
    • getPriceFromElsewhere

      protected Optional<javax.money.MonetaryAmount> getPriceFromElsewhere(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Extension point for getting a PriceSummary from somewhere other than a PriceData or PriceList.getPriceModifier().
      See Also:
    • getPriceSummaryFromElsewhere

      protected Optional<PriceSummary> getPriceSummaryFromElsewhere(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceList priceList, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Extension point for getting a PriceSummary from somewhere other than a PriceData or PriceList.getPriceModifier().
      Since:
      Pricing Service 2.1.0, Release Train 2.2.0
    • getTargetsBaseDetails

      @NonNull protected Map<String,com.broadleafcommerce.pricing.client.domain.PriceDetail> getTargetsBaseDetails(@NonNull @NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceableTarget target, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Builds a map of PriceDetails for each field of PriceableTarget.getPriceableFields() where the key is the type.
      Parameters:
      target - The PriceableTarget
      contextInfo - Additional tenant and sandbox info
      Returns:
      A map of PriceDetails for each field of target#priceableFields where the key is the type.
    • addBasePriceDetail

      @Deprecated protected void addBasePriceDetail(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceableTargetPriceState priceState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • addBaseCostPriceDetail

      @Deprecated protected void addBaseCostPriceDetail(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, PriceableTargetPriceState priceState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getBasePrice

      @Nullable protected javax.money.MonetaryAmount getBasePrice(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getBaseCost

      @Nullable protected javax.money.MonetaryAmount getBaseCost(com.broadleafcommerce.pricing.client.domain.PriceableTarget target, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • putBestPriceForType

      protected Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> putBestPriceForType(String type, String priceKey, PriceableTargetPriceState priceState)
      Records the highest-priority best (lowest) price for the price list type out of all the matches found.
    • putBestBackupPriceForType

      protected Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> putBestBackupPriceForType(String type, String priceKey, PriceableTargetPriceState priceState)
      Records the best backup price for the price list type out of all the matches found.
    • putBestPriceForTypeInternal

      protected Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> putBestPriceForTypeInternal(String type, String priceKey, PriceableTargetPriceState priceState, boolean includeLimitedQuantity)
    • formatPrice

      protected String formatPrice(javax.money.MonetaryAmount price)
      Helper method to format a MonetaryAmount as a price string
    • getBestPriceForType

      @Deprecated protected Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> getBestPriceForType(Map<PriceList,javax.money.MonetaryAmount> pricesMap)
      Deprecated.
      in favor of #getBestPriceFromPriceLists(Map) in order to hold & pass on more details than just MonetaryAmount.
    • getBestPriceFromPriceLists

      protected Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> getBestPriceFromPriceLists(Map<PriceList,PriceListPriceDetail> priceListPriceDetailMap, com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext)
    • getBestPriceFromPriceLists

      protected Optional<com.broadleafcommerce.pricing.client.domain.PriceDetail> getBestPriceFromPriceLists(Map<PriceList,PriceListPriceDetail> priceListPriceDetailMap, javax.money.CurrencyUnit requestedCurrency, boolean includeLimitedQuantity)
      Picks the best (lowest) price for the price list type out of all the matches found.
    • getBestPriceOverall

      @Nullable @Deprecated(since="Pricing Service 2.3.0, Release Train 2.3.0", forRemoval=true) protected com.broadleafcommerce.pricing.client.domain.PriceDetail getBestPriceOverall(@Nullable Map<String,com.broadleafcommerce.pricing.client.domain.PriceDetail> prices, @Nullable Currency defaultCurrency)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since Pricing Services 2.2.0, Release Train 2.3.0, in favor of getBestPriceOverall(Map, PriceableTargetPriceState)
    • getBestPriceOverall

      @Nullable protected com.broadleafcommerce.pricing.client.domain.PriceDetail getBestPriceOverall(@Nullable Map<String,com.broadleafcommerce.pricing.client.domain.PriceDetail> prices, PriceableTargetPriceState priceState)
      Retrieves all of the PriceableFieldTypes in ascending order by PriceableFieldType.order(). Then, returns a PriceDetail for the best price found for the type.

      Out of the box, if a price with currency matching the default is found, we want to prioritize that. Otherwise, the lowest price is chosen.

      If there are more than one price that are equal to the lowest price (i.e. standard and sale price are equally the lowest), then we want to prioritize whichever PriceDetail that is not a sale price.

      Parameters:
      prices - map of price type (e.g., standardPrice, salePrice, contractPrice) to its corresponding PriceDetail
      priceState - the current PriceableTargetPriceState
      Returns:
      PriceDetail for the best price found
    • isEqualPrice

      protected boolean isEqualPrice(com.broadleafcommerce.pricing.client.domain.PriceDetail priceDetail1, com.broadleafcommerce.pricing.client.domain.PriceDetail priceDetail2)
      Checks if the given PriceDetails have the same price.
      Parameters:
      priceDetail1 - the first PriceDetail to compare
      priceDetail2 - the second PriceDetail to compare
      Returns:
      true if both PriceDetails have the same price, otherwise false
    • isSalePrice

      protected boolean isSalePrice(com.broadleafcommerce.pricing.client.domain.PriceDetail priceDetail)
      Checks if the given PriceDetail is of type PriceableFieldType.SALE_PRICE.
      Parameters:
      priceDetail - the PriceDetail to check against
      Returns:
      true of the given PriceDetail is of type PriceableFieldType.SALE_PRICE, otherwise false
    • getBestPriceOverall

      @Deprecated protected com.broadleafcommerce.pricing.client.domain.PriceDetail getBestPriceOverall(Map<String,com.broadleafcommerce.pricing.client.domain.PriceDetail> prices)
      Deprecated.
      in favor of getBestPriceOverall(Map, Currency)

      Retrieves all of the PriceableFieldTypes in ascending order by PriceableFieldType.order(). Then, returns a PriceDetail for the best price found for the type.

      Out of the box, the lowest price is chosen.

    • addPriceInfoForTarget

      protected com.broadleafcommerce.pricing.client.domain.PriceInfo addPriceInfoForTarget(List<com.broadleafcommerce.pricing.client.domain.PriceInfo> priceInfos, com.broadleafcommerce.pricing.client.domain.PriceableTarget priceableTarget, com.broadleafcommerce.pricing.client.domain.PriceDetail bestPriceDetail, PriceableTargetPriceState priceState, boolean skipDetails)
      Uses the best price detail found for the target and creates a PriceInfo for it. Then, adds PriceTypeDetails for each type of price found. Optionally, this also adds PriceDetails for all candidate prices found besides the best one, if skipDetails == false.
      Parameters:
      priceInfos - The current list of PriceInfos into which to add a new PriceInfo.
      priceableTarget - The PriceableTarget for which the new PriceInfo corresponds.
      bestPriceDetail - The PriceDetail of the best overall price from amongst all types of prices.
      priceState - The current PriceableTargetPriceState with fall the important pricing info discovered for the targets.
      skipDetails - Whether to not include PriceDetails in the PriceInfo
    • addBackupPriceInfo

      protected void addBackupPriceInfo(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, com.broadleafcommerce.pricing.client.domain.PriceDetail backupDetail, PriceableTargetPriceState priceState)
    • initPriceInfoFromDetail

      protected com.broadleafcommerce.pricing.client.domain.PriceInfo initPriceInfoFromDetail(com.broadleafcommerce.pricing.client.domain.PriceDetail detail, com.broadleafcommerce.pricing.client.domain.PriceableTarget target)
    • addPriceAdjustmentInfo

      protected void addPriceAdjustmentInfo(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, com.broadleafcommerce.pricing.client.domain.PriceDetail detail)
    • amountOrZero

      protected javax.money.MonetaryAmount amountOrZero(javax.money.CurrencyUnit currencyUnit, javax.money.MonetaryAmount amount)
    • addPriceTypeDetail

      protected void addPriceTypeDetail(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, String type, com.broadleafcommerce.pricing.client.domain.PriceDetail detail)
    • addPriceDetail

      @Deprecated(forRemoval=true, since="1.7.14, 2.0.1") protected void addPriceDetail(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, PriceList priceList, javax.money.MonetaryAmount price, Map<String,List<PriceDataTier>> priceTiers)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • addPriceDetail

      protected void addPriceDetail(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, PriceList priceList, PriceListPriceDetail listPriceDetail, Map<String,List<PriceDataTier>> priceTiers)
    • populatePriceDataTierRef

      protected com.broadleafcommerce.pricing.client.domain.PriceDataTierRef populatePriceDataTierRef(PriceDataTier priceDataTier)
    • getErrors

      protected org.springframework.validation.Errors getErrors(com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext priceInfoContext)
      Parameters:
      priceInfoContext - The price info context to bind an errors object to.
      Returns:
      An errors object bound to priceInfoContext
    • getPriceDataService

      protected PriceDataService<PriceData> getPriceDataService()
    • getRuleEvaluationService

      protected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService getRuleEvaluationService()
    • getPriceableFields

      protected PriceableFieldProperties getPriceableFields()
    • getPriceListService

      protected PriceListService<PriceList> getPriceListService()
    • getValidator

      protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator getValidator()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • setPriceDetailComparator

      @Autowired(required=false) public void setPriceDetailComparator(PriceDetailComparator priceDetailComparator)
    • getPriceInfoProperties

      protected PriceInfoProperties getPriceInfoProperties()
    • setPriceInfoProperties

      @Autowired public void setPriceInfoProperties(PriceInfoProperties priceInfoProperties)
    • getCurrencyConversionService

      protected CurrencyConversionService getCurrencyConversionService()
    • setCurrencyConversionService

      @Autowired public void setCurrencyConversionService(CurrencyConversionService currencyConversionService)