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
FulfillmentCalculator
s.-
Constructor Summary
ConstructorDescriptionDefaultFulfillmentCalculatorService
(FulfillmentCalculatorConfigService calcCfgService, List<FulfillmentCalculatorProvider> fulfillmentCalculatorProviders, FulfillmentCalculatorFilterService calculatorFilterService, FulfillmentCalculationService calculationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected FulfillmentItemPriceResult
buildFulfillmentItemPriceResult
(FulfillmentPriceResultHolder resultHolder, EnhancedFulfillmentPricingItem item) protected int
calculateItemsQuantity
(@NonNull FulfillmentPriceResultHolder holder) protected com.broadleafcommerce.fulfillment.common.domain.Weight
calculateItemsWeight
(@NonNull FulfillmentPriceResultHolder holder) protected FulfillmentItemPriceResult
calculateProratedResult
(EnhancedFulfillmentPricingItem enhancedItem, javax.money.MonetaryAmount fulfillmentPrice, FulfillmentPriceResultHolder rh) Prorates the fulfillment price amongst the items.protected CalculatorSummaryResult
protected BandField
determineBandField
(@NonNull FulfillmentPriceResultHolder holder) protected BigDecimal
determineProrationAmountByPrice
(BigDecimal eligibleItemTotal, BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) protected BigDecimal
determineProrationAmountByQuantity
(BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) protected BigDecimal
determineProrationAmountByWeight
(BigDecimal fulfillmentTotal, com.broadleafcommerce.fulfillment.common.domain.FulfillmentPricingItem item, FulfillmentPriceResultHolder rh) protected boolean
filterForExistingIfNeeded
(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 eligibleFulfillmentCalculator
calculators that can be used to compute option pricing.protected FulfillmentCalculationService
protected FulfillmentCalculatorFilterService
protected String
getDefaultServiceLevelForGroup
(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group) protected List<FulfillmentCalculatorProvider>
protected String
getItemServiceLevel
(EnhancedFulfillmentPricingItem item, String defaultServiceLevel) protected com.broadleafcommerce.common.extension.TypeFactory
protected List<EnhancedFulfillmentPricingItem>
getUnPricedItems
(EnhancedFulfillmentPricingGroup group, String serviceLevel) protected WeightCalculationHelper
protected FulfillmentPriceResultHolder
initializeFulfillmentPriceResultHolderCommon
(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnlyFlag) protected FulfillmentPriceResultHolder
initializeFulfillmentPriceResultHolderForGroup
(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnlyFlag) protected FulfillmentPriceResultHolder
initializeFulfillmentPriceResultHolderForItem
(FulfillmentPricingContext context, EnhancedFulfillmentPricingItem item, FulfillmentCalculator calculator, boolean existingOnlyFlag) protected void
priceFulfillmentGroup
(FulfillmentPricingContext context, EnhancedFulfillmentPricingGroup group, FulfillmentCalculator calculator, boolean existingOnly) void
priceFulfillmentGroups
(FulfillmentPricingContext context, List<FulfillmentCalculator> calculators) Delegates topriceFulfillmentGroups(FulfillmentPricingContext, List, boolean)
with the value from the request.protected void
priceFulfillmentGroups
(FulfillmentPricingContext context, List<FulfillmentCalculator> calculatorsParam, boolean priceCurrentServiceLevelsOnly) Modifies the passed inEnhancedFulfillmentPricingGroup
and its containedItems
with the computed price information.protected void
priceFulfillmentItem
(FulfillmentPricingContext context, EnhancedFulfillmentPricingItem item, List<FulfillmentCalculator> calculators) void
priceFulfillmentItems
(FulfillmentPricingContext context, List<FulfillmentCalculator> calculatorsParam) Attempts to price items within the passed in fulfillment group according to the semantics of the passed in calculator.void
setDefaultFulfillmentCalculatorComparator
(DefaultFulfillmentCalculatorComparator defaultFulfillmentCalculatorComparator) void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) void
setWeightCalculationHelper
(WeightCalculationHelper weightCalculationHelper) protected void
sortFulfillmentCalculators
(List<FulfillmentCalculator> calculators) Sorts the list of calculators using theDefaultFulfillmentCalculatorComparator
.protected void
protected void
protected void
-
Constructor Details
-
DefaultFulfillmentCalculatorService
public DefaultFulfillmentCalculatorService(FulfillmentCalculatorConfigService calcCfgService, 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 eligibleFulfillmentCalculator
calculators that can be used to compute option pricing.- Specified by:
findEligibleFulfillmentPricingCalculators
in interfaceFulfillmentCalculatorService
- Parameters:
context
- the pricing context containing the items and originating requestcontextInfo
- the context info providing tenancy and application data- Returns:
- List of
Fulfillment Calculators
sorted 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 inEnhancedFulfillmentPricingGroup
and its containedItems
with the computed price information.- Specified by:
priceFulfillmentGroups
in 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> calculatorsParam, boolean priceCurrentServiceLevelsOnly) Modifies the passed inEnhancedFulfillmentPricingGroup
and its containedItems
with the computed price information.- Parameters:
context
- the pricing context containing the items and originating requestcalculatorsParam
- 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> calculatorsParam) Attempts to price items within the passed in fulfillment group according to the semantics of the passed in calculator. Modifies the passed inEnhancedFulfillmentPricingGroup
and its containedItems
with the computed price information.- Specified by:
priceFulfillmentItems
in interfaceFulfillmentCalculatorService
- Parameters:
context
- the pricing context containing the items and originating requestcalculatorsParam
- 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)
-