Class DefaultCalculationService
- All Implemented Interfaces:
CalculationService,Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
CalculationService.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO -
Field Summary
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManagerFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAbsoluteEntryTaxValue(long entryQuantity, TaxValue taxValue, Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap) protected voidaddRelativeEntryTaxValue(double entryTotal, TaxValue taxValue, Set<TaxValue> relativeEntryTaxValues, Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap) protected TaxValueapplyGrossMixedRate(TaxValue unappliedTaxValue, Map<Set<TaxValue>, Double> taxGroups, int digits, double taxAdjustmentFactor) protected TaxValueapplyNetMixedRate(TaxValue unappliedTaxValue, Map<Set<TaxValue>, Double> taxGroups, int digits, double taxAdjustmentFactor) voidcalculate(AbstractOrderModel order) Calculates the given order and all its entries unless they're already calculated and the order has not been modified.voidcalculate(AbstractOrderModel order, Date date) Calculates the given order and all its entries unless they're already calculated and the order has not been modified.protected TaxValuecalculateAbsoluteTotalTaxValue(CurrencyModel curr, String currencyIso, int digits, boolean net, TaxValue taxValue, double cumulatedEntryQuantities) protected doublecalculateDiscountValues(AbstractOrderModel order, boolean recalculate) Returns the total discount for this abstract order.voidcalculateEntries(AbstractOrderModel order, boolean forceRecalculate) calculateSubtotal(AbstractOrderModel order, boolean recalculate) voidcalculateTotals(AbstractOrderEntryModel entry, boolean recalculate) Recalculates given entries total prices and re-applies tax and discount values.voidcalculateTotals(AbstractOrderModel order, boolean recalculate) (re)calculates all totals for the given order.protected voidcalculateTotals(AbstractOrderModel order, boolean recalculate, Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap) calculates all totals.protected voidprotected doublecalculateTotalTaxValues(AbstractOrderModel order, boolean recalculate, int digits, double taxAdjustmentFactor, Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap) protected ListconvertDiscountValues(AbstractOrderModel order, List dvs) convertPriceIfNecessary(PriceValue pv, boolean toNet, CurrencyModel toCurrency, Collection taxValues) converts a PriceValue object into a double matching the target currency and net/gross - state if necessary.protected PriceValueprotected List<DiscountValue>protected List<DiscountValue>protected Collection<TaxValue>protected doublegetTaxCorrectionFactor(Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap, double subtotal, double total, AbstractOrderModel order) booleanDeprecated, for removal: This API element is subject to removal in a future version.protected doubleCalculates the sub total of all order entries with NO tax values.getUnappliedRelativeTaxValues(Collection<TaxValue> allTaxValues) protected booleanprotected booleanisAllEntriesTaxed(Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap, double subtotal, AbstractOrderModel order) booleanprotected booleanmustHandleTaxFreeEntries(Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap, double subtotal, AbstractOrderModel order) voidCalculates this entry even if the entry was calculated before.voidrecalculate(AbstractOrderModel order) recalculates the whole order and all its entries.voidrecalculate(AbstractOrderModel order, Date date) recalculates the whole order and all its entries.protected voidrecalculateOrderEntryIfNeeded(AbstractOrderEntryModel entry, boolean forceRecalculation) protected voidrefreshOrder(AbstractOrderModel order) booleanReturnBoolean.TRUEin case if order needs to be calculated.protected voidresetAdditionalCosts(AbstractOrderModel order, Collection<TaxValue> relativeTaxValues) protected voidprotected MapresetAllValues(AbstractOrderModel order) protected voidsaveOrder(AbstractOrderModel order) protected voidprotected voidvoidsetCommonI18NService(CommonI18NService commonI18NService) voidsetFindDeliveryCostStrategy(FindDeliveryCostStrategy findDeliveryCostStrategy) voidsetFindDiscountsStrategies(List<FindDiscountValuesStrategy> findDiscountsStrategies) voidsetFindPaymentCostStrategy(FindPaymentCostStrategy findPaymentCostStrategy) voidsetFindPriceStrategy(FindPriceStrategy findPriceStrategy) voidsetFindTaxesStrategies(List<FindTaxValuesStrategy> findTaxesStrategies) voidsetOrderRequiresCalculationStrategy(OrderRequiresCalculationStrategy orderRequiresCalculationStrategy) voidsetTaxFreeEntrySupport(boolean taxFreeEntrySupport) Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
Constructor Details
-
DefaultCalculationService
public DefaultCalculationService()
-
-
Method Details
-
calculate
Description copied from interface:CalculationServiceCalculates the given order and all its entries unless they're already calculated and the order has not been modified.So this method will fetch prices, taxes and discounts (using spring configurable strategies) for uncalculated or modified entries only - all other will remain unchanged. If at least one entry has been calculated or the order itself has been modified the totals will be calculated as well.
if you merely like to adjust totals while keeping prices, taxes and discounts you should call
CalculationService.calculateTotals(AbstractOrderModel, boolean)instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Specified by:
calculatein interfaceCalculationService- Parameters:
order- targetAbstractOrderModel- Throws:
CalculationException- if a pricefactory error occurred.
-
requiresCalculation
Description copied from interface:CalculationServiceReturnBoolean.TRUEin case if order needs to be calculated. Default implementation use calculationStrategy to get this information.- Specified by:
requiresCalculationin interfaceCalculationService
-
setCalculatedStatus
-
setCalculatedStatus
-
calculate
Description copied from interface:CalculationServiceCalculates the given order and all its entries unless they're already calculated and the order has not been modified.So this method will fetch prices, taxes and discounts (using spring configured strategies) for uncalculated or modified entries only - all other will remain unchanged. If at least one entry has been calculated or the order itself has been modified the totals will be calculated as well.
if you merely like to adjust totals while keeping prices, taxes and discounts you should call
CalculationService.calculateTotals(AbstractOrderModel, boolean)instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Specified by:
calculatein interfaceCalculationService- Parameters:
order- targetAbstractOrderModeldate- assumes a given date to perform calculations for - be careful with that since this method will calculate modified or uncalculated entries only, so the given date may not apply to all entries!- Throws:
CalculationException- if a pricefactory error occurred
-
calculateTotals
public void calculateTotals(AbstractOrderModel order, boolean recalculate) throws CalculationException Description copied from interface:CalculationService(re)calculates all totals for the given order. This does not trigger price, tax and discount calculation but takes all currently set price, tax and discount values as base.- Specified by:
calculateTotalsin interfaceCalculationService- Parameters:
order- targetAbstractOrderModelrecalculate- forces setting total even if order is marked as calculated- Throws:
CalculationException
-
calculateTotals
protected void calculateTotals(AbstractOrderModel order, boolean recalculate, Map<TaxValue, Map<Set<TaxValue>, throws CalculationExceptionDouble>> taxValueMap) calculates all totals. this does not trigger price, tax and discount calculation but takes all currently set price, tax and discount values as base. this method requires the correct subtotal to be set before and the correct tax value map.- Parameters:
recalculate- if false calculation is done only if the calculated flag is not settaxValueMap- the map { tax value -> Double( sum of all entry totals for this tax ) } obtainable viacalculateSubtotal(AbstractOrderModel, boolean)- Throws:
CalculationException
-
saveOrder
-
getTaxCorrectionFactor
protected double getTaxCorrectionFactor(Map<TaxValue, Map<Set<TaxValue>, throws CalculationExceptionDouble>> taxValueMap, double subtotal, double total, AbstractOrderModel order) - Throws:
CalculationException
-
mustHandleTaxFreeEntries
-
getTaxFreeSubTotal
Calculates the sub total of all order entries with NO tax values. -
isAllEntriesTaxed
-
recalculate
Description copied from interface:CalculationServicerecalculates the whole order and all its entries. this includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed price factory.if you merely like to adjust totals while keeping prices, taxes and discounts you should call
CalculationService.calculateTotals(AbstractOrderModel, boolean)instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Specified by:
recalculatein interfaceCalculationService- Parameters:
order- targetAbstractOrderModel- Throws:
CalculationException- if a pricefactory error occurred.
-
recalculate
Description copied from interface:CalculationServicerecalculates the whole order and all its entries. this includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed dedicated strategies (FindPriceStrategy,FindDeliveryCostStrategy,FindTaxValuesStrategy, etc... ).if you merely like to adjust totals while keeping prices, taxes and discounts you should call
CalculationService.calculateTotals(AbstractOrderModel, boolean)instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Specified by:
recalculatein interfaceCalculationService- Parameters:
order- targetAbstractOrderModeldate- the date to calculate prices for- Throws:
CalculationException- if a pricefactory error occurred
-
calculateEntries
public void calculateEntries(AbstractOrderModel order, boolean forceRecalculate) throws CalculationException - Throws:
CalculationException
-
calculateTotals
Description copied from interface:CalculationServiceRecalculates given entries total prices and re-applies tax and discount values. This does not include finding price, taxes or discount but uses all currently set values.- Specified by:
calculateTotalsin interfaceCalculationService- Parameters:
entry- targetAbstractOrderEntryModelrecalculate- forces the recalculation of the abstract order entry.
-
hasJaloStrategies
protected boolean hasJaloStrategies() -
calculateTotalTaxValues
-
recalculateOrderEntryIfNeeded
protected void recalculateOrderEntryIfNeeded(AbstractOrderEntryModel entry, boolean forceRecalculation) throws CalculationException - Throws:
CalculationException
-
recalculate
Description copied from interface:CalculationServiceCalculates this entry even if the entry was calculated before. This includes finding the correct base price, taxes and discount using the currently installed price factory.If prices should be left as currently set but the entry totals have to be consolidated (e.g. when the quantity has changed) call
CalculationService.calculateTotals(AbstractOrderEntryModel, boolean)instead !- Specified by:
recalculatein interfaceCalculationService- Parameters:
entry- targetAbstractOrderEntryModel- Throws:
CalculationException- if a pricefactory error occurred
-
refreshOrder
-
resetAllValues
- Throws:
CalculationException
-
resetAllValues
- Throws:
CalculationException
-
resetAdditionalCosts
protected void resetAdditionalCosts(AbstractOrderModel order, Collection<TaxValue> relativeTaxValues) -
convertPriceIfNecessary
public PriceValue convertPriceIfNecessary(PriceValue pv, boolean toNet, CurrencyModel toCurrency, Collection taxValues) converts a PriceValue object into a double matching the target currency and net/gross - state if necessary. this is the case when the given price value has a different net/gross flag or different currency.- Parameters:
pv- the base price to converttoNet- the target net/gross statetoCurrency- the target currencytaxValues- the collection of tax values which apply to this price- Returns:
- a new PriceValue containing the converted price or pv in case no conversion was necessary
-
convertDiscountValues
-
calculateSubtotal
-
calculateDiscountValues
Returns the total discount for this abstract order.- Parameters:
recalculate-trueforces a recalculation- Returns:
- totalDiscounts
-
calculateTotalTaxValues
protected double calculateTotalTaxValues(AbstractOrderModel order, boolean recalculate, int digits, double taxAdjustmentFactor, Map<TaxValue, Map<Set<TaxValue>, Double>> taxValueMap) - Parameters:
recalculate-digits-taxAdjustmentFactor-taxValueMap-- Returns:
- total taxes
-
addRelativeEntryTaxValue
-
addAbsoluteEntryTaxValue
-
getUnappliedRelativeTaxValues
-
calculateAbsoluteTotalTaxValue
protected TaxValue calculateAbsoluteTotalTaxValue(CurrencyModel curr, String currencyIso, int digits, boolean net, TaxValue taxValue, double cumulatedEntryQuantities) -
applyGrossMixedRate
-
applyNetMixedRate
-
findTaxValues
protected Collection<TaxValue> findTaxValues(AbstractOrderEntryModel entry) throws CalculationException - Throws:
CalculationException
-
findDiscountValues
protected List<DiscountValue> findDiscountValues(AbstractOrderEntryModel entry) throws CalculationException - Throws:
CalculationException
-
findGlobalDiscounts
protected List<DiscountValue> findGlobalDiscounts(AbstractOrderModel order) throws CalculationException - Throws:
CalculationException
-
findBasePrice
- Throws:
CalculationException
-
setCommonI18NService
-
setFindTaxesStrategies
-
setFindDiscountsStrategies
-
setFindPriceStrategy
-
setFindDeliveryCostStrategy
-
setFindPaymentCostStrategy
-
setOrderRequiresCalculationStrategy
public void setOrderRequiresCalculationStrategy(OrderRequiresCalculationStrategy orderRequiresCalculationStrategy) -
setTaxFreeEntrySupport
public void setTaxFreeEntrySupport(boolean taxFreeEntrySupport) -
getTaxFreeEntrySupport
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useisTaxFreeEntrySupport() -
isTaxFreeEntrySupport
public boolean isTaxFreeEntrySupport()
-
isTaxFreeEntrySupport()