Class DefaultFulfillmentCalculatorService<P extends FulfillmentCalculatorConfig>
java.lang.Object
com.broadleafcommerce.fulfillment.service.DefaultFulfillmentCalculatorService<P>
- All Implemented Interfaces:
FulfillmentCalculatorService
public class DefaultFulfillmentCalculatorService<P extends FulfillmentCalculatorConfig>
extends Object
implements FulfillmentCalculatorService
/** Default implementation of calculator service used to find, qualify, and process fulfillment
pricing using
FulfillmentCalculators.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultFulfillmentCalculatorService(FulfillmentCalculatorConfigService calcCfgService, List<FulfillmentCalculatorProvider> fulfillmentCalculatorProviders, FulfillmentCalculatorFilterService calculatorFilterService, FulfillmentCalculationService calculationService) Deprecated, for removal: This API element is subject to removal in a future version.DefaultFulfillmentCalculatorService(List<FulfillmentCalculatorProvider> fulfillmentCalculatorProviders, FulfillmentCalculatorFilterService calculatorFilterService, FulfillmentCalculationService calculationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected FulfillmentItemPriceResultbuildFulfillmentItemPriceResult(FulfillmentPriceResultHolder resultHolder, EnhancedFulfillmentPricingItem item) protected intcalculateItemsQuantity(@NonNull FulfillmentPriceResultHolder holder) protected com.broadleafcommerce.fulfillment.common.domain.WeightcalculateItemsWeight(@NonNull FulfillmentPriceResultHolder holder) protected FulfillmentItemPriceResultcalculateProratedResult(EnhancedFulfillmentPricingItem enhancedItem, javax.money.MonetaryAmount fulfillmentPrice, FulfillmentPriceResultHolder rh) Prorates the fulfillment price amongst the items.protected CalculatorSummaryResultprotected BandFielddetermineBandField(@NonNull FulfillmentPriceResultHolder holder) protected BigDecimaldetermineProrationAmountByPrice(BigDecimal eligibleItemTotal, BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) protected BigDecimaldetermineProrationAmountByQuantity(BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) protected BigDecimaldetermineProrationAmountByWeight(BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) protected booleanfilterForExistingIfNeeded(EnhancedFulfillmentPricingItem item, String defaultServiceLevel, String calcServiceLevel, boolean filterExisting) protected List<EnhancedFulfillmentPricingItem>filterItemsCalculatorCanHandle(List<EnhancedFulfillmentPricingItem> items, FulfillmentCalculator calculator, String defaultServiceLevel, boolean filterExisting) findEligibleFulfillmentPricingCalculators(FulfillmentPricingContext context, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given theFulfillmentPricingContext, this method returns a list of eligibleFulfillmentCalculatorcalculators that can be used to compute option pricing.protected FulfillmentCalculationServiceprotected FulfillmentCalculatorFilterServiceprotected StringgetDefaultServiceLevelForGroup(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group) protected List<FulfillmentCalculatorProvider>protected StringgetItemServiceLevel(EnhancedFulfillmentPricingItem item, String defaultServiceLevel) protected com.broadleafcommerce.common.extension.TypeFactoryprotected List<EnhancedFulfillmentPricingItem>getUnPricedItems(EnhancedFulfillmentPricingGroup group, String serviceLevel) protected WeightCalculationHelperprotected FulfillmentPriceResultHolderinitializeFulfillmentPriceResultHolderCommon(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnlyFlag) protected FulfillmentPriceResultHolderinitializeFulfillmentPriceResultHolderForGroup(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnlyFlag) protected FulfillmentPriceResultHolderinitializeFulfillmentPriceResultHolderForItem(FulfillmentPricingContext context, EnhancedFulfillmentPricingItem item, FulfillmentCalculator calculator, boolean existingOnlyFlag) protected voidpriceFulfillmentGroup(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnly) voidpriceFulfillmentGroups(FulfillmentPricingContext context, List<FulfillmentCalculator> calculators) Delegates topriceFulfillmentGroups(FulfillmentPricingContext, List, boolean)with the value from the request.protected voidpriceFulfillmentGroups(FulfillmentPricingContext context, List<FulfillmentCalculator> eligibleCalculators, boolean priceCurrentServiceLevelsOnly) Modifies the passed inEnhancedFulfillmentPricingGroupand its containedItemswith the computed price information.protected voidpriceFulfillmentItem(FulfillmentPricingContext context, EnhancedFulfillmentPricingItem item, List<FulfillmentCalculator> calculators) voidpriceFulfillmentItems(FulfillmentPricingContext context, List<FulfillmentCalculator> eligibleCalculators) Attempts to price items within the passed in fulfillment group according to the semantics of the passed in calculator.voidsetDefaultFulfillmentCalculatorComparator(DefaultFulfillmentCalculatorComparator defaultFulfillmentCalculatorComparator) voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) voidsetWeightCalculationHelper(WeightCalculationHelper weightCalculationHelper) protected voidsortFulfillmentCalculators(List<FulfillmentCalculator> calculators) Sorts the list of calculators using theDefaultFulfillmentCalculatorComparator.protected voidprotected voidprotected void
-
Constructor Details
-
DefaultFulfillmentCalculatorService
@Deprecated(forRemoval=true) public DefaultFulfillmentCalculatorService(FulfillmentCalculatorConfigService calcCfgService, List<FulfillmentCalculatorProvider> fulfillmentCalculatorProviders, FulfillmentCalculatorFilterService calculatorFilterService, FulfillmentCalculationService calculationService) Deprecated, for removal: This API element is subject to removal in a future version.Backward compatible constructor. TheFulfillmentCalculatorConfigServiceparameter was never used. -
DefaultFulfillmentCalculatorService
public DefaultFulfillmentCalculatorService(List<FulfillmentCalculatorProvider> fulfillmentCalculatorProviders, FulfillmentCalculatorFilterService calculatorFilterService, FulfillmentCalculationService calculationService)
-
-
Method Details
-
findEligibleFulfillmentPricingCalculators
public List<FulfillmentCalculator> findEligibleFulfillmentPricingCalculators(@NonNull FulfillmentPricingContext context, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given theFulfillmentPricingContext, this method returns a list of eligibleFulfillmentCalculatorcalculators that can be used to compute option pricing.- Specified by:
findEligibleFulfillmentPricingCalculatorsin interfaceFulfillmentCalculatorService- Parameters:
context- the pricing context containing the items and originating requestcontextInfo- the context info providing tenancy and application data- Returns:
- List of
Fulfillment Calculatorssorted in default order.
-
sortFulfillmentCalculators
Sorts the list of calculators using theDefaultFulfillmentCalculatorComparator.- Parameters:
calculators-
-
priceFulfillmentGroups
public void priceFulfillmentGroups(FulfillmentPricingContext context, List<FulfillmentCalculator> calculators) Delegates topriceFulfillmentGroups(FulfillmentPricingContext, List, boolean)with the value from the request. Modifies the passed inEnhancedFulfillmentPricingGroupand its containedItemswith the computed price information.- Specified by:
priceFulfillmentGroupsin interfaceFulfillmentCalculatorService- Parameters:
context- the pricing context containing the items and originating requestcalculators- the list of calculator to use for pricing
-
priceFulfillmentGroups
protected void priceFulfillmentGroups(FulfillmentPricingContext context, List<FulfillmentCalculator> eligibleCalculators, boolean priceCurrentServiceLevelsOnly) Modifies the passed inEnhancedFulfillmentPricingGroupand its containedItemswith the computed price information.- Parameters:
context- the pricing context containing the items and originating requesteligibleCalculators- List of the availableFulfillmentCalculators.priceCurrentServiceLevelsOnly- indicates whether to price all options or just the current service levels
-
priceFulfillmentItems
public void priceFulfillmentItems(FulfillmentPricingContext context, List<FulfillmentCalculator> eligibleCalculators) Attempts to price items within the passed in fulfillment group according to the semantics of the passed in calculator. Modifies the passed inEnhancedFulfillmentPricingGroupand its containedItemswith the computed price information.- Specified by:
priceFulfillmentItemsin interfaceFulfillmentCalculatorService- Parameters:
context- the pricing context containing the items and originating requesteligibleCalculators- List of the availableFulfillmentCalculators.
-
priceFulfillmentGroup
protected void priceFulfillmentGroup(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnly) -
priceFulfillmentItem
protected void priceFulfillmentItem(FulfillmentPricingContext context, EnhancedFulfillmentPricingItem item, List<FulfillmentCalculator> calculators) -
buildFulfillmentItemPriceResult
protected FulfillmentItemPriceResult buildFulfillmentItemPriceResult(FulfillmentPriceResultHolder resultHolder, EnhancedFulfillmentPricingItem item) -
initializeFulfillmentPriceResultHolderForItem
protected FulfillmentPriceResultHolder initializeFulfillmentPriceResultHolderForItem(FulfillmentPricingContext context, EnhancedFulfillmentPricingItem item, FulfillmentCalculator calculator, boolean existingOnlyFlag) -
initializeFulfillmentPriceResultHolderForGroup
protected FulfillmentPriceResultHolder initializeFulfillmentPriceResultHolderForGroup(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnlyFlag) -
determineBandField
-
calculateItemsWeight
protected com.broadleafcommerce.fulfillment.common.domain.Weight calculateItemsWeight(@NonNull @NonNull FulfillmentPriceResultHolder holder) -
calculateItemsQuantity
-
initializeFulfillmentPriceResultHolderCommon
protected FulfillmentPriceResultHolder initializeFulfillmentPriceResultHolderCommon(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnlyFlag) -
getDefaultServiceLevelForGroup
protected String getDefaultServiceLevelForGroup(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group) -
updateGroupWithResults
-
getUnPricedItems
protected List<EnhancedFulfillmentPricingItem> getUnPricedItems(EnhancedFulfillmentPricingGroup group, String serviceLevel) -
filterItemsCalculatorCanHandle
protected List<EnhancedFulfillmentPricingItem> filterItemsCalculatorCanHandle(List<EnhancedFulfillmentPricingItem> items, FulfillmentCalculator calculator, String defaultServiceLevel, boolean filterExisting) -
filterForExistingIfNeeded
protected boolean filterForExistingIfNeeded(EnhancedFulfillmentPricingItem item, String defaultServiceLevel, String calcServiceLevel, boolean filterExisting) -
getItemServiceLevel
protected String getItemServiceLevel(EnhancedFulfillmentPricingItem item, String defaultServiceLevel) -
updateGroupSummary
-
createCalculatorSummaryResult
-
updateEligibleItems
-
calculateProratedResult
protected FulfillmentItemPriceResult calculateProratedResult(EnhancedFulfillmentPricingItem enhancedItem, javax.money.MonetaryAmount fulfillmentPrice, FulfillmentPriceResultHolder rh) Prorates the fulfillment price amongst the items. If the fulfillment price was based on weight, then the price is apportioned according to weight. If price, then price. If price and weight are 0, then quantity is used as a fallback. -
determineProrationAmountByPrice
protected BigDecimal determineProrationAmountByPrice(BigDecimal eligibleItemTotal, BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) -
determineProrationAmountByWeight
protected BigDecimal determineProrationAmountByWeight(BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) -
determineProrationAmountByQuantity
protected BigDecimal determineProrationAmountByQuantity(BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) -
getFulfillmentCalculatorProviders
-
getCalculatorFilterService
-
getCalculationService
-
getWeightCalculationHelper
-
setWeightCalculationHelper
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
getDefaultFulfillmentCalculatorComparator
-
setDefaultFulfillmentCalculatorComparator
public void setDefaultFulfillmentCalculatorComparator(DefaultFulfillmentCalculatorComparator defaultFulfillmentCalculatorComparator)
-